Repository navigation
Validate the scanner argument before initializing the benchmark. - #354
Conversation
babenek
left a comment
There was a problem hiding this comment.
Good point!
please update
def get_arguments() -> Namespace:
to
def get_arguments(argv:list[str]) -> Namespace:
and parse incoming arguments
also in main
def main(argv) -> None:
args = get_arguments(argv[1:])
if __name__ == """__main__""":
sys.exit(main(sys.argv))
then avoid extra patching in tests
|
Thanks for the feedback! I've made the requested changes and verified that all 9 tests pass. |
There was a problem hiding this comment.
Mocking should be a last resort. Prefer real objects and test units directly by default, without invoking their parent functions just to reach them.
Function main() is easy byself.
Test only get_arguments() instead:
- test with unsupported scanner
- test with supported scanner (credsweeper ;)
no auxiliary methods required!
babenek
left a comment
There was a problem hiding this comment.
Code - OK
Test - rewrite
|
Thanks for the feedback! I've rewritten the tests to call |
babenek
left a comment
There was a problem hiding this comment.
LGTM. Thanks @deep-sengupta
Problem
main()previously constructedBenchmark()before checking whether the supplied scanner name was supported. This could trigger unnecessary dataset preparation for invalid input. The manual error branch also returned normally, resulting in a successful exit status for invalid scanner names.Additionally,
nargs="?"allowed--scannerto be supplied without a value.Changes
choices=SCANNER_LISTto the--scannerargument.nargs="?"so the scanner value is required.Benchmarkis not initialized.Testing
python -m benchmark -hdisplays the required scanner argument.No full benchmark run was performed because this change only affects argument validation.