From 6f5be562d35af50b404f63068b9b1ffcd953b882 Mon Sep 17 00:00:00 2001 From: Mark Frost Date: Wed, 30 Aug 2023 15:43:24 +0100 Subject: [PATCH] jar: add integration test for corrupt jar file Signed-off-by: Mark Frost --- java/packagescanner_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/java/packagescanner_test.go b/java/packagescanner_test.go index 08ef84179..9963115fe 100644 --- a/java/packagescanner_test.go +++ b/java/packagescanner_test.go @@ -17,6 +17,26 @@ func TestScan(t *testing.T) { defer done() t.Run(path.Base(tinkerpop.Name), tinkerpop.Run(ctx)) t.Run(path.Base(jenkins.Name), jenkins.RunSubset(ctx, 226)) + t.Run(path.Base(db2CorruptJar.Name), db2CorruptJar.RunSubset(ctx, 184)) +} + +var db2CorruptJar = test.ScannerTestcase{ + Domain: "docker.io", + Name: "ibmcom/db2", + Hash: "sha256:52c13866cd8bb6811be5ea51605f7d7777a666a3fde9beab03ee088e556fd142", + // Layer contains a corrupt jar file which should be skipped harmlessly: + // /opt/ibm/db2/V11.1/samples/repl/xmlpubtk/loadqueue/LoadQueue.jar + // Want is just one arbitrary other jar to prove the scan does not have a fatal error + Want: []*claircore.Package{ + { + Name: "com.ibm.db2.jcc", + Version: "1.4.0", + Kind: "binary", + PackageDB: "jar:opt/ibm/db2/V11.5/db2tss/lib/db2jcc4.jar", + RepositoryHint: "sha1:902856c6b9f979facc6f75fad40da6b048df5df8", + }, + }, + Scanner: &java.Scanner{}, } var tinkerpop = test.ScannerTestcase{