mirror of
https://github.com/anchore/syft.git
synced 2026-02-12 10:36:45 +01:00
fix: stop panicking on "devel" version go stdlib (#3043)
Previously, if a Go binary was cataloged with build info indicating that the go compiler version used was "deve", syft would panic on a nil pointer dereference. Instead, skip creating a Go stdlib reference and relationship for such a package. Signed-off-by: Will Murphy <will.murphy@anchore.com>
This commit is contained in:
parent
278b72d39b
commit
75902b0540
@ -33,10 +33,11 @@ func stdlibPackageAndRelationships(pkgs []pkg.Package) ([]pkg.Package, []artifac
|
|||||||
}
|
}
|
||||||
|
|
||||||
stdLibPkg := newGoStdLib(mValue.GoCompiledVersion, goPkg.Locations)
|
stdLibPkg := newGoStdLib(mValue.GoCompiledVersion, goPkg.Locations)
|
||||||
if stdLibPkg != nil {
|
if stdLibPkg == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
goCompilerPkgs = append(goCompilerPkgs, *stdLibPkg)
|
goCompilerPkgs = append(goCompilerPkgs, *stdLibPkg)
|
||||||
totalLocations.Add(location)
|
totalLocations.Add(location)
|
||||||
}
|
|
||||||
|
|
||||||
relationships = append(relationships, artifact.Relationship{
|
relationships = append(relationships, artifact.Relationship{
|
||||||
From: *stdLibPkg,
|
From: *stdLibPkg,
|
||||||
|
|||||||
@ -68,6 +68,22 @@ func Test_stdlibPackageAndRelationships(t *testing.T) {
|
|||||||
wantPkgs: 1,
|
wantPkgs: 1,
|
||||||
wantRels: 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 {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user