Skip to content

feat(ci): diff-scoped PR scans and findings baseline (#109) - #215

Closed
Falguni-105 wants to merge 1 commit into
secfoo-com:mainfrom
Falguni-105:feature/issue-109-diff-baseline
Closed

Falguni-105 wants to merge 1 commit into
secfoo-com:mainfrom
Falguni-105:feature/issue-109-diff-baseline

Conversation

@Falguni-105

Copy link
Copy Markdown

Fixes #109

Summary

  • Diff-scoped PR scans: --changed-since <ref> uses git's merge base (with rename detection contributing both old and new paths), and --changed-files <paths> accepts a CI-supplied newline-separated list. Bad refs and non-git targets fail before any agent starts. The brief names changed files and asks for Scope: changed|context markers; findings in unchanged files stay open and exported but are tagged scope: context.
  • Focused CI gates: --fail-scope changed excludes context findings from --fail-on without hiding them. Stale-finding closure is limited to the scanned paths, so a diff run never closes findings it did not look at.
  • Findings baseline: secfoo findings baseline write|check maintains a small, editable JSON file keyed by fingerprint. secfoo run --baseline <file> excludes active entries from the gate, re-counts expired ones with a clear notice, and findings export --baseline annotates every finding with SARIF baselineState and JSONL baseline: {reason, expires} instead of dropping it. The SAST dashboard shows an Accepted in baseline badge.
  • CI wiring: action.yml gains changed-only and baseline inputs (automatic github.event.pull_request.base.sha wiring), with full-history checkout/fetch and diff/baseline examples in GitHub Actions and GitLab CI.
  • Docs: docs/CI.md adoption workflow and input table; docs/REFERENCE.md flags, baseline commands, export annotations, fingerprint/diff notes, and dashboard badge note.

Tests

  • New: tests/test_diff_scope.py, tests/test_baseline.py, tests/test_cli_diff_baseline.py, tests/test_runner_diff_scope.py (merge base, renames, bad refs, missing targets, brief text, scope tags, expiry, export annotations, out-of-scope findings staying open, baseline dashboard marker).
  • pytest targeted: 53 passed. CLI/memory: 85 passed. Report/storage: 319 passed (2 pre-existing SARIF as_uri() DeprecationWarnings). Docs/skills/lint config: 83 passed. YAML parse check passed for action.yml and examples/ci/*.yml.
  • The web suite has 4 pre-existing failures about architecture Mermaid diagrams; reproduced on clean HEAD d90d3f0, unrelated to this change.

Notes

@Falguni-105
Falguni-105 requested a review from vsn411 as a code owner November 29, 2026 07:40
@Falguni-105

Copy link
Copy Markdown
Author

@vsn411 Could you review and merge when you have a chance? Note that PR #211 also addresses #109; this is an alternative implementation with extra rename/expiry/export/dashboard coverage. PR #207 (issue #116) is also still awaiting merge.

@Shruti070107
Shruti070107 force-pushed the feature/issue-109-diff-baseline branch from 19a9f6f to fa82be1 Compare November 29, 2026 07:53
@Shruti070107

Copy link
Copy Markdown
Contributor

Update: rebased onto the latest upstream main and resolved the conflict; this PR is now MERGEABLE. Branch protection still blocks a direct merge and I don't have upstream write/auto-merge permissions, so a maintainer will need to approve and merge.

@vsn411

vsn411 commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

Thank you for this, and welcome! It's a careful implementation: --end-of-options on the diff call, explicit rename parsing that keeps both paths, and directory-prefix matching are all good details.

We're closing it only because #211 implements the same issue (#109). #211 was claimed on the issue first, and we've just finished reviewing and merging it, so the two can't both land. One fix we made to #211 applies to yours too, in case it's useful elsewhere: a finding's file path, not the model's Scope: tag, decides whether it counts as changed. The tag is model output and could be steered by text in the scanned PR.

If you'd like to bring over any of your extras as a small follow-up on top of main, we'd welcome it. The rename handling and directory-prefix matching would be good candidates. #207 (opencode) is also still open and close to done. Thanks again, and we hope to see more from you.

@vsn411 vsn411 closed this Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants