fix(check): skip invalid specifiers from the vulnerability DB - #900
Open
Sanjays2402 wants to merge 1 commit into
Open
fix(check): skip invalid specifiers from the vulnerability DB#900Sanjays2402 wants to merge 1 commit into
Sanjays2402 wants to merge 1 commit into
Conversation
The `check` command built a SpecifierSet directly from each entry in db["vulnerable_packages"], so a malformed entry such as "=1.7.0" (single equals, invalid per PEP 440) raised InvalidSpecifier and aborted the whole run with "Unhandled exception happened: Invalid specifier: '=1.7.0'". Invalid specifiers are now logged and skipped, matching the guard already proposed for the scan code path. Remaining valid specifiers for the same package are still evaluated. Closes pyupio#882
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Description
safety checkaborts withUnhandled exception happened: Invalid specifier: '=1.7.0'when the vulnerability DB contains a malformed specifier (single=, invalid per PEP 440).check()insafety/safety.pybuilt aSpecifierSetdirectly from each DB entry with no guard, so one bad entry killed the whole run.Invalid specifiers are now logged and skipped; remaining valid specifiers for the same package are still evaluated. This mirrors the guard proposed for the
scanpath in #879/#880, which left thischeckcall site unpatched.Type of Change
Related Issues
Closes #882
Testing
tests/test_safety.py::TestSafety::test_check_invalid_specifier_in_dbfeeds["=1.7.0", "<1.0"]for a package. It fails onmainwithpackaging.specifiers.InvalidSpecifier: Invalid specifier: '=1.7.0'and passes with this change, still reporting the vulnerability matched by the valid<1.0specifier. Fulltests/test_safety.py: 34 passed.Checklist
Additional Notes
Only the
checkcode path is touched here. Note that the underlyingauthlibDB entry itself should still be corrected upstream (=1.7.0->==1.7.0); this change only stops a bad entry from crashing the client.