-
Notifications
You must be signed in to change notification settings - Fork 273
fix(root): resolve version comparison crashes and PURL collisions #4575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
I'm not an authority on PURL, but adding
Inserting I've noticed that the OSV records from Root's REST API does not currently include the PURLs (were these silently removed recently? I thought I had seen them yesterday). OSV does not actually require PURLs. |
afa112b to
219e7c2
Compare
|
These PURLs would map to OSV's The best thing to do here would be to remove the PURL conversion code altogether. PURLs are not required in OSV.dev, and users will still be able to query the Root packages by their OSV ecosystem + names. We can always revisit adding PURLs later if the need arises and a clear mapping can be developed. |
219e7c2 to
69fc583
Compare
|
@michaelkedar done. |
|
Fixed lint. Other failures were related to urllib in unrelated files so I didnt change them |
83272da to
e59e383
Compare
These will be added in a separate PR after the code changes are merged.
Fixes three critical issues with Root.io data source integration:
1. **Version Comparison Crashes (TypeError)**
- Root versions mixed int and str types in comparison tuples
- Example: '22.12.0-2.root.io.1' vs '22.12.0-2+deb12u1.root.io.5'
- Solution: Reuse ecosystem-specific parsers (AlpineLinuxVersion,
DebianVersion, packaging_legacy, MavenVersion)
- Use suffix-based ecosystem detection (:Alpine:3.18 → Alpine)
- Explicit error handling with ValueError for invalid versions
- No fallback try/catch to let errors propagate properly
2. **PURL Collisions**
- All Root packages mapped to pkg:generic/root/ causing collisions
- Example: Both Root:Alpine:3.18/curl and Root:Debian:12/curl
generated identical pkg:generic/root/curl
- Solution: Add sub-ecosystem-specific PURL mappings:
* Root:Alpine → pkg:apk/root-alpine/
* Root:Debian → pkg:deb/root-debian/
* Root:Ubuntu → pkg:deb/root-ubuntu/
* Root:PyPI → pkg:pypi/root/
* Root:npm → pkg:npm/root/
* Root:Maven → pkg:maven/root/
- Parse hierarchical ecosystems (Root:Alpine:3.18 → Root:Alpine)
- Add arch=source suffix for distro packages
3. **Maven PURL Encoding**
- Fixed encoding to preserve '/' in Maven group/artifact separation
- Example: com.example:mylib → pkg:maven/root/com.example/mylib
Changes:
- osv/ecosystems/root.py: Complete redesign with ecosystem-based
version parser selection using match/case pattern
- osv/purl_helpers.py: Added Root sub-ecosystem mappings and
hierarchical ecosystem parsing
- osv/purl_helpers_test.py: Added collision prevention tests
- osv/ecosystems/root_test.py: Created 11 comprehensive unit tests
covering Alpine, Debian, PyPI, Maven, and npm ecosystems
Testing:
- All unit tests pass (11/11 in root_test.py)
- Validated against real Root.io API with 8144 vulnerabilities
- No PURL collisions detected across sub-ecosystems
- Version comparison works correctly for all ecosystems
Fixes google#4396
e59e383 to
5ea32fc
Compare
|
/gcbrun |
Fixes three critical issues with Root.io data source integration:
Version Comparison Crashes (TypeError)
DebianVersion, packaging_legacy, MavenVersion)
PURL Collisions
generated identical pkg:generic/root/curl
Maven PURL Encoding
Changes:
version parser selection using match/case pattern
hierarchical ecosystem parsing
covering Alpine, Debian, PyPI, Maven, and npm ecosystems
Testing:
Fixes #4396