Skip to content

Commit 6b98f23

Browse files
committed
java: include inner JAR paths in PackageDB
Signed-off-by: RTann <[email protected]> rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED
1 parent f5a19a4 commit 6b98f23

File tree

3 files changed

+225
-220
lines changed

3 files changed

+225
-220
lines changed

java/packagescanner.go

+10-5
Original file line numberDiff line numberDiff line change
@@ -238,20 +238,25 @@ func (s *Scanner) Scan(ctx context.Context, layer *claircore.Layer) ([]*claircor
238238
// claircore.Package mapping code around embedded jars. There's a
239239
// testcase to be written, there.
240240

241+
idx := strings.LastIndex(i.Source, ":")
242+
pkgDB := n
243+
if idx != -1 {
244+
// Use the source as the package DB.
245+
pkgDB = i.Source[:idx]
246+
}
241247
// Only examine the last element of the source list:
242-
js := strings.Split(i.Source, ":")
243-
switch l := js[len(js)-1]; {
248+
switch l := i.Source[idx+1:]; {
244249
case strings.HasSuffix(l, "pom.properties"):
245250
fallthrough
246251
case s.root != nil && i.Source == s.root.String():
247252
// Populate as a maven artifact.
248-
pkg.PackageDB = `maven:` + n
253+
pkg.PackageDB = `maven:` + pkgDB
249254
case l == "META-INF/MANIFEST.MF":
250255
// information pulled from a manifest file
251-
pkg.PackageDB = `jar:` + n
256+
pkg.PackageDB = `jar:` + pkgDB
252257
case l == ".":
253258
// Name guess.
254-
pkg.PackageDB = `file:` + n
259+
pkg.PackageDB = `file:` + pkgDB
255260
default:
256261
return nil, fmt.Errorf("java: martian Info: %+v", i)
257262
}

0 commit comments

Comments
 (0)