fix: reject null bytes in capec_map_enricher CLI arguments - #3503
Closed
HarshRajSinghania wants to merge 1 commit into
Closed
HarshRajSinghania wants to merge 1 commit into
HarshRajSinghania wants to merge 1 commit into
Conversation
Collaborator
|
@HarshRajSinghania thank you for your contribution. Remember that you have to ask to be assigned before starting work on an issue. Otherwise, thank you!. There is a complexity issue raised in the script. See: ./scripts/capec_map_enricher.py:274:1: C901 'main' is too complex (13) |
Collaborator
|
Please be aware of the contributor guidelines: https://github.com/OWASP/cornucopia/blob/master/CONTRIBUTING.md I will close this pull-request, but feel free to open a new pull-request in the correct way. |
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.
Summary
Reject null bytes in
scripts/capec_map_enricher.pyCLI path and string arguments so the tool logs a clear error and exits instead of crashing with an unhandledValueErrorfrompathlib/pathvalidate.Motivation
Fixes #3502. Maintainer requested validation wrappers around filepath and string arguments after fuzzed inputs with embedded null bytes caused an unhandled crash.
Implementation
validate_filepath_no_nulls()for--capec-json,--input-path,--source-dir, and--output-path._validate_no_null_bytes()for--versionand--edition.argparse.ArgumentTypeErrorinparse_arguments()and exit with code 1 after logging.main()for the same fields.Testing
python3 -m astparse of both changed files succeeds.tests/scripts/capec_map_enricher_utest.pyfor path/version null bytes and the two validators.pathvalidateis not installed locally. CI on this PR should runtests/scripts/capec_map_enricher_utest.py.