Repository navigation
Fix UnboundLocalError in curl importer for non-SEMVER version ranges - #2214
Open
xovishnukosuri wants to merge 1 commit into
Open
xovishnukosuri wants to merge 1 commit into
xovishnukosuri wants to merge 1 commit into
Conversation
parse_curl_advisory only assigned fixed_version_range inside an if block
but referenced it unconditionally, causing UnboundLocalError for advisories
that have only a GIT range or no fixed version. Initialize it to None
before the conditional. Also change the empty fallbacks for affected and
ranges from [] to {} so .get() calls later do not raise AttributeError.
Adds two new tests covering GIT-only ranges and the CURL-CVE-* id format.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced Nov 28, 2026
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 #1166
Summary
parse_curl_advisoryconditionally assignedfixed_version_rangeinsideif version_type == "SEMVER" and fixed_version:but then passed it toAffectedPackageV2unconditionally. Any advisory with only a GIT range (no SEMVER block) or nofixedevent raisesUnboundLocalError.affectedandrangesfrom[]to{}so subsequent.get()calls don't raiseAttributeErroron a list when the feed returns an emptyaffectedarray.fixed_version_range = Nonebefore the conditional so non-SEMVER advisories correctly storeNonefor the fixed version range.Changes
vulnerabilities/pipelines/v2_importers/curl_importer.py: initializefixed_version_range = Nonebefore the SEMVER conditional; use{}instead of[]as the fallback for emptyaffectedandranges.vulnerabilities/tests/pipelines/v2_importers/test_curl_importer_v2.py: two new tests - one for GIT-only ranges (regression test for theUnboundLocalError) and one for theCURL-CVE-*advisory id format used by the actual feed.Test plan
python -m pytest vulnerabilities/tests/pipelines/v2_importers/test_curl_importer_v2.py -v— all 8 tests passtest_parse_curl_advisory_git_only_rangewould have failed on the old code withUnboundLocalError: local variable 'fixed_version_range' referenced before assignment🤖 Generated with Claude Code