Add --ignore-dirty-worktree to reuse recent scans of dirty worktrees - #159
Conversation
Pipelines can look clean to git status and still be marked dirty (skip-worktree, assume-unchanged), which blocked reuse. The flag only relaxes --skip-if-commit-scanned-recently; new scans still report the real dirty status. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Automated review risk: 4/5.
The override can reuse legacy scans whose scope is unknown, potentially treating a partial scan as a complete commit scan and missing findings.
Critical or high-priority changes must be addressed.
Automatic approval was not submitted: checks failed: Build and Upload Native Binaries (windows-latest, x86_64-pc-windows-msvc, corgea.exe), windows (windows-latest, x64).
None is not known dirtiness: older CLIs and partial --target/--exclude uploads omit the flag, and reusing those as a whole-commit scan can miss findings. Co-authored-by: Cursor <cursoragent@cursor.com>
| match scan.worktree_dirty { | ||
| Some(false) => {} | ||
| Some(true) if ignore_dirty_worktree => {} | ||
| Some(true) => { |
There was a problem hiding this comment.
high: Dirty prior scans cannot safely represent the commit
Accepting worktree_dirty == Some(true) means the scan's uploaded source may differ arbitrarily from its recorded SHA. For example, a prior dirty worktree can delete a vulnerable file from commit C and produce clean results; a later invocation for C then reuses those results and allows --block-on to exit successfully without ever analyzing the vulnerable committed file. The dirty flag provides no proof that the differences were harmless. Keep prior candidates restricted to Some(false); ignoring the current worktree's dirtiness is a separate explicit decision.
Proof or reproduction:
let mut prior = scan("prior", "complete", Some(SHA), "2026-01-01T23:00:00Z");
prior.worktree_dirty = Some(true);
// The prior upload may omit vulnerable content present in SHA.
assert!(select_reusable_scan(&[prior], SHA, now(), DAY, true).is_none());
There was a problem hiding this comment.
This is expectected
There was a problem hiding this comment.
Automated review risk: 4/5.
The override can reuse results from arbitrary uncommitted content, making security gates report false success for the requested commit.
Critical or high-priority changes must be addressed.
Automatic approval was not submitted: automated review found critical or high-priority findings.
Summary
--ignore-dirty-worktree, which can only be used with--skip-if-commit-scanned-recently.worktree_dirty.Test plan
corgea scan --ignore-dirty-worktreewithout--skip-if-commit-scanned-recentlyis rejected--ignore-dirty-worktreereuses a recent scan of the commitworktree_dirty=trueis reused when the flag is setdirty=trueand prints the uncommitted-changes noticecargo test --test cloud_commands_e2e ignore_dirtyMade with Cursor