From f9d0fa81ab6c2232df7b6b2d4b966797483f2ba5 Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Fri, 9 May 2025 13:49:17 -0400 Subject: [PATCH] do not search binary contents for version for go package (#3874) Signed-off-by: Alex Goodman --- syft/pkg/cataloger/golang/config.go | 2 +- syft/pkg/cataloger/golang/parse_go_binary_test.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/syft/pkg/cataloger/golang/config.go b/syft/pkg/cataloger/golang/config.go index 604471954..36dca0fbc 100644 --- a/syft/pkg/cataloger/golang/config.go +++ b/syft/pkg/cataloger/golang/config.go @@ -91,7 +91,7 @@ func defaultGoModDir() string { func DefaultMainModuleVersionConfig() MainModuleVersionConfig { return MainModuleVersionConfig{ FromLDFlags: true, - FromContents: true, + FromContents: false, FromBuildSettings: true, } } diff --git a/syft/pkg/cataloger/golang/parse_go_binary_test.go b/syft/pkg/cataloger/golang/parse_go_binary_test.go index 36158507a..d1949d352 100644 --- a/syft/pkg/cataloger/golang/parse_go_binary_test.go +++ b/syft/pkg/cataloger/golang/parse_go_binary_test.go @@ -855,6 +855,14 @@ func TestBuildGoPkgInfo(t *testing.T) { }, { name: "parse main mod and replace devel with pattern from binary contents", + cfg: func() *CatalogerConfig { + c := DefaultCatalogerConfig() + // off by default + assert.False(t, c.MainModuleVersion.FromContents) + // override to true for this test + c.MainModuleVersion.FromContents = true + return &c + }(), mod: &extendedBuildInfo{ BuildInfo: &debug.BuildInfo{ GoVersion: goCompiledVersion,