Repository navigation
fix(gentoo): skip entries with no usable version range - #2521
Open
sanchit955 wants to merge 1 commit into
Open
sanchit955 wants to merge 1 commit into
sanchit955 wants to merge 1 commit into
Conversation
An unparsable GLSA version produced an EbuildVersionRange with no constraints, which serializes as 'vers:ebuild/'. VersionRange.from_string rejects that string, so the affected package was dropped on round-trip. Skip the entry instead, mirroring the apache_httpd fix for aboutcode-org#2387. Also guard missing version text: an empty version element previously raised an uncaught AttributeError from GentooVersion(None) and killed the run. Signed-off-by: Sanchit <dev.sanchit955@gmail.com>
This branch has not been deployed
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.
Problem
The gentoo importer builds a version range from whatever constraints it parsed, even when that list is empty. An unparsable GLSA version (e.g.
1.0*) producesEbuildVersionRange(constraints=[]), which serializes asvers:ebuild/.VersionRange.from_stringrejects that string, so the affected package is dropped (toNone) on everyAdvisoryDataV2.from_dictround-trip — the exact error reported in #2387.The apache_httpd half of #2387 was fixed the same way in #2392; the gentoo half was never fixed.
A second, related defect in the same path: an empty version element (
<vulnerable range="lt"/>) passesNoneintoGentooVersion, raising an uncaughtAttributeErrorthat kills the whole gentoo import run instead of skipping one entry.Fix
process_file: build the range only when constraints are non-empty; when there is no usable range, log and skip the entry — mirroring the apache_httpd fix for Invalid version range inapache_httpdandgentooadvisory #2387.build_constraints: skip (and log) constraint pairs with a missing version before parsing, so an empty element can no longer crash the run.Trade-off
Skipping the entry means the package is not recorded as affected for that GLSA entry — the same trade-off #2392 made for apache_httpd. A deeper fix in
AffectedPackageV2.from_dict(tolerate aNonerange instead of dropping the package) would be a behaviour change beyond the importer; flagging it here for maintainer decision rather than bundling it.Tests
vulnerabilities/tests/pipelines/v2_importers/test_gentoo_importer_v2.py: 5 passed (3 existing + 2 new).test_gentoo_invalid_version_does_not_build_empty_range: invalid version → entry skipped, unaffected entry kept.test_gentoo_empty_version_element_does_not_crash: empty<vulnerable/>element → no crash, entry skipped.black --checkclean on both changed files.Fixes the gentoo half of #2387.