Repository navigation
Fix unreachable and ineffective --from-json input validation - #5353
Open
0Cymantek0 wants to merge 1 commit into
Open
0Cymantek0 wants to merge 1 commit into
0Cymantek0 wants to merge 1 commit into
Conversation
The checks never ran: options.get("--from-json") always returned False
because click keys ctx.params with the option name "from_json", and the
extension and header checks were dead code after a raise inside a
"not is_file()" condition. Inputs are now validated upfront as readable
.json files starting with "{", reading the header in binary mode so
binary content fails cleanly instead of raising UnicodeDecodeError.
Reference: aboutcode-org#5351
Signed-off-by: Shuvagata Dey <cymantekfnosz@gmail.com>
This branch has not been deployed
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.
Fixes #5351
In validate_input_path() the --from-json checks never ran: options.get("--from-json") always returned False because click keys ctx.params with the option name "from_json", and the extension and header checks were dead code after an unconditional raise inside a "not is_file()" condition. Bad inputs were only caught late at codebase loading, with the raw file content dumped in the error (e.g. the full PNG bytes for png.png).
Changes:
Validation:
Tasks
Run tests locally to check for errors.