fix: handle Go 1.26 GOEXPERIMENT version format change#10351
Merged
DmitriyLewen merged 2 commits intoaquasecurity:mainfrom Mar 17, 2026
Merged
fix: handle Go 1.26 GOEXPERIMENT version format change#10351DmitriyLewen merged 2 commits intoaquasecurity:mainfrom
DmitriyLewen merged 2 commits intoaquasecurity:mainfrom
Conversation
Contributor
DmitriyLewen
left a comment
There was a problem hiding this comment.
Hello @VedantMadane
Thanks for your contribution!
left a comment. Take a look, when you have time, please.
Contributor
There was a problem hiding this comment.
I think you can use export_test.go file for this test (instead of creating new file (parse_internal_test.go.)
e.g.
diff --git a/pkg/dependency/parser/golang/binary/export_test.go b/pkg/dependency/parser/golang/binary/export_test.go
index 3f361bc1e..2c0bb7545 100644
--- a/pkg/dependency/parser/golang/binary/export_test.go
+++ b/pkg/dependency/parser/golang/binary/export_test.go
@@ -13,3 +13,6 @@ func (p *Parser) ChooseMainVersion(version, ldflagsVersion, elfVersion string) s
func (p *Parser) ELFSymbolVersion(r io.ReaderAt, name string) string {
return p.elfSymbolVersion(r, name)
}
+
+
+var ParseStdlibVersion = parseStdlibVersion
\ No newline at end of file
diff --git a/pkg/dependency/parser/golang/binary/parse_internal_test.go b/pkg/dependency/parser/golang/binary/parse_internal_test.go
index bece0aeff..3a0102b8c 100644
--- a/pkg/dependency/parser/golang/binary/parse_internal_test.go
+++ b/pkg/dependency/parser/golang/binary/parse_internal_test.go
@@ -1,8 +1,9 @@
-package binary
+package binary_test
import (
"testing"
+ "github.com/aquasecurity/trivy/pkg/dependency/parser/golang/binary"
"github.com/stretchr/testify/assert"
)
@@ -40,7 +41,7 @@ func TestParseStdlibVersion(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- got := parseStdlibVersion(tt.goVersion)
+ got := binary.ParseStdlibVersion(tt.goVersion)
assert.Equal(t, tt.want, got)
})
}
jtownnew13-collab
approved these changes
Mar 10, 2026
d23bb60 to
1abf69a
Compare
Go 1.26 changed the GOEXPERIMENT format from ' X:' separator to '-X:'. Strip both formats when parsing stdlib version from build info. Fixes aquasecurity#10350
1abf69a to
e389ab3
Compare
Contributor
|
Hello @VedantMadane I see that you did a rebase, but I don't see the suggested changes. Regards, Dmitriy |
6 tasks
3 tasks
DmitriyLewen
approved these changes
Mar 17, 2026
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
Go 1.26 changed the format used to embed GOEXPERIMENT flags in the binary's build info from \ X:\ separator (Go <=1.25) to -X:\ separator (Go >=1.26). Trivy was failing to correctly parse the stdlib version from binaries built with Go 1.26 when GOEXPERIMENT flags are present.
Changes
Testing
Fixes #10350