Concepts

Behavior contracts

A contract records what a resource must keep allowing and what it must keep denying. Every fix, and every later change, is checked against it.

What a contract is

A YAML file per resource, built from usage evidence and kept in your repo next to the code. By default it lives in posturanet/contracts/, named after the resource's address. Set contracts.dir in .posturanet.yml to move it.

$ posturanet contract build finding.json --evidence-file flows.json

  ✓ evidence    flow logs · 89 days · confidence high · 5 sources
                10.0.5.9/32       6,218 conns · 22/tcp · daily
                203.0.113.7/32    1,067 conns · 22/tcp · daily  ! external, review owner
                198.51.100.23/32      3 conns · 22/tcp · one_off ! not kept, likely a scanner
  ! contract    module.bastion.aws_security_group.this.yaml · 1 source needs review

Result   CONTRACT · 3 must_allow · 2 must_deny · 1 needs review

How it's built

  • Sources, actions or principals seen regularly in the evidence window become must_allow.
  • One-off traffic, such as a scanner, isn't kept.
  • Outside sources are kept but flagged, so the owner reviews them before the contract is approved.
  • must_deny holds what the finding was about, such as SSH from 0.0.0.0/0.

You approve a contract by merging it like any other code. Each contract says what it couldn't see: behavior rarer than once per window isn't in it.

How it's used

Before a fix PR opens, the Z3 solver checks the new rules against the contract: every must_allow still allowed, every must_deny denied. The result always states the model scope, meaning what the check covered and what it didn't.

After that, the contract gates later changes, from people and from AI agents alike:

$ posturanet contract check --plan tfplan.json   # PASS 0 · BLOCK 5 · UNKNOWN 3
$ posturanet contract check --source            # offline, from your code

In GitHub Actions, the same check posts a "PosturaNet contract" check run and one sticky PR comment on BLOCK or UNKNOWN.

Keeping contracts current (Team)

Usage changes. With a Team key, contract refresh runs on a schedule and proposes contract updates as PRs, and contract live opens a GitHub issue when a live resource drifts from its contract. The org-wide gate applies one config to every repo in your organization.

Next: Evidence