Repository navigation
fix(elixir): skip entries with no usable version range - #2541
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 advisory with no patched or unaffected versions listed produced a HexVersionRange with no constraints, which serializes as 'vers:hex/'. VersionRange.from_string rejects that string, so the affected package was dropped on round-trip. Skip the entry instead, mirroring the gentoo/apache_httpd fix for aboutcode-org#2387. Signed-off-by: Sanchit <[email protected]>
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.
Fixes #2540.
Problem
An Elixir Security advisory that lists no
unaffected_versionsand nopatched_versions— a disclosed vulnerability with no patched version yet — produces anAffectedPackageV2whose version range serializes as'vers:hex/'.VersionRange.from_stringrejects that string, so the importer logsCannot create AffectedPackage with invalid or unknown rangeand the package is dropped on round-trip.Evidence
Reproduced on current main with a minimal advisory YAML (valid CVE + package, no version lists):
process_fileyields the advisory withaffected_version_range == 'vers:hex/', and the package disappears after anAdvisoryDataV2.from_dictround-trip.Fix
Build the range only when constraints are non-empty; when there is no usable range, log and skip the package entry, mirroring the Gentoo fix in #2521 and the apache_httpd fix in #2392 for the same defect family (#2387). The advisory itself is still recorded (with an empty
affected_packageslist).Tests
vulnerabilities/tests/pipelines/v2_importers/test_elixir_security_importer_v2.py: 5 passed (3 existing + 2 new).test_collect_advisories_skips_empty_version_range: no version lists → advisory collected,affected_packages == [], novers:hex/string anywhere in the advisory dict. Fails on unmodified main.test_collect_advisories_keeps_one_sided_versions: onlypatched_versionspresent → range still built, 1 affected package (guard against over-skipping).black --checkclean on both changed files.Note for reviewers
The package is not recorded as affected for that advisory. A deeper fix in
AffectedPackageV2.from_dict(tolerate aNonerange instead of dropping the package) is a behaviour change beyond the importer — flagging for maintainer decision, not bundling it here.