Run on new findings
When Security Hub reports a new failed finding, an EventBridge rule sends it to your repository, and PosturaNet runs fix on it with the usual evidence, contract and validation checks. Nothing is merged or applied.
What you need
- A license key with the triggers feature.
- PosturaNet's read-only role (posturanet init prints its policy).
- A fine-grained GitHub token for this repo only, with Contents read and write. GitHub requires that for repository_dispatch. It is stored in the EventBridge connection, not in your repo.
1. Deploy the EventBridge rule
PosturaNet prints a CloudFormation template; you deploy it in the Security Hub account and region. Add --controls EC2.19,S3.8 to limit it to some controls.
$ posturanet triggers template --github-repo acme/infra > triggers.json $ aws cloudformation deploy --template-file triggers.json --stack-name posturanet-triggers \ --capabilities CAPABILITY_IAM --parameter-overrides GitHubToken=<token>
2. Add the workflow
Copy posturanet-triggers.yml from the posturanet-pro package to .github/workflows/. Add the secret POSTURANET_LICENSE and the variable POSTURANET_READONLY_ROLE_ARN.
Each event runs posturanet dispatch, which re-checks that every finding is still failing and runs fix on up to 10 of them. A fix that passes every check opens or updates its PR; one that doesn't stops with the reason in the job log. One finding never gets two PRs.
Try it without AWS
$ posturanet dispatch event.json --repo infra/ # a saved EventBridge event; checks only, no PR