mirror of
https://github.com/anchore/syft.git
synced 2026-11-02 07:26:34 +01:00
Internalize majority of cmd package (#2533)
* internalize majority of cmd package and migrate integration tests Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add internal api encoder Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * create internal representation of all formats Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * export capability to get default encoders Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * restore test fixtures Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package integration
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/anchore/syft/syft/pkg"
|
||||
"github.com/anchore/syft/syft/source"
|
||||
)
|
||||
|
||||
func TestWarCatalogedCorrectlyIfRenamed(t *testing.T) {
|
||||
// install hudson-war@2.2.1 and renames the file to `/hudson.war`
|
||||
sbom, _ := catalogFixtureImage(t, "image-java-virtualpath-regression", source.SquashedScope)
|
||||
|
||||
badPURL := "pkg:maven/hudson/hudson@2.2.1"
|
||||
goodPURL := "pkg:maven/org.jvnet.hudson.main/hudson-war@2.2.1"
|
||||
foundCorrectPackage := false
|
||||
badVirtualPath := "/hudson.war:org.jvnet.hudson.main:hudson-war"
|
||||
goodVirtualPath := "/hudson.war"
|
||||
for _, p := range sbom.Artifacts.Packages.Sorted() {
|
||||
if p.Type == pkg.JavaPkg && strings.Contains(p.Name, "hudson") {
|
||||
assert.NotEqual(t, badPURL, p.PURL, "must not find bad purl %q", badPURL)
|
||||
virtPath := ""
|
||||
if meta, ok := p.Metadata.(pkg.JavaArchive); ok {
|
||||
virtPath = meta.VirtualPath
|
||||
if p.PURL == goodPURL && virtPath == goodVirtualPath {
|
||||
foundCorrectPackage = true
|
||||
}
|
||||
}
|
||||
assert.NotEqual(t, badVirtualPath, virtPath, "must not find bad virtual path %q", badVirtualPath)
|
||||
}
|
||||
}
|
||||
assert.True(t, foundCorrectPackage, "must find correct package, but did not")
|
||||
}
|
||||
Reference in New Issue
Block a user