Skip to content

fix(elixir): skip entries with no usable version range - #2541

Open
sanchit955 wants to merge 1 commit into
aboutcode-org:mainfrom
sanchit955:fix/elixir-empty-version-range
Open

sanchit955 wants to merge 1 commit into
aboutcode-org:mainfrom
sanchit955:fix/elixir-empty-version-range

Conversation

@sanchit955

Copy link
Copy Markdown

Fixes #2540.

Problem

An Elixir Security advisory that lists no unaffected_versions and no patched_versions — a disclosed vulnerability with no patched version yet — produces an AffectedPackageV2 whose version range serializes as 'vers:hex/'. VersionRange.from_string rejects that string, so the importer logs Cannot create AffectedPackage with invalid or unknown range and the package is dropped on round-trip.

Evidence

Reproduced on current main with a minimal advisory YAML (valid CVE + package, no version lists): process_file yields the advisory with affected_version_range == 'vers:hex/', and the package disappears after an AdvisoryDataV2.from_dict round-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_packages list).

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 == [], no vers:hex/ string anywhere in the advisory dict. Fails on unmodified main.
  • test_collect_advisories_keeps_one_sided_versions: only patched_versions present → range still built, 1 affected package (guard against over-skipping).

black --check clean 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 a None range instead of dropping the package) is a behaviour change beyond the importer — flagging for maintainer decision, not bundling it here.

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Elixir Security importer drops affected packages when an advisory lists no patched or unaffected versions

1 participant