Repository navigation
Security: a finding leaves its pull request or run when that is over - #661
Merged
Merged
Conversation
A finding in a fix pull request that a person closed stayed `pr_open`, and one claimed by a cancelled fix run stayed `fixing`, so the Security page could not select it and nobody could ask for a new fix. A repository had 274 findings in that state a day after its pull request was closed. Why: the pull request webhook recorded the close on the run and never told the findings; cancelling or closing a run wrote only the run; and the one comparison with GitHub was the last step of the scheduled sweep (`track_prs`), behind the time budget every team's sources and triage share, reading any failed GitHub request as "still open". A `fixing` finding waited 12 hours on a guess. - `common::security_release`: the rules. A pull request merged fixes the finding; closed unmerged gives it back with who closed it and when on the pull request's record, and automatic fixes wait 7 days (a person asking never waits); reopened, the finding is in it again; gone from GitHub, released. A run that ended without a pull request releases its findings (7 days after a person cancelled or closed it, 1 day after it failed). GitHub not answering changes nothing. A fact applied twice writes nothing. - `worker::passes::security_release`: reads GitHub and the run records and applies the rules. Called by the new `pr` and `run` events and by every sweep, first for each team, on a clock of its own, for teams the sweep's budget never reaches too, at most 100 pull requests and 50 runs per team per sweep, the rest in turn. A team with security fixes off is released once a day. - Gateway: a security pull request closing or reopening, a cancelled run and a closed run queue those events. - Retry on a fix run whose pull request is gone is a new request for the unit's findings as they stand: a new plan and a new pull request, never the closed one. A request queued past a daily limit now starts although the finding keeps its closed pull request's record. - The groups list carries the run's ticket and prefers a member's open pull request, for the dashboard's reasons and links. Incident case `ap_closed_pr_keeps_findings`.
nambok
added a commit
that referenced
this pull request
Nov 14, 2026
…n it is over (#666) #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`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On the Security page an admin filtered to one repository and could select nothing: every checkbox was off, the header's too. They had closed CoderHelm's dependency fix pull request for that repository to start again and cancelled its fix run. Later, the repository's findings still read
pr_open, and a finding in a pull request cannot be picked.Root cause: nothing released a finding when its claim ended.
gateway/src/routes/github_webhook.rs, theclosedbranch from line 1899) recorded the outcome on the run (line 2036) and never told the security findings. There was no path forreopenedeither.gateway/src/routes/api.rs,cancel_run, line 3031) and closing one wrote only the run record.track_prsinworker/src/passes/security_fixes.rs(line 2277), the last per-finding step of the 20 minute sweep (called at line 2256, after the sources and triage). It returns at once when the sweep's time is up (line 2287), and that time is one 300 second budget shared by every team in a fixed order (lines 54, 3900 and 3903), so a team behind others, or a team with a long sync or triage, was never compared. A failed GitHub request was read as "still open" (lines 2439 and 2442). Afixingfinding was released only after 12 hours without a write (line 2293).common/src/security_fixes.rsline 2166,f.pr.is_none()).Which of the sweep's conditions kept this install's findings stale for a day is not something the code can say; it needs the worker's logs for that team. Every one of them is closed here.
Paths, before and now:
Changes
common/src/security_release.rs(new): the rules, pure.settle_prandsettle_runtake what GitHub or the run record says and return the finding as it should stand with its timeline line. A pull request closed unmerged returns its findings to open, recordsclosed_at,closed_byandclosed_by_personon the pull request's record, and holds automatic fixes for 7 days; a person asking for a fix never waits on the hold. A run a person cancelled or closed holds 7 days, a failed one 1 day. "GitHub did not answer" changes nothing. Applying a fact twice writes nothing.worker/src/passes/security_release.rs(new):reconcilereads GitHub once per pull request and the run records once per ticket and applies the rules. It runs for the newprandrunevents, and in every sweep first for each team with its own 45 second clock, also for teams the sweep's shared budget no longer reaches (up to 240 seconds more). Bounded at 100 pull requests and 50 runs per team per sweep; the rest take their turn on the following sweeps. A team with security fixes turned off is released once a day.worker/src/passes/security_fixes.rs:track_prskeeps CI, cards and descriptions and settles a merge or close through the same rules; the 12 hour guess is gone;enqueuerecords when a run claimed a finding;on_pr_openedleaves fixed and dismissed findings alone; newretryevent.pull_requestclosed and reopened queue aprevent for CoderHelm's security pull requests and adopted Dependabot and Renovate ones;cancel_runand the close route queue arunevent;retry_runon a security fix run whose pull request is gone queuesretryinstead of replaying the old plan.requested_unitsno longer skips a finding because it keeps a closed pull request's record.ticketand prefer a member's open pull request over an older closed one.ap_closed_pr_keeps_findingsand its row indocs/incidents.md.How today's stale records are repaired: no step by a person. After deploy the first sweep (within 20 minutes) reads each pull request a finding records as open. The closed one answers "closed, by this login, at this time", and its findings go back to open with that record. Findings left
fixingby an ended run are released from the run's record the same way.Not in this pull request: infrastructure findings keep their own records and have no path for a pull request closed unmerged. They have no selection on the page, so this incident does not reach them, but the same gap is there.
Verification
cargo fmt --check --all,cargo clippy --workspace --all-targets -- -D warningsandcargo test --workspacepass locally: common 2,292 passed, gateway 912, worker 1,774, none failed.f.pr.is_none()back, the incident case's retry test fails.