-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
feat(go): use toolchain
as stdlib
version for go.mod
files
#7163
Merged
knqyf263
merged 15 commits into
aquasecurity:main
from
DmitriyLewen:feat-gomod/stdlib-from-toolchain
Sep 3, 2024
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
f4d7af4
feat(gomod): parse `toolchain` to get stdlib version
DmitriyLewen a3d25f5
test(gomod): update unit test
DmitriyLewen 132fa50
docs(go): update coverage page
DmitriyLewen f0fe5c5
docs(go): add info about toolchain and local go version
DmitriyLewen 5c136e9
feat: parse `go` line when toolchain omitted
DmitriyLewen 797a1b9
docs: add info about Go version restrictions
DmitriyLewen fe248fc
refactor: update logic to detect Go version for `go` line
DmitriyLewen 4c0d49c
update docs
DmitriyLewen 48cacc2
Merge branch 'main' into 'feat-gomod/stdlib-from-toolchain'
DmitriyLewen 4d0814c
feat: add useMinVersion + update comments
DmitriyLewen 294bd1e
test: update testcases
DmitriyLewen 70ca3cd
fix: update newGoModAnalyzer
DmitriyLewen e8aaef4
docs: update
DmitriyLewen 175b542
refactor: update comments
DmitriyLewen e6411c0
refactor
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 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 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 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 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 |
---|---|---|
@@ -1,6 +1,10 @@ | ||
package mod | ||
|
||
import ftypes "github.com/aquasecurity/trivy/pkg/fanal/types" | ||
import ( | ||
"slices" | ||
|
||
ftypes "github.com/aquasecurity/trivy/pkg/fanal/types" | ||
) | ||
|
||
var ( | ||
// execute go mod tidy in normal folder | ||
|
@@ -17,37 +21,71 @@ var ( | |
}, | ||
}, | ||
{ | ||
ID: "github.com/aquasecurity/[email protected]", | ||
Name: "github.com/aquasecurity/go-dep-parser", | ||
Version: "0.0.0-20211224170007-df43bca6b6ff", | ||
ID: "[email protected]", | ||
Name: "stdlib", | ||
Version: "1.22.5", | ||
Relationship: ftypes.RelationshipDirect, | ||
}, | ||
{ | ||
ID: "github.com/aquasecurity/[email protected]", | ||
Name: "github.com/aquasecurity/go-version", | ||
Version: "0.0.0-20240603093900-cf8a8d29271d", | ||
Relationship: ftypes.RelationshipDirect, | ||
ExternalReferences: []ftypes.ExternalRef{ | ||
{ | ||
Type: ftypes.RefVCS, | ||
URL: "https://github.com/aquasecurity/go-dep-parser", | ||
URL: "https://github.com/aquasecurity/go-version", | ||
}, | ||
}, | ||
}, | ||
{ | ||
ID: "golang.org/x/[email protected]", | ||
Name: "golang.org/x/xerrors", | ||
Version: "0.0.0-20200804184101-5ec99f83aff1", | ||
ID: "github.com/davecgh/[email protected]", | ||
Name: "github.com/davecgh/go-spew", | ||
Version: "1.1.2-0.20180830191138-d8f796af33cc", | ||
Relationship: ftypes.RelationshipIndirect, | ||
ExternalReferences: []ftypes.ExternalRef{ | ||
{ | ||
Type: ftypes.RefVCS, | ||
URL: "https://github.com/davecgh/go-spew", | ||
}, | ||
}, | ||
}, | ||
{ | ||
ID: "github.com/pmezard/[email protected]", | ||
Name: "github.com/pmezard/go-difflib", | ||
Version: "1.0.1-0.20181226105442-5d4384ee4fb2", | ||
Relationship: ftypes.RelationshipIndirect, | ||
ExternalReferences: []ftypes.ExternalRef{ | ||
{ | ||
Type: ftypes.RefVCS, | ||
URL: "https://github.com/pmezard/go-difflib", | ||
}, | ||
}, | ||
}, | ||
{ | ||
ID: "gopkg.in/[email protected]", | ||
Name: "gopkg.in/yaml.v3", | ||
Version: "3.0.0-20210107192922-496545a6307b", | ||
ID: "github.com/stretchr/[email protected]", | ||
Name: "github.com/stretchr/testify", | ||
Version: "1.9.0", | ||
Relationship: ftypes.RelationshipIndirect, | ||
ExternalReferences: []ftypes.ExternalRef{ | ||
{ | ||
Type: ftypes.RefVCS, | ||
URL: "https://github.com/go-yaml/yaml", | ||
URL: "https://github.com/stretchr/testify", | ||
}, | ||
}, | ||
}, | ||
{ | ||
ID: "golang.org/x/[email protected]", | ||
Name: "golang.org/x/xerrors", | ||
Version: "0.0.0-20231012003039-104605ab7028", | ||
Relationship: ftypes.RelationshipIndirect, | ||
}, | ||
} | ||
|
||
GoModNormalWithoutStdlib = slices.DeleteFunc(slices.Clone(GoModNormal), func(f ftypes.Package) bool { | ||
return f.Name == "stdlib" | ||
}) | ||
|
||
// execute go mod tidy in replaced folder | ||
GoModReplaced = []ftypes.Package{ | ||
{ | ||
|
Oops, something went wrong.
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.
nit: It's no big deal, but if
useMinVersion == false
, we don't need to get the toolchain version. We may want to evaluateuseMinVersion
first before getting the toolchain version.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.
It make sense.
Updated in e6411c0