Repository navigation
Description
Problem: two things stop teams from leaving a scanner on in CI. First, every run reviews the whole repository, so a one-line PR costs the same minutes and dollars as a full audit. Second, the first run on an existing codebase finds dozens of issues, --fail-on high goes red on every PR, and the team turns it off. secfoo has neither a way to focus a run on what changed nor a way to acknowledge known findings without losing them.
Goal: a PR run reviews what the PR touched, and known findings are recorded once and stop failing the build while staying visible.
Build:
--changed-since <ref>and--changed-files <path>.secfoo run --changed-since origin/maincomputes the changed paths withgit diff --name-only --merge-base, and the brief tells the agent which files changed and asks it to review those paths and the code that calls them, with the rest of the repository as context. Findings in unchanged files are still allowed but taggedscope: contextso the gate can ignore them (--fail-on high --fail-scope changed).--changed-filestakes a newline-separated list for CI systems that already know the diff. Non-git targets and a ref that does not exist are errors before anything runs. The GitHub Action passesgithub.event.pull_request.base.shaautomatically onpull_requestevents (changed-only: trueinput); the GitLab example usesCI_MERGE_REQUEST_DIFF_BASE_SHA.- Baseline file.
secfoo findings baseline write .secfoo/baseline.jsonrecords the fingerprint, skill, severity and title of every open finding (optionally--reasonand--expires YYYY-MM-DDapplied to all, editable afterwards).secfoo run --baseline .secfoo/baseline.jsonexcludes matching fingerprints from the--fail-oncount. Expired entries count again and are listed in the run output. Baselined findings are still stored and exported: SARIF getsbaselineState: "unchanged"(new ones"new"), JSONL getsbaseline: {reason, expires}, and the dashboard marks them "accepted in baseline" rather than hiding them.secfoo findings baseline checkreports entries whose finding is now closed, so the file can be pruned. - Fingerprints that survive a diff scan. The SAST fingerprint uses path plus code-region hash (see
docs/REFERENCE.md, "SAST Open/Closed finding identity"); check that a diff-scoped run does not close findings it simply did not look at. Findings outside the scanned scope must keep their state. - Action and examples:
changed-onlyandbaselineinputs onaction.yml; the GitLab and manual GitHub examples updated;docs/CI.mdgains "Adopting secfoo in an existing repo" (write the baseline on the first run, tighten--fail-onlater).
Where to look: src/secfoo/cli.py (run, _findings_at_or_above, the findings group), src/secfoo/runner.py (execute_runs, how the brief and target are assembled), src/secfoo/targets/, src/secfoo/skills/ (prompt rendering), src/secfoo/storage/repository.py (open/closed lifecycle, list_structured_findings), src/secfoo/report/sarif.py, action.yml, docs/CI.md, docs/REFERENCE.md.
Relation: builds on #106; #46 (SARIF) and #80 (runtime gate) show how gates and exports are tested. The sticky PR comment from the action self-test issue should show "new vs baseline" once both land.
Done when: tests cover the changed-paths computation (merge-base, renames, a missing ref), the brief text naming the changed files, the scope tag and --fail-scope, baseline write/apply/expiry/check, baselineState in SARIF, and that a diff-scoped run leaves out-of-scope findings open; a real PR run on a sample repo shows the cost and time drop; docs updated.
Activity
SriRamkunamsetty commentedon Nov 29, 2026
I'd like to take this
feat: diff-scoped PR scans and findings baseline (secfoo-com#109)
feat(ci): diff-aware PR scans (--changed-since/--changed-files) and f…