Skip to content

fix(check): skip invalid specifiers from the vulnerability DB - #900

Open
Sanjays2402 wants to merge 1 commit into
pyupio:mainfrom
Sanjays2402:fix/invalid-specifier-check-path
Open

fix(check): skip invalid specifiers from the vulnerability DB#900
Sanjays2402 wants to merge 1 commit into
pyupio:mainfrom
Sanjays2402:fix/invalid-specifier-check-path

Conversation

@Sanjays2402

Copy link
Copy Markdown

Description

safety check aborts with Unhandled exception happened: Invalid specifier: '=1.7.0' when the vulnerability DB contains a malformed specifier (single =, invalid per PEP 440). check() in safety/safety.py built a SpecifierSet directly 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 scan path in #879/#880, which left this check call site unpatched.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor
  • Other (please describe):

Related Issues

Closes #882

Testing

  • Tests added or updated
  • No tests required

tests/test_safety.py::TestSafety::test_check_invalid_specifier_in_db feeds ["=1.7.0", "<1.0"] for a package. It fails on main with packaging.specifiers.InvalidSpecifier: Invalid specifier: '=1.7.0' and passes with this change, still reporting the vulnerability matched by the valid <1.0 specifier. Full tests/test_safety.py: 34 passed.

Checklist

  • Code is well-documented
  • Changelog is updated (if needed)
  • No sensitive information (e.g., keys, credentials) is included in the code
  • All PR feedback is addressed

Additional Notes

Only the check code path is touched here. Note that the underlying authlib DB entry itself should still be corrected upstream (=1.7.0 -> ==1.7.0); this change only stops a bad entry from crashing the client.

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
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 692987e1-95a4-4fec-bfc9-04a6f2c3bab7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

authlib vuln-db entry contains invalid specifier "=1.7.0"

1 participant