fix(supply-chain): treat only == / <= as version pins in requirements.txt (#294)#302
Open
Mark2Mac wants to merge 1 commit into
Open
fix(supply-chain): treat only == / <= as version pins in requirements.txt (#294)#302Mark2Mac wants to merge 1 commit into
Mark2Mac wants to merge 1 commit into
Conversation
….txt
`_extract_packages_from_requirements` kept the captured version for any operator,
so a floor like `pillow>=10.0.0` was recorded as the exact release `10.0.0` and
the OSV/CVE lookup attributed that version's vulnerabilities to an unpinned
dependency — a false CRITICAL on a requirements file that pins nothing.
Only `==` and `<=` bound the dependency to a concrete, CVE-checkable release;
`>=`, `>`, `!=`, `~=` are floors/ranges. This mirrors the guard already present
in `_extract_packages_from_setup_py` (`m.group(2) in ("==", "<=")`), so the two
extractors now agree.
Added a regression test asserting `>=`, `~=`, `!=` and bare names yield
version=None while `==` / `<=` keep the version.
Fixes NVIDIA#294
Signed-off-by: Mark2Mac <Mark2Mac@users.noreply.github.com>
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.
What
_extract_packages_from_requirementsrecorded the captured version for any operator, so a floor likepillow>=10.0.0was stored as the exact release10.0.0. The OSV/CVE lookup then attributed that release's vulnerabilities to a dependency that pins nothing — a false CRITICAL supply-chain finding.Only
==and<=bind a dependency to a concrete, CVE-checkable release.>=,>,!=,~=are floors/ranges. The fix applies the same guard already used by_extract_packages_from_setup_py(m.group(2) in ("==", "<=")), so the two extractors agree.Reproduction (before)
Test
Added
test_extract_packages_requirements_specifier_is_not_a_pin: asserts==/<=keep the version while>=,~=,!=and bare names yieldNone. Verified red before the fix (pillowcame back'10.0.0'), green after. Full existing suite for the analyzer stays green (320 passed).Fixes #294