Repository navigation
fix(elixir): skip entries with no usable version range - #2541
sanchit955 wants to merge 2 commits 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 <dev.sanchit955@gmail.com>
Jean-Regis-M
left a comment
There was a problem hiding this comment.
I ran a YAML with no patched_versions and no unaffected_versions on main (9a9c9b3) and on this branch:
| after import | after to_dict / from_dict |
|
|---|---|---|
main |
plug, vers:hex/ |
[None] |
| this PR | no affected package | no affected package |
So the crash-prone None is gone, but plug is now never recorded as affected. A disclosed bug with no fix is when users most need that link.
If "no version lists" means every version is affected, could the importer keep the package with vers:hex/*? I checked that part: it survives the same round trip and contains 1.0.0. I haven't taken it through the improvers or a full import. If the meaning is unknown, skipping is fair, and I'd say so in the log message.
On Windows, test_collect_advisories fails on both branches (it expects / in the advisory ID). The other tests in that file pass, including your two.
Side note: the source repo, dependabot/elixir-security-advisories, is archived. I raised that in #2550.
An advisory with no patched or unaffected versions means no fix is known and no version is known unaffected, so every version is affected. Use the wildcard range instead of dropping the package. Signed-off-by: Sanchit <dev.sanchit955@gmail.com>
94429d8 to
5b99f10
Compare
|
Good catch — you're right that skipping loses the link exactly when it matters most. I checked the advisory format: with no Changed the importer to keep the package with On the Windows failure: confirmed it's pre-existing — |
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.