diff --git a/provider/internal/java/provider.go b/provider/internal/java/provider.go index b31f16aa..016346d5 100644 --- a/provider/internal/java/provider.go +++ b/provider/internal/java/provider.go @@ -200,6 +200,8 @@ func (p *javaProvider) Init(ctx context.Context, log logr.Logger, config provide config.Location = sourceLocation // for binaries, we fallback to looking at .jar files only for deps config.DependencyPath = depLocation + // for binaries, always run in source-only mode as we don't know how to correctly resolve deps + config.AnalysisMode = provider.SourceOnlyAnalysisMode isBinary = true } diff --git a/provider/internal/java/util.go b/provider/internal/java/util.go index ec929290..b947161e 100644 --- a/provider/internal/java/util.go +++ b/provider/internal/java/util.go @@ -122,9 +122,9 @@ func decompile(ctx context.Context, log logr.Logger, archivePath, projectPath st if _, err := io.Copy(dstFile, archiveFile); err != nil { return "", err } - - // If we found a class file, decompile it to java project path - if strings.HasSuffix(f.Name, ClassFile) { + switch { + // when it's a .class file, decompile it into java project + case strings.HasSuffix(f.Name, ClassFile): // full path in the java project for the decompd file destPath := filepath.Join( projectPath, "src", "main", "java", @@ -147,7 +147,8 @@ func decompile(ctx context.Context, log logr.Logger, archivePath, projectPath st } else { log.V(8).Info("decompiled file", "file", filePath) } - } else if strings.HasSuffix(f.Name, JavaArchive) || strings.HasSuffix(f.Name, WebArchive) { + // decompile web archives + case strings.HasSuffix(f.Name, WebArchive): if _, err := decompile(ctx, log, filePath, projectPath); err != nil { log.Error(err, "failed to decompile file", "file", filePath) }