mirror of
https://github.com/anchore/syft
synced 2024-11-10 06:14:16 +00:00
Merge pull request #447 from bureado/main
Minimal changes to use ID_LIKE
This commit is contained in:
commit
6f038e9208
5 changed files with 30 additions and 3 deletions
|
@ -91,10 +91,15 @@ func assemble(name, version, like string) *Distro {
|
|||
distroType, ok := IDMapping[name]
|
||||
|
||||
// Both distro and version must be present
|
||||
if len(name) == 0 {
|
||||
if len(name) == 0 && len(version) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
// If it's an unknown distro, try mapping the ID_LIKE
|
||||
if !ok && len(like) != 0 {
|
||||
distroType, ok = IDMapping[like]
|
||||
}
|
||||
|
||||
if ok {
|
||||
distro, err := NewDistro(distroType, version, like)
|
||||
if err != nil {
|
||||
|
|
|
@ -7,9 +7,8 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/anchore/syft/internal"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/anchore/syft/syft/source"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestIdentifyDistro(t *testing.T) {
|
||||
|
@ -85,6 +84,20 @@ func TestIdentifyDistro(t *testing.T) {
|
|||
fixture: "test-fixtures/os/arch",
|
||||
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()
|
||||
|
|
|
@ -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…
Reference in a new issue