-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(vex): use a separate visited set for each DFS path
#9760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DmitriyLewen
wants to merge
5
commits into
aquasecurity:main
Choose a base branch
from
DmitriyLewen:fix/vex/multiple-parent-check-from-different-branches
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bb7e208
test(vex): add test
DmitriyLewen e00c6d6
refactor(vex): use set instead of map
DmitriyLewen 46398fd
test(vex): correct test result
DmitriyLewen 84f3419
fix(vex): use different (use set.Clone) visited sets for each path
DmitriyLewen 0a51da3
chore: add comment
DmitriyLewen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,6 +70,20 @@ var ( | |
| }, | ||
| }, | ||
| } | ||
| baseFiles2Package = ftypes.Package{ | ||
| ID: "[email protected]", | ||
| Name: "base-files2", | ||
| Version: "5.3", | ||
| Identifier: ftypes.PkgIdentifier{ | ||
| UID: "08", | ||
| PURL: &packageurl.PackageURL{ | ||
| Type: packageurl.TypeDebian, | ||
| Namespace: "debian", | ||
| Name: "base-files2", | ||
| Version: "5.3", | ||
| }, | ||
| }, | ||
| } | ||
| goModulePackage = ftypes.Package{ | ||
| ID: "github.com/aquasecurity/[email protected]", | ||
| Name: "github.com/aquasecurity/go-module", | ||
|
|
@@ -572,7 +586,7 @@ repositories: | |
| Sources: []vex.Source{ | ||
| { | ||
| Type: vex.TypeFile, | ||
| FilePath: "testdata/openvex-multiple.json", | ||
| FilePath: "testdata/openvex-oci.json", | ||
| }, | ||
| }, | ||
| }, | ||
|
|
@@ -585,6 +599,37 @@ repositories: | |
| }), | ||
| }), | ||
| }, | ||
| { | ||
| name: "check one parent from multiple dependency paths", | ||
| args: args{ | ||
| // - oci:debian?tag=12 | ||
| // - pkg:deb/debian/[email protected] | ||
| // - pkg:deb/debian/[email protected] | ||
| // - pkg:deb/debian/[email protected] | ||
| // - pkg:deb/debian/[email protected] | ||
| report: imageReport([]types.Result{ | ||
| bashPackagesResult(types.Result{ | ||
| Vulnerabilities: []types.DetectedVulnerability{ | ||
| vuln3, | ||
| }, | ||
| }), | ||
| }), | ||
| opts: vex.Options{ | ||
| Sources: []vex.Source{ | ||
| { | ||
| Type: vex.TypeFile, | ||
| FilePath: "testdata/openvex-oci.json", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| want: imageReport([]types.Result{ | ||
| bashPackagesResult(types.Result{ | ||
| Vulnerabilities: []types.DetectedVulnerability{}, | ||
| ModifiedFindings: []types.ModifiedFinding{modifiedFinding(vuln3, vulnerableCodeNotInExecutePath, "testdata/openvex-oci.json")}, | ||
| }), | ||
| }), | ||
| }, | ||
| { | ||
| name: "unknown format", | ||
| args: args{ | ||
|
|
@@ -705,6 +750,26 @@ func bashResult(result types.Result) types.Result { | |
| return result | ||
| } | ||
|
|
||
| func bashPackagesResult(result types.Result) types.Result { | ||
| result.Type = ftypes.Debian | ||
| result.Class = types.ClassOSPkg | ||
|
|
||
| bashPkg := clonePackage(bashPackage) | ||
| baseFilesPkg := clonePackage(baseFilesPackage) | ||
| baseFiles2Pkg := clonePackage(baseFiles2Package) | ||
|
|
||
| baseFilesPkg.DependsOn = []string{bashPkg.ID} | ||
| baseFiles2Pkg.DependsOn = []string{bashPkg.ID} | ||
|
|
||
| result.Packages = []ftypes.Package{ | ||
| bashPkg, | ||
| baseFilesPkg, | ||
| baseFiles2Pkg, | ||
| } | ||
|
|
||
| return result | ||
| } | ||
|
|
||
| func infinityLoopOSPackagesResult(result types.Result) types.Result { | ||
| result.Type = ftypes.Debian | ||
| result.Class = types.ClassOSPkg | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case looks like multiple parents ([email protected] and [email protected]) from a single dependency ([email protected]). Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right.
But oci:debian?tag=12 is the parent for both [email protected] and [email protected].
For this test case there are two dependency paths:
After the first path, we mark oci:debian?tag=12 as visited.
When we process pkg:deb/debian/[email protected], we see that oci:debian?tag=12 is already visited and return true.