mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
Merge pull request #447 from bureado/main
Minimal changes to use ID_LIKE
This commit is contained in:
commit
6f038e9208
@ -91,10 +91,15 @@ func assemble(name, version, like string) *Distro {
|
|||||||
distroType, ok := IDMapping[name]
|
distroType, ok := IDMapping[name]
|
||||||
|
|
||||||
// Both distro and version must be present
|
// Both distro and version must be present
|
||||||
if len(name) == 0 {
|
if len(name) == 0 && len(version) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If it's an unknown distro, try mapping the ID_LIKE
|
||||||
|
if !ok && len(like) != 0 {
|
||||||
|
distroType, ok = IDMapping[like]
|
||||||
|
}
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
distro, err := NewDistro(distroType, version, like)
|
distro, err := NewDistro(distroType, version, like)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -7,9 +7,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/anchore/syft/internal"
|
"github.com/anchore/syft/internal"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
|
|
||||||
"github.com/anchore/syft/syft/source"
|
"github.com/anchore/syft/syft/source"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestIdentifyDistro(t *testing.T) {
|
func TestIdentifyDistro(t *testing.T) {
|
||||||
@ -85,6 +84,20 @@ func TestIdentifyDistro(t *testing.T) {
|
|||||||
fixture: "test-fixtures/os/arch",
|
fixture: "test-fixtures/os/arch",
|
||||||
Type: ArchLinux,
|
Type: ArchLinux,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
fixture: "test-fixtures/partial-fields/missing-id",
|
||||||
|
Type: Debian,
|
||||||
|
Version: "8.0.0",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fixture: "test-fixtures/partial-fields/unknown-id",
|
||||||
|
Type: Debian,
|
||||||
|
Version: "8.0.0",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fixture: "test-fixtures/partial-fields/missing-version",
|
||||||
|
Type: UnknownDistroType,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
observedDistros := internal.NewStringSet()
|
observedDistros := internal.NewStringSet()
|
||||||
|
|||||||
@ -0,0 +1,3 @@
|
|||||||
|
NAME="Debian GNU/Linux"
|
||||||
|
VERSION_ID="8"
|
||||||
|
ID_LIKE=debian
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
NAME="Debian GNU/Linux"
|
||||||
|
ID_LIKE=debian
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
NAME="Debian GNU/Linux"
|
||||||
|
VERSION_ID="8"
|
||||||
|
ID=my-awesome-distro
|
||||||
|
ID_LIKE=debian
|
||||||
Loading…
x
Reference in New Issue
Block a user