Skip to content

Include -state and -diff in output-file clash check - #428

Merged
TMHSDigital merged 1 commit into
TMHSDigital:mainfrom
bfs2021:fix/state-output-clash
Nov 17, 2026
Merged

TMHSDigital merged 1 commit into
TMHSDigital:mainfrom
bfs2021:fix/state-output-clash

Conversation

@bfs2021

@bfs2021 bfs2021 commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Problem

checkOutputFiles (#378) refused two outputs naming the same file, but it never included -state. A stopped run reports "Saved resume state to X", then -stats X or -o X overwrites that file, so -resume X can no longer continue the scan. -diff was likewise not compared with the other non--o reports. Fixes #395.

Root cause

The list of named outputs in checkOutputFiles contained only -inconclusive, -stats and -sarif. f.stateFile and f.diff were absent, so a clash with either was never detected at startup. In session.go, saveResumeState writes f.stateFile first and -stats/-o are written afterwards, silently replacing it.

Fix

Added {"-state", f.stateFile} and {"-diff", f.diff} to the compared outputs. -state is compared with every output so the resume file can never be clobbered. -diff is compared with the other non--o reports, while -o X -diff X remains legal (#297). Updated the function comment to reflect the broader contract.

Testing

Extended TestOutputFilesSameFile in internal/cli/wordlist_test.go with four cases: -state vs -o, -stats and -diff, plus -diff vs -stats. All four fail on the unmodified code (exit 0 or a file-read error instead of the "name the same file" usage error) and pass with the fix. go test ./internal/cli/ -count=1 passes in full.

checkOutputFiles skipped -state, so -stats or -o could overwrite the resume state after it was saved and reported. Compare -state with every output and -diff with the other non--o reports, keeping -o X -diff X legal (TMHSDigital#395).
@TMHSDigital
TMHSDigital merged commit 42f349a into TMHSDigital:main Nov 17, 2026
17 checks passed
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.

-state is not in the output-file clash check; -stats or -o can overwrite saved state

2 participants