mirror of
https://github.com/anchore/syft.git
synced 2026-10-30 14:02:26 +01:00
Replace distro type (#742)
* remove strong distro type Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * bump json schema to v3 (breaking distro shape) Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix linting Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * allow for v2 decoding of distro idLikes field in v3 json decoder Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix casing in simple linux release name Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * use discovered name as pretty name in simple linux release Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
@@ -3,7 +3,7 @@ package integration
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/anchore/syft/syft/distro"
|
||||
"github.com/anchore/syft/syft/linux"
|
||||
"github.com/anchore/syft/syft/pkg/cataloger"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
|
||||
@@ -33,7 +33,7 @@ func BenchmarkImagePackageCatalogers(b *testing.B) {
|
||||
b.Fatalf("unable to get resolver: %+v", err)
|
||||
}
|
||||
|
||||
theDistro := distro.Identify(resolver)
|
||||
theDistro := linux.IdentifyRelease(resolver)
|
||||
|
||||
b.Run(c.Name(), func(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
|
||||
@@ -3,20 +3,22 @@ package integration
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/anchore/syft/syft/distro"
|
||||
"github.com/go-test/deep"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/anchore/syft/syft/linux"
|
||||
)
|
||||
|
||||
func TestDistroImage(t *testing.T) {
|
||||
sbom, _ := catalogFixtureImage(t, "image-distro-id")
|
||||
|
||||
expected, err := distro.NewDistro(distro.Busybox, "1.31.1", "")
|
||||
if err != nil {
|
||||
t.Fatalf("could not create distro: %+v", err)
|
||||
}
|
||||
|
||||
for _, d := range deep.Equal(sbom.Artifacts.Distro, &expected) {
|
||||
t.Errorf("found distro difference: %+v", d)
|
||||
expected := &linux.Release{
|
||||
PrettyName: "BusyBox v1.31.1",
|
||||
Name: "busybox",
|
||||
ID: "busybox",
|
||||
IDLike: []string{"busybox"},
|
||||
Version: "1.31.1",
|
||||
VersionID: "1.31.1",
|
||||
}
|
||||
|
||||
assert.Equal(t, expected, sbom.Artifacts.LinuxDistribution)
|
||||
}
|
||||
|
||||
@@ -2,3 +2,4 @@ FROM scratch
|
||||
COPY pkgs/ .
|
||||
# we duplicate to show a package count difference between all-layers and squashed scopes
|
||||
COPY lib lib
|
||||
COPY etc/ .
|
||||
@@ -0,0 +1,12 @@
|
||||
NAME="Ubuntu"
|
||||
VERSION="20.04 LTS (Focal Fossa)"
|
||||
ID=ubuntu
|
||||
ID_LIKE=debian
|
||||
PRETTY_NAME="Ubuntu 20.04 LTS"
|
||||
VERSION_ID="20.04"
|
||||
HOME_URL="https://www.ubuntu.com/"
|
||||
SUPPORT_URL="https://help.ubuntu.com/"
|
||||
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
|
||||
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
|
||||
VERSION_CODENAME=focal
|
||||
UBUNTU_CODENAME=focal
|
||||
@@ -32,8 +32,8 @@ func catalogFixtureImage(t *testing.T, fixtureImageName string) (sbom.SBOM, *sou
|
||||
|
||||
return sbom.SBOM{
|
||||
Artifacts: sbom.Artifacts{
|
||||
PackageCatalog: pkgCatalog,
|
||||
Distro: actualDistro,
|
||||
PackageCatalog: pkgCatalog,
|
||||
LinuxDistribution: actualDistro,
|
||||
},
|
||||
Relationships: relationships,
|
||||
Source: theSource.Metadata,
|
||||
@@ -66,8 +66,8 @@ func catalogDirectory(t *testing.T, dir string) (sbom.SBOM, *source.Source) {
|
||||
|
||||
return sbom.SBOM{
|
||||
Artifacts: sbom.Artifacts{
|
||||
PackageCatalog: pkgCatalog,
|
||||
Distro: actualDistro,
|
||||
PackageCatalog: pkgCatalog,
|
||||
LinuxDistribution: actualDistro,
|
||||
},
|
||||
Relationships: relationships,
|
||||
Source: theSource.Metadata,
|
||||
|
||||
Reference in New Issue
Block a user