Skip to content

CI that stays green: diff-aware PR scans (--changed-since) and a findings baseline (--baseline) #109

Done

Description

@vsn411

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:

  1. --changed-since <ref> and --changed-files <path>. secfoo run --changed-since origin/main computes the changed paths with git 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 tagged scope: context so the gate can ignore them (--fail-on high --fail-scope changed). --changed-files takes 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 passes github.event.pull_request.base.sha automatically on pull_request events (changed-only: true input); the GitLab example uses CI_MERGE_REQUEST_DIFF_BASE_SHA.
  2. Baseline file. secfoo findings baseline write .secfoo/baseline.json records the fingerprint, skill, severity and title of every open finding (optionally --reason and --expires YYYY-MM-DD applied to all, editable afterwards). secfoo run --baseline .secfoo/baseline.json excludes matching fingerprints from the --fail-on count. Expired entries count again and are listed in the run output. Baselined findings are still stored and exported: SARIF gets baselineState: "unchanged" (new ones "new"), JSONL gets baseline: {reason, expires}, and the dashboard marks them "accepted in baseline" rather than hiding them. secfoo findings baseline check reports entries whose finding is now closed, so the file can be pruned.
  3. 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.
  4. Action and examples: changed-only and baseline inputs on action.yml; the GitLab and manual GitHub examples updated; docs/CI.md gains "Adopting secfoo in an existing repo" (write the baseline on the first run, tighten --fail-on later).

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

  1. added
    enhancement
    help wanted
    hackathon
    difficulty: hard
    on Nov 15, 2026
  2. SriRamkunamsetty commented on Nov 29, 2026

    @SriRamkunamsetty
    Contributor

    I'd like to take this

  3. added a commit that references this issue on Nov 29, 2026
    64ff2da
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty: hardenhancementhackathonhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions