Skip to content

Commit 34bf4b0

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

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

java/packagescanner.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -227,20 +227,22 @@ func (s *Scanner) Scan(ctx context.Context, layer *claircore.Layer) ([]*claircor
227227
// claircore.Package mapping code around embedded jars. There's a
228228
// testcase to be written, there.
229229

230+
idx := strings.LastIndex(i.Source, ":")
231+
// Use the source as the package DB.
232+
pkgDB := i.Source[:idx]
230233
// Only examine the last element of the source list:
231-
js := strings.Split(i.Source, ":")
232-
switch l := js[len(js)-1]; {
234+
switch l := i.Source[idx+1:]; {
233235
case strings.HasSuffix(l, "pom.properties"):
234236
fallthrough
235237
case s.root != nil && i.Source == s.root.String():
236238
// Populate as a maven artifact.
237-
pkg.PackageDB = `maven:` + n
239+
pkg.PackageDB = `maven:` + pkgDB
238240
case l == "META-INF/MANIFEST.MF":
239241
// information pulled from a manifest file
240-
pkg.PackageDB = `jar:` + n
242+
pkg.PackageDB = `jar:` + pkgDB
241243
case l == ".":
242244
// Name guess.
243-
pkg.PackageDB = `file:` + n
245+
pkg.PackageDB = `file:` + pkgDB
244246
default:
245247
return nil, fmt.Errorf("java: martian Info: %+v", i)
246248
}

0 commit comments

Comments
 (0)