requirements.txt: unpinned and compound requirements are dropped before transitive resolution
Version: osv-scanner v2.7.0
Repro
requirements.txt:
flask==2.0.1
requests
werkzeug>=2.0,<3
osv-scanner scan source --all-packages --data-source=native --format json .
Expected: requests and werkzeug are resolved, and werkzeug<3 constrains the graph.
Actual: both are reported with an empty version and dropped ("Filtered 2 local/unscannable package/s"). Nothing is resolved for them, and flask pulls in werkzeug 3.1.9, violating <3.
Likely cause: packages with an empty version are filtered out before the transitive requirements enricher runs, so it never sees these requirements.
I reproduced this on current main and traced the root cause: scalibr's requirements extractor intentionally emits unpinned and compound requirements with an empty version, carrying the constraint in metadata for the transitive enricher. But osv-scanner's own filter annotator runs in the annotator phase, before any enricher, and drops those empty-version packages as unscannable — so the enricher only ever sees the pinned packages and resolves the dropped ones unconstrained (in the report's example, flask pulls in werkzeug 3.1.9 despite the <3 constraint).
I have a fix ready locally with regression tests: the filter no longer drops a versionless package when an enabled transitive enricher is responsible for resolving it, while config-ignored packages are still filtered and --no-resolve behaviour is unchanged. With the fix, requests resolves with its full tree and werkzeug resolves to a version satisfying <3.
Could I be assigned to this issue so I can open the PR?
One design point worth flagging: when transitive resolution fails (e.g. no network), the kept packages surface with empty versions under --all-packages instead of being dropped, alongside the resolution error. That matches how they were presented before, but happy to adjust if you prefer different handling.
The same root cause also affects Maven, and there it can hide every vulnerability in a project.
pom.xml dependencies that inherit their version from the parent (the usual Spring Boot setup) are extracted with an empty version and filtered before transitivedependency/pomxml runs. The enricher only resolves files that still have packages in the inventory, so a pom.xml where every dependency is versionless is never resolved at all:
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.0</version>
</parent>
<groupId>x</groupId>
<artifactId>y</artifactId>
<version>1</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
$ docker run --rm -v "$PWD:/src" ghcr.io/google/osv-scanner:v2.7.1 scan source /src
...
Scanned /src/pom.xml file and found 1 package
...
Filtered 1 local/unscannable package/s from the scan.
No issues found
The exit code is 0. Adding one dependency with an explicit version (e.g. org.webjars:webjars-locator-lite:1.1.3) is enough for the enricher to pick up the file, and the same project then reports vulnerabilities in spring-webmvc 6.0.2, snakeyaml 1.33 and others.
Versions tested: v2.4.0 runs the pomxml enricher on this file (it prints the "may be risky" warning and fetches the parent POM), while on v2.5.0 and v2.7.1 the enricher gets no packages for the file (no warning, no parent POM fetch error). That lines up with #2935, released in v2.5.0, which moved the unscannable filter into an annotator, and annotators run before enrichers.
If the fix proposed above applies to transitive enrichers in general, it should cover this case too. A pom.xml regression test where all dependencies inherit their version would be worth adding.