-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 1 commit
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
Next
Next commit
feat(gomod): parse
toolchain
to get stdlib version
- Loading branch information
commit f4d7af419827ec2c13503468fd688fd278ef677f
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
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.
Since Go uses
go
line iftoolchain
is omitted, we probably need to check thego
line as well.https://go.dev/doc/toolchain
But we need to consider how to treat a go line omitting a patch version, like
go 1.22
. I think we can skip stdlib in this case.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.
If module uses version without patch (and child modules don't use patch and
toolchain
) -go
doesn't add patch/toolchain:➜ cat ../greetings/go.mod module github.com/greetings go 1.22 ➜ cat go.mod module example.com/hello go 1.22 replace example.com/greetings => ../greetings require example.com/greetings v0.0.0-00010101000000-000000000000 ➜ go version go version go1.22.0 darwin/arm64
since we say we use
minimum required version
forstdlib
- we can say thatv1.x.0
(v1.21.0
for this example) is the minimum required version, no?I think I'm missing something, but I can't figure out what 😄
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.
or do you mean that if
go
version doesn't contain patch - that means it is not a situation wheretoolchan
is omitted?and we don't need to check for cases where
toolchain
is not used (or omitted).But it doesn't work for
v1.19
or early:The standard Go toolchains are named goV where V is a Go version denoting a beta release, release candidate, or release. For example, go1.21rc1 and go1.21.0 are toolchain names; go1.21 and go1.22 are not (the initial releases are go1.21.0 and go1.22.0), but go1.20 and go1.19 are.
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.
I found answer -
1.21
!=1.21.0
:For example, 1.21 < 1.21rc1 < 1.21rc2 < 1.21.0 < 1.21.1 < 1.21.2.
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.
@knqyf263 I updated this PR:
go
linerc
releasesThere 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.
Detection using the minimum version may be better enabled when this flag is used. For example,
django>=3.0.0
in requirements.txt, we can take3.0.0
as the version even if the project may use newer than 3.0.0. The toolchain version is the same. Fromtoolchain go1.21.4
in go.mod, we consider it Go 1.21.4 even if the project may actually use Go 1.21.5.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.
Agree with you.
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.
OK, I've converted this PR to draft. Let's finalize this proposal first and come back here.
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 is good idea 👍
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.
@knqyf263 I updated this PR using
--detection-priority
flag.Take a look, when you have time, please.