Skip to content

fix(supply-chain): handle ranges and unresolved dependencies safely - #340

Closed
keshprad wants to merge 3 commits into
mainfrom
keshavp/codex/combine-sc4-range-handling
Closed

fix(supply-chain): handle ranges and unresolved dependencies safely#340
keshprad wants to merge 3 commits into
mainfrom
keshavp/codex/combine-sc4-range-handling

Conversation

@keshprad

@keshprad keshprad commented Aug 4, 2026

Copy link
Copy Markdown
Member

Combines #302 and #319 so SC4 does not invent a pinned version for ranges or report historical package advisories as a verified vulnerability. Exact-version findings remain unchanged. Fixes #294 and #318. Tests: focused analyzer suite (247 passed); Ruff on changed files.

Mark2Mac added 2 commits July 30, 2026 23:11
Addresses the review on #302: the previous guard still admitted non-exact
constraints. `<=8.1.0` matches every earlier release and `==1.*` is a wildcard,
so both were handed to the vulnerability lookup as a version the dependency may
never install.

A vulnerability lookup answers "is THIS release affected?", which is only
meaningful when the manifest admits exactly one release. That predicate is now
explicit and shared instead of being re-derived at each call site:

- `_pinned_version` (PEP 440): only `==` with a fully concrete version. Floors,
  caps, exclusions, compatible releases and wildcard equality yield None.
- `_pinned_npm_version` (semver): only a bare `x.y.z`. npm defaults to caret
  ranges, so `"^1.8.3"` was being stripped into the concrete release `1.8.3`.

Applied to all three extractors — requirements.txt, pyproject.toml and
package.json — because the objection in the review holds verbatim for the two
that were not touched by the original patch.

Note for the maintainer: dropping these specifiers moves more dependencies to
version=None, which #318 shows is currently reported as CRITICAL carrying the
package's worst-ever advisory. The two fixes are complementary; happy to send
the severity side as a separate PR.

Regressions cover both cases named in the review (`<=` and `==1.*`) plus the
npm caret/tilde/wildcard/range forms.

Signed-off-by: Mark2Mac <Mark2Mac@users.noreply.github.com>
When a manifest admits a range, no version is resolved and OSV is queried by name
alone. The advisories that come back are the package's history, not a match against
the release that will be installed: the worst of them may predate every version the
range admits. Using that as the finding's severity turns 'setuptools>=61' into a
CRITICAL 'Known Vulnerable Dependency'.

Scanning 65 skill/plugin units, every SC4 finding in the corpus came from this or
from a range being read as a pin (#294/#302). Not one manifest pinned a vulnerable
release.

The lack of pinning is already reported by SC1, so what is left for SC4 to say is
'could not verify', and it must not outrank a real version match: severity capped at
LOW, confidence 0.4, and wording that states the limit instead of implying a match.
Version-matched findings are unchanged.

Closes #318

Signed-off-by: Mark2Mac <Mark2Mac@users.noreply.github.com>
@keshprad

keshprad commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

Blocking: valid exact PEP 440 pins are still truncated before _pinned_version() sees them, so OSV can be queried for a different or invalid release.

Reproduced on this branch:

pillow==10.0.0rc1    => 10.0.0
pillow==10.0.0.post1 => 10.0.0.
pillow==1!10.0       => 1

The requirements/pyproject regex only captures [\d.*]+, then the new helper treats that partial capture as a concrete pin. Please parse the complete specifier with a PEP 440-aware parser (or reject non-full matches) and add regressions for prerelease, post-release, and epoch versions before merging.

@keshprad
keshprad marked this pull request as ready for review August 4, 2026 03:01
Signed-off-by: keshprad <32313895+keshprad@users.noreply.github.com>
@keshprad
keshprad force-pushed the keshavp/codex/combine-sc4-range-handling branch from 2f99aba to 3c26dcb Compare August 4, 2026 03:06
@keshprad keshprad closed this Aug 4, 2026
@keshprad
keshprad deleted the keshavp/codex/combine-sc4-range-handling branch August 4, 2026 03:07
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.

[BUG] requirements.txt: any version specifier is treated as an exact pin (pillow>=10.0.0 reported as pillow==10.0.0 with its CVEs)

2 participants