Skip to content
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

fix: stop panicking on "devel" version go stdlib #3043

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions syft/pkg/cataloger/golang/stdlib_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ func stdlibPackageAndRelationships(pkgs []pkg.Package) ([]pkg.Package, []artifac
}

stdLibPkg := newGoStdLib(mValue.GoCompiledVersion, goPkg.Locations)
if stdLibPkg != nil {
goCompilerPkgs = append(goCompilerPkgs, *stdLibPkg)
totalLocations.Add(location)
if stdLibPkg == nil {
continue
}
goCompilerPkgs = append(goCompilerPkgs, *stdLibPkg)
totalLocations.Add(location)

relationships = append(relationships, artifact.Relationship{
From: *stdLibPkg,
Expand Down
16 changes: 16 additions & 0 deletions syft/pkg/cataloger/golang/stdlib_package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@ func Test_stdlibPackageAndRelationships(t *testing.T) {
wantPkgs: 1,
wantRels: 1,
},
{
name: "go binary package with devel stdlib",
pkgs: []pkg.Package{
{
Name: "github.com/something/go",
Version: "1.0.0",
Locations: file.NewLocationSet(file.NewLocation("/bin/my-app")),
Metadata: pkg.GolangBinaryBuildinfoEntry{
GoCompiledVersion: "devel",
MainModule: "github.com/something/go",
},
},
},
wantPkgs: 0,
wantRels: 0,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
Loading