mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
Correct CycloneDX distro decoding (#745)
This commit is contained in:
parent
7789506dc6
commit
6c8102bf28
@ -5,6 +5,8 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/CycloneDX/cyclonedx-go"
|
"github.com/CycloneDX/cyclonedx-go"
|
||||||
|
|
||||||
|
"github.com/anchore/syft/internal/formats/common"
|
||||||
"github.com/anchore/syft/syft/artifact"
|
"github.com/anchore/syft/syft/artifact"
|
||||||
"github.com/anchore/syft/syft/linux"
|
"github.com/anchore/syft/syft/linux"
|
||||||
"github.com/anchore/syft/syft/pkg"
|
"github.com/anchore/syft/syft/pkg"
|
||||||
@ -157,6 +159,14 @@ func linuxReleaseFromOSComponent(component *cyclonedx.Component) *linux.Release
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if component.Properties != nil {
|
||||||
|
values := map[string]string{}
|
||||||
|
for _, p := range *component.Properties {
|
||||||
|
values[p.Name] = p.Value
|
||||||
|
}
|
||||||
|
common.DecodeInto(&rel, values, "syft:distro", CycloneDXFields)
|
||||||
|
}
|
||||||
|
|
||||||
return rel
|
return rel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -54,7 +54,9 @@ func TestEncodeDecodeEncodeCycleComparison(t *testing.T) {
|
|||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(string(test.formatOption), func(t *testing.T) {
|
t.Run(string(test.formatOption), func(t *testing.T) {
|
||||||
|
|
||||||
originalSBOM, _ := catalogFixtureImage(t, "image-pkg-coverage")
|
// use second image for relationships
|
||||||
|
for _, image := range []string{"image-pkg-coverage", "image-owning-package"} {
|
||||||
|
originalSBOM, _ := catalogFixtureImage(t, image)
|
||||||
|
|
||||||
format := syft.FormatByID(test.formatOption)
|
format := syft.FormatByID(test.formatOption)
|
||||||
require.NotNil(t, format)
|
require.NotNil(t, format)
|
||||||
@ -85,6 +87,7 @@ func TestEncodeDecodeEncodeCycleComparison(t *testing.T) {
|
|||||||
t.Errorf("diff: %s", dmp.DiffPrettyText(diffs))
|
t.Errorf("diff: %s", dmp.DiffPrettyText(diffs))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user