Repository navigation
Include -state and -diff in output-file clash check - #428
Merged
Merged
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 Xor-o Xoverwrites that file, so-resume Xcan no longer continue the scan.-diffwas likewise not compared with the other non--oreports. Fixes #395.Root cause
The list of named outputs in
checkOutputFilescontained only-inconclusive,-statsand-sarif.f.stateFileandf.diffwere absent, so a clash with either was never detected at startup. Insession.go,saveResumeStatewritesf.stateFilefirst and-stats/-oare written afterwards, silently replacing it.Fix
Added
{"-state", f.stateFile}and{"-diff", f.diff}to the compared outputs.-stateis compared with every output so the resume file can never be clobbered.-diffis compared with the other non--oreports, while-o X -diff Xremains legal (#297). Updated the function comment to reflect the broader contract.Testing
Extended
TestOutputFilesSameFileininternal/cli/wordlist_test.gowith four cases:-statevs-o,-statsand-diff, plus-diffvs-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=1passes in full.