Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/incidents.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ pipeline still calls it there.
| an. `an_six_database_findings` | Security, Infrastructure showed six database findings, every one a one-command runbook with no pull request although the databases were in the team's code. The same CVE stood on an operating system update, an Aurora PostgreSQL patch and a MySQL upgrade. A database with a Terraform-generated identifier and an Aurora cluster defined through a module were "not found in code". A patch and an upgrade pending on one cluster were unrelated rows, an update on a second instance was dropped, and the account was read one page deep. | An advisory is attached only where it applies (service, engine, version range, kind of action, date); an action AWS publishes with no CVE list gets none. An action is named for what it means on its ARN. One database's pending actions are one ordered set of rows. The defining code is found from stack records, resource type and attributes, module calls and variable files, graded, and a guess never becomes a pull request. An update with a code equivalent is a pull request on the line that sets the value; one that cannot be expressed in code stays a complete runbook and says why. A change that would replace a database is refused. |
| ao. `ao_stopped_log_finding` | Two log findings of one production service stayed on the Logs page as Critical and New, each with "Create fix PR" and "Not started automatically: not sure the repo is ...; check it and start the fix", a day and a half after their error had stopped: 735 matching lines in one six-hour window, then none while the service wrote its usual volume. The team had fixed the cause the day before. Only time closed a finding (three days without a line), so a problem that was over read as a live emergency that needed a person. | Every analysis counts each open finding's own lines on its own log group and keeps the count with the lines the group wrote. Two analyses in a row with no matching line at the service's usual volume make the finding stopped: shown and counted as stopped, never New or a live critical, with no automatic fix and no stale "choose a repo" reason. When the service itself went quiet nobody can tell, and it stays as it was. A burst that stopped after a change in its repo resolves after one day instead of three, with that evidence in the reason; an error that keeps coming back keeps its longer period. Seen again, it is live again and its fix may start. Evidence for the repo that couldn't be weighed is weighed again next sweep and never put to a person. |
| ap. `ap_closed_pr_keeps_findings` | An admin closed CoderHelm's dependency fix pull request for a repository to start again and cancelled its fix run. On the Security page every checkbox for that repository was off, the header's too, with nothing to say why: 274 findings still read "in a pull request" a day later. The pull request webhook recorded the close on the run and never told the findings, cancelling a run wrote only the run, and the one comparison with GitHub was the last step of the scheduled sweep, behind the time every team's sources and triage left, reading a failed request as "still open". | A finding is `pr_open` only while its pull request is open and `fixing` only while its run works (`common::security_release`). A pull request closed unmerged gives its findings back with who closed it and when, a cancelled or closed run releases what it claimed, a reopened pull request takes its findings back, and a merge fixes them: on the webhook or the person's action, and again on every sweep, first for each team and on a clock of its own, bounded and in turn, so a missed webhook and records stale from before heal within a sweep. A person asking for a fix always gets one; automatic fixes wait a week after a person said no. Retry on the run is a new request from the findings as they are now and opens a new pull request. GitHub not answering is never read as open, closed or merged. |
| ar. `ar_description_stamped_to_the_head` | A dependency run's pull request was described from a head, and the head then moved on without it. A feedback round changed an override in the manifest and the description was rebuilt on that commit, where the lockfile still resolved the old version ("not moved on the head"); the lockfile was regenerated in the commits after it and the run completed. The description still said not moved, still counted the advisory as not fixed, still listed the package under open findings and "the lockfile is out of sync" under Open items, and CoderHelm's own review of the final head left that as a note. The checks step on an open pull request never rebuilt the computed sections, a regenerated lockfile was pushed with nothing after it, a review wrote its findings into the copy of the description it had read when it started (undoing a rebuild made meanwhile), and nits on CoderHelm's own pull request ended the loop. | The description names the head it was built for, and whenever that is not the pull request's head it is rebuilt: after every message in which CoderHelm moved the branch (seen in the one place every request leaves the GitHub client), in the checks and settle step, before a review of its own pull request, in the pull request watch, and at the end of the run, which never completes while the two differ. A review writes on the description as it is now and only for the head it reviewed. An item that says a lockfile is out of sync is checked on the head, never carried. A finding that the description is behind the code is settled by the rebuild, and every finding on CoderHelm's own pull request that is not pure style is its own to act on. |
| ba. `ba_verdict_on_old_commit` | A run finished as Done with its pull request ready while its own reviewer stood at "Changes requested" on a commit older than the head, and the run page said a person was needed and that merging was the team's call. The last fix was pushed, and the wake-up that found CI green with no event to read completed the run through an ending that skips the review step, so the new head was never reviewed. | Every completion and the sweep look at the finished run's pull request (`pr_watch`): no reviewer verdict on the head asks for the review of that commit, once per head; changes requested on the head get their fix round, and when the run's rounds are over the findings are deferred on the pull request with the reason. The run page names the one true reason the pull request is where it is (`common::merge_standing`) and names a person only for the team's own rule, with where it is set. |
| bb. `bb_flaky_not_broken` | An end-to-end workflow failed on a timeout in a spec the change never touched, as it had on unrelated pull requests that week. The run spent fix rounds editing the spec's timeout and a retry helper. Where the GitHub App may not write Actions, the re-run tried first was refused and the same fix round followed. | Before a CI fix round the failure is judged (`common::flaky_checks`): a failure naming a changed file is the change's; a check with a record of failing and then passing on one commit of other pull requests, naming no changed file, is re-run once and no code changes for it, and the pull request says which check, the evidence and what was done. A refused re-run is said with the permission by name and still changes no code. The record is per repository and learns only from a commit that failed and then passed unchanged. |
| bc. `bc_stays_through_merge_and_deploy` | Pull requests were left as they were after their runs finished: one conflicted after its base moved, one went red a day later on a commit status no event carries, and one merged by a person had its production deploy fail with nothing watching. | A finished run's pull request is looked at on completion and by the sweep: a conflict starts the conflict round once per base commit, red checks not red on the base go to the fix loop once per head, and a merge by anyone gets its merge commit's deploy watched once. A deploy of CoderHelm's own change that fails on checks passing before the merge gets a revert pull request with the failing jobs as evidence, ready for the team's approval and never merged by CoderHelm; files changed again since are never overwritten. |
Expand Down
130 changes: 130 additions & 0 deletions services/common/src/dep_head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,4 +626,134 @@ mod tests {
Resolved::Unknown { .. }
));
}

// ── Suffixed versions, exact-version overrides, a later head ────────

#[test]
fn a_version_with_a_suffix_is_read_on_its_line() {
let unit = FixUnit {
bumps: vec![bump("xml-kit", "1.4.4-lts.1", "2.0.3")],
..Default::default()
};
let f = finding("GHSA-s", "xml-kit", "1.4.4-lts.1", Some("2.0.3"));
// An override keyed on the exact version moved every copy to 2.0.3.
let moved = LockAt {
path: "pnpm-lock.yaml".into(),
base: copies(&[("xml-kit", "1.4.4-lts.1")]),
head: copies(&[("xml-kit", "2.0.3")]),
why: String::new(),
};
let facts = resolve(&unit, "h2", &[moved]);
assert_eq!(facts.version_cell(0), "1.4.4-lts.1 to 2.0.3 (major)");
assert_eq!(facts.fixed(&unit, &f), Fixed::Yes);
// A patched build on the same line, also suffixed.
let unit_lts = FixUnit {
bumps: vec![bump("xml-kit", "1.4.4-lts.1", "1.4.4-lts.2")],
..Default::default()
};
let f_lts = finding("GHSA-s", "xml-kit", "1.4.4-lts.1", Some("1.4.4-lts.2"));
let same_line = LockAt {
path: "pnpm-lock.yaml".into(),
base: copies(&[("xml-kit", "1.4.4-lts.1")]),
head: copies(&[("xml-kit", "1.4.4-lts.2")]),
why: String::new(),
};
let facts = resolve(&unit_lts, "h2", &[same_line]);
assert_eq!(facts.version_cell(0), "1.4.4-lts.1 to 1.4.4-lts.2");
assert_eq!(facts.fixed(&unit_lts, &f_lts), Fixed::Yes);
// The suffixed build is not mistaken for the plain release.
let not_yet = LockAt {
path: "pnpm-lock.yaml".into(),
base: copies(&[("xml-kit", "1.4.4-lts.1")]),
head: copies(&[("xml-kit", "1.4.4-lts.1")]),
why: String::new(),
};
let facts = resolve(&unit_lts, "h1", &[not_yet]);
assert_eq!(facts.version_cell(0), "1.4.4-lts.1, not moved on the head");
assert_eq!(facts.fixed(&unit_lts, &f_lts), Fixed::No);
}

/// The lockfiles as the package managers write them, with an override
/// keyed on the exact suffixed version.
#[test]
fn an_exact_version_override_is_read_from_real_lockfile_text() {
use crate::reachability::lock_copies;
let pnpm = |v: &str| {
format!(
"lockfileVersion: '9.0'\noverrides:\n xml-kit@1.4.4-lts.1: 2.0.3\nimporters:\n .:\n dependencies:\n feed-reader:\n specifier: ^3.0.0\n version: 3.1.0\npackages:\n feed-reader@3.1.0: {{}}\n xml-kit@{v}: {{}}\nsnapshots:\n feed-reader@3.1.0:\n dependencies:\n xml-kit: {v}\n xml-kit@{v}: {{}}\n"
)
};
let npm = |v: &str| {
format!(
r#"{{"lockfileVersion":3,"packages":{{"":{{"dependencies":{{"feed-reader":"^3.0.0"}},"overrides":{{"xml-kit@1.4.4-lts.1":"2.0.3"}}}},"node_modules/feed-reader":{{"version":"3.1.0","dependencies":{{"xml-kit":"1.4.4-lts.1"}}}},"node_modules/xml-kit":{{"version":"{v}"}}}}}}"#
)
};
let yarn = |v: &str| {
format!(
"# yarn lockfile v1\n\nfeed-reader@^3.0.0:\n version \"3.1.0\"\n dependencies:\n xml-kit \"1.4.4-lts.1\"\n\nxml-kit@1.4.4-lts.1:\n version \"{v}\"\n"
)
};
for (path, lock) in [
("pnpm-lock.yaml", &pnpm as &dyn Fn(&str) -> String),
("package-lock.json", &npm),
("yarn.lock", &yarn),
] {
let mut b = bump("xml-kit", "1.4.4-lts.1", "2.0.3");
b.manifest = path.into();
let unit = FixUnit {
bumps: vec![b],
..Default::default()
};
let at = LockAt {
path: path.into(),
base: lock_copies(path, &lock("1.4.4-lts.1")),
head: lock_copies(path, &lock("2.0.3")),
why: String::new(),
};
assert!(
at.base
.as_ref()
.unwrap()
.contains(&("xml-kit".into(), "1.4.4-lts.1".into())),
"{path}: {:?}",
at.base
);
let facts = resolve(&unit, "h2", &[at]);
assert_eq!(
facts.version_cell(0),
"1.4.4-lts.1 to 2.0.3 (major)",
"{path}"
);
}
}

/// The manifest got its override on one head; the lockfile was written
/// on a later one. The first head's answer is right for that head and
/// wrong for the next, so it is never carried over.
#[test]
fn a_package_an_override_moves_on_a_later_head_is_read_again() {
let unit = FixUnit {
bumps: vec![bump("xml-kit", "1.4.4-lts.1", "2.0.3")],
..Default::default()
};
let f = finding("GHSA-s", "xml-kit", "1.4.4-lts.1", Some("2.0.3"));
let st = FindingState::default();
let at = |head: &str| LockAt {
path: "pnpm-lock.yaml".into(),
base: copies(&[("xml-kit", "1.4.4-lts.1")]),
head: copies(&[("xml-kit", head)]),
why: String::new(),
};
let first = resolve(&unit, "h1", &[at("1.4.4-lts.1")]);
assert_eq!(first.version_cell(0), "1.4.4-lts.1, not moved on the head");
assert!(first
.headline(&unit, &[(&f, &st)])
.contains("Not fixed on the head: GHSA-s"));
let second = resolve(&unit, "h2", &[at("2.0.3")]);
assert_eq!(second.version_cell(0), "1.4.4-lts.1 to 2.0.3 (major)");
let h = second.headline(&unit, &[(&f, &st)]);
assert!(h.starts_with("Fixes 1 of 1 advisory"), "{h}");
assert!(!h.contains("Not fixed"), "{h}");
assert_ne!(first, second);
}
}
Loading
Loading