Skip to content

Security: infrastructure findings leave their pull request or run when it is over - #666

Merged
nambok merged 2 commits into
mainfrom
fix/infra-findings-release
Nov 14, 2026
Merged

nambok merged 2 commits into
mainfrom
fix/infra-findings-release

Conversation

@nambok

@nambok nambok commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #661, for the gap it named. Infrastructure findings keep their own records (INFRAFINDING#) and nothing released them when a claim ended:

  • A fix pull request closed without merging left the record pr_open. The Infrastructure tab kept the closed pull request and never offered "Open fix PR" again.
  • A fix run that was cancelled or failed left the record fixing for good. This store had no fallback at all.
  • A reopened pull request was never noticed.

Only a read of the AWS account ever changed such a record. They now have the same guarantees as dependency findings, through the same code.

Changes

  • One set of rules, generalised, not copied. common::security_release gains the Claim trait. Dependency findings and infrastructure records both implement it. The words, the person-closed record and the holds are shared (closed_words, closed_record, run_end), so the two stores cannot drift.
  • One reconciliation. worker/src/passes/security_release.rs::reconcile is generic over Claim. Both stores use the same reads of GitHub and the run records (Reads), the same pr and run events from the gateway (no new gateway events were needed: the webhook filter already covers coderhelm/security-infra- branches), and the same sweep: first for each team, on its own clock, at most 100 pull requests and 50 runs per team per sweep, the rest in turn.
  • Infrastructure records (common/src/infra_vuln/records.rs): the pull request record gets closed_at, closed_by, closed_by_person; the record gets hold_until, claimed_at and the note shown after a person ended its run. Records stored before read as before.
    • Closed unmerged: open again, with who closed it and when; no run starts by itself for 7 days. A person asking never waits.
    • Run cancelled or closed by a person: released, 7 day hold. Run failed: released, 1 day hold.
    • Reopened: the record is in the pull request again.
    • GitHub or the run records not answering: nothing changes.
  • What stays this store's own:
    • A merge is recorded and never closes a finding. Only a read of the account does.
    • A pull request the replacement guard made a draft is not "closed": GitHub has it open, and the record is left exactly as it is. If a person closes the draft, the record says so and the finding keeps its runbook, with no attempt by itself until its code or target changes.
    • A pull request closed while the guard's refusal stood keeps the refusal standing, and is not taken back if reopened.
    • A pull request the run opened and the record never learned is not recorded by the shared rule: it goes through on_pr_opened, so the guard reads it first.
    • A fix round that ends (cancelled, failed, never started) without settling its pull request is the guard's second step: the pull request becomes a draft with the reason at its top and the finding falls back to its runbook. It is never left as a ready pull request with the refused change, and never closed.
  • Requests and Retry. "Open fix PR" and Retry check the record against GitHub and its run first, so a person who just closed the pull request is never told it is still open. Retry on an infrastructure fix run whose pull request is gone queues the same request as the button: a new run from the finding as it stands and a new pull request, never the closed one. With an open pull request, a held draft or a working run, Retry behaves as before.
  • Incident case as_infra_closed_pr_keeps_record and its row in docs/incidents.md.

Records that are stale today are repaired by the first sweep after deploy, with no step by a person, as for dependency findings.

The dashboard change that offers the fix again on the Infrastructure tab is a separate small pull request in CoderHelm/coderhelm.

Verification

  • cargo fmt --check --all, cargo clippy --workspace --all-targets -- -D warnings and cargo test --workspace pass locally: common 2,301 passed, gateway 913, worker 1,784, none failed.
  • The rules on a record: closed by a person (record, hold, idempotent, gone, GitHub unknown), merged (recorded, never fixed), a held draft (left alone while open; closed keeps the runbook; never reattached), reopened (and not once a new run has it), run cancelled and failed (holds, note), no run on record, a pull request the record never learned, a fix round that ends, a close during the fix round, and records stored before these fields.
  • The reconciliation on records with the fakes of GitHub and the run records: sweep and webhook event end in the same place, a second sweep writes nothing, GitHub down releases nothing, a cancelled run releases and a working one is left, the guard's opening path is used, the fix round's draft step.
  • The gateway's Retry decision for an infrastructure run. All of Security: a finding leaves its pull request or run when that is over #661's tests still pass on the generalised code.
  • Not verified live: nothing was deployed and no AWS or GitHub call was made against an install. Converting a pull request to a draft on GitHub after a dead fix round is exercised only up to the decision (newly_drafted), not against GitHub.

…n it is over

#661 gave dependency findings a release when their fix pull request
closed or their run ended. Infrastructure findings keep their own
records and had none: a closed pull request left the record `pr_open`
(the page never offered the fix again), a cancelled or failed run left
it `fixing` for good, and a reopened pull request was never noticed.

- `common::security_release` is generalised instead of copied: both
  stores are a `Claim`, and the words, the person-closed record and the
  holds (`closed_words`, `closed_record`, `run_end`) are shared.
- The worker's `reconcile` is generic over `Claim`. Both stores use the
  same reads of GitHub and the run records (`Reads`), the same `pr` and
  `run` events, and the same sweep, first for each team, with the same
  bounds.
- Infrastructure records get the closed record on their pull request, a
  hold on automatic attempts (a person asking never waits) and the time
  their run claimed them.
- What stays this store's own: a merge is recorded and never closes a
  finding (only a read of the account does); a draft the replacement
  guard holds is not closed and is left as it is; a finding on its
  runbook stays there until its code or target changes; a pull request
  the record never learned goes through the guard before it is recorded;
  a fix round that ends without settling its pull request becomes the
  guard's second step (a draft), never a ready pull request.
- "Open fix PR" and Retry check the record against GitHub first. Retry
  on an infrastructure fix run whose pull request is gone is a new
  request for the finding as it stands.

Incident case `as_infra_closed_pr_keeps_record`.
Both sides kept: the incident list and its table carry `ar`, `as` and
`at` in order. The draft hold still goes through description::save.
@nambok
nambok merged commit 1aeb386 into main Nov 14, 2026
10 checks passed
@nambok
nambok deleted the fix/infra-findings-release branch November 14, 2026 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant