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
4 changes: 4 additions & 0 deletions fasttrack/incident.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ def series_stack(out: Path, series: str, head: str, own: str) -> list[str]:
"""The patch set a new backport goes on top of: patches/<series>/ from the last
run, then cve/ backports made since, oldest first. ``own`` (<ID>/<series>) is left
out, and so is a superseded set: one whose fix is a clean pick in patches/<series>/.
A set made on another stable head is left out too: build-test does not stack it.
Empty when patches/<series>/ was verified on another stable head."""
d = out / "patches" / series
if not (d / "base").exists() or (d / "base").read_text().strip() != head:
Expand All @@ -288,6 +289,9 @@ def series_stack(out: Path, series: str, head: str, own: str) -> list[str]:
for meta_file in out.glob(f"cve/*/{series}/fasttrack.json"):
meta, cdir = json.loads(meta_file.read_text()), meta_file.parent
name = f"{cdir.parent.name}/{series}"
base = cdir / "base"
if base.exists() and base.read_text().strip() != head:
continue
# Superseded: a clean pick carries its fix, so run leaves the whole set out.
if any(p.get("upstream") in picks for p in meta.get("patches", [])):
continue
Expand Down
18 changes: 16 additions & 2 deletions tests/test_fasttrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,13 +596,27 @@ def test_stack_leaves_out_superseded_set(self):
cands.append(engine.Candidate("6.18", upstream, "backport", "claude", ["CVE-2026-0001"],
filename=f"000{i}-{upstream[:12]}-backport.patch",
patch=sh(wt, "git", "format-patch", "-1", "--stdout")))
emit.write_patch_dir(self.out / "cve" / "CVE-2026-0001" / "6.18", "6.18", "h", "6.18.2", cands,
{"made": "2026-11-01T00:00:00Z"})
head = (self.out / "patches" / "6.18" / "base").read_text().strip()
emit.write_patch_dir(self.out / "cve" / "CVE-2026-0001" / "6.18", "6.18", head, "6.18.2", cands,
{"made": "2026-11-01T00:00:00Z"})
stack = incident.series_stack(self.out, "6.18", head, "CVE-2026-0003/6.18")
self.assertEqual(len(stack), 2) # D and A from patches/
self.assertFalse(any("cve/CVE-2026-0001/6.18" in t for t in stack))

def test_stack_leaves_out_set_on_other_head(self):
# A cve/ set that does not apply on the new stable head stays out of patches/.
# build-test does not stack it, so a new backport must not be made on it.
cli.main(["--config", str(self.cfg), "run"])
head = (self.out / "patches" / "6.18" / "base").read_text().strip()
for cve, base in (("CVE-2026-0008", "0" * 40), ("CVE-2026-0009", head)):
cand = engine.Candidate("6.18", "e" * 40, "backport", "claude", [cve],
filename=f"0001-{cve}.patch", patch=f"{cve} patch\n")
emit.write_patch_dir(self.out / "cve" / cve / "6.18", "6.18", base, "6.18.2", [cand],
{"made": "2026-11-01T00:00:00Z"})
stack = "".join(incident.series_stack(self.out, "6.18", head, "CVE-2026-0003/6.18"))
self.assertNotIn("CVE-2026-0008 patch", stack)
self.assertIn("CVE-2026-0009 patch", stack)

def test_unpatched_round_trip(self):
cli.main(["--config", str(self.cfg), "run"])
rc = cli.main(["--config", str(self.cfg), "cve", "--unpatched", "--adapt"])
Expand Down