fix: prevent panics on malformed parser inputs - #10978
Open
123kaze wants to merge 2 commits into
Open
Conversation
123kaze
marked this pull request as ready for review
July 21, 2026 11:04
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.
Description
Closes #10976.
Several parsers and the Amazon Linux detector indexed the first element returned by
strings.Fieldsor another tokenization step without first checking whether any tokens existed. Malformed but container-valid input could therefore panic and abort the entire scan.This change handles each malformed value at the boundary where its format is understood:
DetectandIsSupportedVersion;pyproject.tomldependencies;Each parser keeps its existing behavior for valid input. The checks remain local because the four dependency formats have different parsing rules and malformed-entry policies.
Before
Any of the malformed inputs described in #10976 could cause
runtime error: index out of range [0] with length 0and terminate the scan.After
The Amazon Linux analyzer reports its normal OS analysis error when required version information is absent. Direct Amazon detector calls also return safely. The dependency parsers skip only the malformed entry and continue parsing valid content.
Validation
mage tidymage fmtmage buildmage docs:generatemage lint:run(0 issues)mage test:unitgit diff --checkChecklist