fix(1872): added fix for vex rule not working in case of direct dependancy#1874
Open
gauravshinde1729 wants to merge 1 commit intol3montree-dev:mainfrom
Conversation
Member
|
Hi @gauravshinde1729 thanks a lot for your PR! I think there is just a logical issue right here. Root actually is not a wildcard. It is used as a stop marker, so the vulnerability path needs to end actually. This means, that [root, pkg:A] should match the path [pkg:A]. The pattern: [root, pkg:A] should not match [pkg:B, pkg:A]. This is different to the star symbol. [*, pkg:A] should match [pkg:B, pkg:A]. Would it be possible for you to make the changes accordingly? |
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.
Title: VEX rules not applied for direct dependencies (#1872)
Summary:
Fixed a bug in matchPatternExact where patterns like ["*", "ROOT", "pkg:..."] never matched direct dependency vulnerability paths
like ["pkg:..."].
When a wildcard (*) was processing and its next pattern element was also a wildcard (ROOT), the code searched for "ROOT" literally
in the path. Since ROOT is a structural graph node and never stored in VulnerabilityPath, the match always failed.
Fix: Before searching for the next pattern element literally, check if it is itself a wildcard. If so, attempt a zero-element match
by recursing directly — consistent with how IsWildcard already treats ROOT.
Files changed:
dtos/vex_rule_dto.go— fixed matchPatternExact to handle consecutive wildcardsdtos/path_pattern_test.go— added test case for direct dependency matchingOutput: