mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 08:23:15 +01:00
add main module field to go bin metadata (#1026)
* add main module field to go bin metadata Signed-off-by: Jonas Xavier <jonasx@anchore.com> * udpate json ouput schema to 3.2.4 Signed-off-by: Jonas Xavier <jonasx@anchore.com> * clean up fixture Signed-off-by: Jonas Xavier <jonasx@anchore.com>
This commit is contained in:
parent
caff67289a
commit
0aea55f880
@ -6,5 +6,5 @@ const (
|
||||
|
||||
// JSONSchemaVersion is the current schema version output by the JSON encoder
|
||||
// This is roughly following the "SchemaVer" guidelines for versioning the JSON schema. Please see schema/json/README.md for details on how to increment.
|
||||
JSONSchemaVersion = "3.2.3"
|
||||
JSONSchemaVersion = "3.2.4"
|
||||
)
|
||||
|
||||
@ -88,7 +88,7 @@
|
||||
}
|
||||
},
|
||||
"schema": {
|
||||
"version": "3.2.3",
|
||||
"url": "https://raw.githubusercontent.com/anchore/syft/main/schema/json/schema-3.2.3.json"
|
||||
"version": "3.2.4",
|
||||
"url": "https://raw.githubusercontent.com/anchore/syft/main/schema/json/schema-3.2.4.json"
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@
|
||||
}
|
||||
},
|
||||
"schema": {
|
||||
"version": "3.2.3",
|
||||
"url": "https://raw.githubusercontent.com/anchore/syft/main/schema/json/schema-3.2.3.json"
|
||||
"version": "3.2.4",
|
||||
"url": "https://raw.githubusercontent.com/anchore/syft/main/schema/json/schema-3.2.4.json"
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@
|
||||
}
|
||||
},
|
||||
"schema": {
|
||||
"version": "3.2.3",
|
||||
"url": "https://raw.githubusercontent.com/anchore/syft/main/schema/json/schema-3.2.3.json"
|
||||
"version": "3.2.4",
|
||||
"url": "https://raw.githubusercontent.com/anchore/syft/main/schema/json/schema-3.2.4.json"
|
||||
}
|
||||
}
|
||||
|
||||
1301
schema/json/schema-3.2.4.json
Normal file
1301
schema/json/schema-3.2.4.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -28,7 +28,7 @@ var (
|
||||
|
||||
func makeGoMainPackage(mod *debug.BuildInfo, arch string, location source.Location) pkg.Package {
|
||||
gbs := getBuildSettings(mod.Settings)
|
||||
main := newGoBinaryPackage(&mod.Main, mod.GoVersion, arch, location, gbs)
|
||||
main := newGoBinaryPackage(&mod.Main, mod.Main.Path, mod.GoVersion, arch, location, gbs)
|
||||
|
||||
if v, ok := gbs["vcs.revision"]; ok {
|
||||
main.Version = v
|
||||
@ -37,7 +37,7 @@ func makeGoMainPackage(mod *debug.BuildInfo, arch string, location source.Locati
|
||||
return main
|
||||
}
|
||||
|
||||
func newGoBinaryPackage(dep *debug.Module, goVersion, architecture string, location source.Location, buildSettings map[string]string) pkg.Package {
|
||||
func newGoBinaryPackage(dep *debug.Module, mainModule, goVersion, architecture string, location source.Location, buildSettings map[string]string) pkg.Package {
|
||||
if dep.Replace != nil {
|
||||
dep = dep.Replace
|
||||
}
|
||||
@ -55,6 +55,7 @@ func newGoBinaryPackage(dep *debug.Module, goVersion, architecture string, locat
|
||||
H1Digest: dep.Sum,
|
||||
Architecture: architecture,
|
||||
BuildSettings: buildSettings,
|
||||
MainModule: mainModule,
|
||||
},
|
||||
}
|
||||
|
||||
@ -172,7 +173,7 @@ func buildGoPkgInfo(location source.Location, mod *debug.BuildInfo, arch string)
|
||||
if dep == nil {
|
||||
continue
|
||||
}
|
||||
p := newGoBinaryPackage(dep, mod.GoVersion, arch, location, nil)
|
||||
p := newGoBinaryPackage(dep, mod.Main.Path, mod.GoVersion, arch, location, nil)
|
||||
if pkg.IsValid(&p) {
|
||||
pkgs = append(pkgs, p)
|
||||
}
|
||||
|
||||
@ -147,6 +147,7 @@ func TestBuildGoPkgInfo(t *testing.T) {
|
||||
GoCompiledVersion: goCompiledVersion,
|
||||
Architecture: archDetails,
|
||||
BuildSettings: buildSettings,
|
||||
MainModule: "github.com/anchore/syft",
|
||||
},
|
||||
}
|
||||
|
||||
@ -298,6 +299,7 @@ func TestBuildGoPkgInfo(t *testing.T) {
|
||||
GoCompiledVersion: goCompiledVersion,
|
||||
Architecture: archDetails,
|
||||
H1Digest: "h1:VSVdnH7cQ7V+B33qSJHTCRlNgra1607Q8PzEmnvb2Ic=",
|
||||
MainModule: "github.com/anchore/syft",
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -319,6 +321,7 @@ func TestBuildGoPkgInfo(t *testing.T) {
|
||||
GoCompiledVersion: goCompiledVersion,
|
||||
Architecture: archDetails,
|
||||
H1Digest: "h1:DYssiUV1pBmKqzKsm4mqXx8artqC0Q8HgZsVI3lMsAg=",
|
||||
MainModule: "github.com/anchore/syft",
|
||||
},
|
||||
},
|
||||
expectedMain,
|
||||
@ -372,7 +375,9 @@ func TestBuildGoPkgInfo(t *testing.T) {
|
||||
Metadata: pkg.GolangBinMetadata{
|
||||
GoCompiledVersion: goCompiledVersion,
|
||||
Architecture: archDetails,
|
||||
H1Digest: "h1:PjhxBct4MZii8FFR8+oeS7QOvxKOTZXgk63EU2XpfJE="}},
|
||||
H1Digest: "h1:PjhxBct4MZii8FFR8+oeS7QOvxKOTZXgk63EU2XpfJE=",
|
||||
MainModule: "github.com/anchore/syft",
|
||||
}},
|
||||
{
|
||||
Name: "golang.org/x/term",
|
||||
FoundBy: catalogerName,
|
||||
@ -391,7 +396,9 @@ func TestBuildGoPkgInfo(t *testing.T) {
|
||||
Metadata: pkg.GolangBinMetadata{
|
||||
GoCompiledVersion: goCompiledVersion,
|
||||
Architecture: archDetails,
|
||||
H1Digest: "h1:Ihq/mm/suC88gF8WFcVwk+OV6Tq+wyA1O0E5UEvDglI="},
|
||||
H1Digest: "h1:Ihq/mm/suC88gF8WFcVwk+OV6Tq+wyA1O0E5UEvDglI=",
|
||||
MainModule: "github.com/anchore/syft",
|
||||
},
|
||||
},
|
||||
expectedMain,
|
||||
},
|
||||
|
||||
@ -6,4 +6,5 @@ type GolangBinMetadata struct {
|
||||
GoCompiledVersion string `json:"goCompiledVersion" cyclonedx:"goCompiledVersion"`
|
||||
Architecture string `json:"architecture" cyclonedx:"architecture"`
|
||||
H1Digest string `json:"h1Digest,omitempty" cyclonedx:"h1Digest"`
|
||||
MainModule string `json:"mainModule,omitempty" cyclonedx:"mainModule"`
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user