test: update tests with new expections

Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
This commit is contained in:
Christopher Phillips 2026-02-02 12:49:03 -05:00
parent cb62054eed
commit 67986a9279
No known key found for this signature in database
6 changed files with 21 additions and 5 deletions

View File

@ -34,6 +34,8 @@ application: # AUTO-GENERATED - application-level config keys
description: search for go package licences by retrieving the package from a network proxy description: search for go package licences by retrieving the package from a network proxy
- key: golang.use-packages-lib - key: golang.use-packages-lib
description: use the golang.org/x/tools/go/packages library, which executes golang tooling found on the path in addition to potential network access to get the most accurate results description: use the golang.org/x/tools/go/packages library, which executes golang tooling found on the path in addition to potential network access to get the most accurate results
- key: java.detect-contained-packages
description: collect all Java package names contained within JAR files. This extracts package information from class file paths within the archive
- key: java.maven-local-repository-dir - key: java.maven-local-repository-dir
description: override the default location of the local Maven repository. the default is the subdirectory '.m2/repository' in your home directory description: override the default location of the local Maven repository. the default is the subdirectory '.m2/repository' in your home directory
- key: java.maven-url - key: java.maven-url

View File

@ -27,7 +27,7 @@
}, },
{ {
"name": "files-analyzed-true", "name": "files-analyzed-true",
"SPDXID": "SPDXRef-Package-files-analyzed-true-035066c2086b8bb4", "SPDXID": "SPDXRef-Package-files-analyzed-true-716e193286ab5f0a",
"versionInfo": "v1", "versionInfo": "v1",
"supplier": "NOASSERTION", "supplier": "NOASSERTION",
"downloadLocation": "NOASSERTION", "downloadLocation": "NOASSERTION",
@ -77,7 +77,7 @@
], ],
"relationships": [ "relationships": [
{ {
"spdxElementId": "SPDXRef-Package-files-analyzed-true-035066c2086b8bb4", "spdxElementId": "SPDXRef-Package-files-analyzed-true-716e193286ab5f0a",
"relatedSpdxElement": "SPDXRef-File-some-file-2c5bc344430decac", "relatedSpdxElement": "SPDXRef-File-some-file-2c5bc344430decac",
"relationshipType": "CONTAINS" "relationshipType": "CONTAINS"
}, },
@ -88,7 +88,7 @@
}, },
{ {
"spdxElementId": "SPDXRef-DocumentRoot-Unknown-", "spdxElementId": "SPDXRef-DocumentRoot-Unknown-",
"relatedSpdxElement": "SPDXRef-Package-files-analyzed-true-035066c2086b8bb4", "relatedSpdxElement": "SPDXRef-Package-files-analyzed-true-716e193286ab5f0a",
"relationshipType": "CONTAINS" "relationshipType": "CONTAINS"
}, },
{ {

View File

@ -1,6 +1,7 @@
package binary package binary
import ( import (
"runtime"
"testing" "testing"
"github.com/anchore/syft/syft/pkg/cataloger/internal/pkgtest" "github.com/anchore/syft/syft/pkg/cataloger/internal/pkgtest"
@ -8,8 +9,9 @@ import (
func Test_JavaBinaryImage(t *testing.T) { func Test_JavaBinaryImage(t *testing.T) {
tests := []struct { tests := []struct {
image string image string
expected []string expected []string
skipOnArch string // skip test when running on this architecture (e.g., "arm64")
}{ }{
{ {
image: "image-java-binary", image: "image-java-binary",
@ -25,12 +27,14 @@ func Test_JavaBinaryImage(t *testing.T) {
expected: []string{ expected: []string{
"zulu @ 1.8.0_462-b08 (/usr/lib/jvm/zulu8-ca-amd64/bin/jdb)", "zulu @ 1.8.0_462-b08 (/usr/lib/jvm/zulu8-ca-amd64/bin/jdb)",
}, },
skipOnArch: "arm64", // image uses amd64-specific paths
}, },
{ {
image: "image-java-zulu-21", image: "image-java-zulu-21",
expected: []string{ expected: []string{
"zulu @ 21.0.8+9-LTS (/usr/lib/jvm/zulu21-ca-amd64/bin/java)", "zulu @ 21.0.8+9-LTS (/usr/lib/jvm/zulu21-ca-amd64/bin/java)",
}, },
skipOnArch: "arm64", // image uses amd64-specific paths
}, },
{ {
image: "image-java-ibm-8", image: "image-java-ibm-8",
@ -43,6 +47,7 @@ func Test_JavaBinaryImage(t *testing.T) {
expected: []string{ expected: []string{
"java @ 1.8.0-_2025_04_14_02_37-b00 (/opt/ibm/java/jre/bin/java)", "java @ 1.8.0-_2025_04_14_02_37-b00 (/opt/ibm/java/jre/bin/java)",
}, },
skipOnArch: "arm64", // base image has no arm64 manifest
}, },
{ {
image: "image-java-ibm-sdk-8", image: "image-java-ibm-sdk-8",
@ -54,6 +59,9 @@ func Test_JavaBinaryImage(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.image, func(t *testing.T) { t.Run(tt.image, func(t *testing.T) {
if tt.skipOnArch != "" && runtime.GOARCH == tt.skipOnArch {
t.Skipf("skipping test on %s architecture", tt.skipOnArch)
}
c := NewClassifierCataloger(ClassifierCatalogerConfig{ c := NewClassifierCataloger(ClassifierCatalogerConfig{
Classifiers: defaultJavaClassifiers(), Classifiers: defaultJavaClassifiers(),
}) })

View File

@ -237,6 +237,7 @@ func TestParseJar(t *testing.T) {
"net.bytebuddy.jar.asm", "net.bytebuddy.jar.asm",
"net.bytebuddy.jar.asm.commons", "net.bytebuddy.jar.asm.commons",
"net.bytebuddy.jar.asm.signature", "net.bytebuddy.jar.asm.signature",
"net.bytebuddy.jar.asmjdkbridge",
"net.bytebuddy.matcher", "net.bytebuddy.matcher",
"net.bytebuddy.pool", "net.bytebuddy.pool",
"net.bytebuddy.utility", "net.bytebuddy.utility",
@ -431,6 +432,7 @@ func TestParseJar(t *testing.T) {
"net.bytebuddy.jar.asm", "net.bytebuddy.jar.asm",
"net.bytebuddy.jar.asm.commons", "net.bytebuddy.jar.asm.commons",
"net.bytebuddy.jar.asm.signature", "net.bytebuddy.jar.asm.signature",
"net.bytebuddy.jar.asmjdkbridge",
"net.bytebuddy.matcher", "net.bytebuddy.matcher",
"net.bytebuddy.pool", "net.bytebuddy.pool",
"net.bytebuddy.utility", "net.bytebuddy.utility",

View File

@ -25,6 +25,9 @@ configs: # AUTO-GENERATED - config structs and their fields
- key: ResolveTransitiveDependencies - key: ResolveTransitiveDependencies
description: ResolveTransitiveDependencies enables resolving transitive dependencies for java packages found within archives. description: ResolveTransitiveDependencies enables resolving transitive dependencies for java packages found within archives.
app_key: java.resolve-transitive-dependencies app_key: java.resolve-transitive-dependencies
- key: DetectContainedPackages
description: DetectContainedPackages enables collecting all package names contained in a jar.
app_key: java.detect-contained-packages
catalogers: catalogers:
- ecosystem: java # MANUAL - ecosystem: java # MANUAL
name: java-archive-cataloger # AUTO-GENERATED name: java-archive-cataloger # AUTO-GENERATED

View File

@ -39,6 +39,7 @@ func Test_parseTarWrappedJavaArchive(t *testing.T) {
expected: []string{ expected: []string{
"example-java-app-maven", "example-java-app-maven",
"joda-time", "joda-time",
"byte-buddy",
}, },
}, },
} }