@@ -15,7 +15,6 @@ import (
1515 "github.com/aquasecurity/trivy/pkg/fanal/analyzer/language"
1616 "github.com/aquasecurity/trivy/pkg/fanal/types"
1717 "github.com/aquasecurity/trivy/pkg/javadb"
18- "github.com/aquasecurity/trivy/pkg/log"
1918 "github.com/aquasecurity/trivy/pkg/parallel"
2019)
2120
@@ -34,8 +33,7 @@ var requiredExtensions = []string{
3433
3534// javaLibraryAnalyzer analyzes jar/war/ear/par files
3635type javaLibraryAnalyzer struct {
37- client * javadb.DB
38- slow bool
36+ slow bool
3937}
4038
4139func newJavaLibraryAnalyzer (options analyzer.AnalyzerOptions ) (analyzer.PostAnalyzer , error ) {
@@ -46,23 +44,20 @@ func newJavaLibraryAnalyzer(options analyzer.AnalyzerOptions) (analyzer.PostAnal
4644
4745func (a * javaLibraryAnalyzer ) PostAnalyze (ctx context.Context , input analyzer.PostAnalysisInput ) (* analyzer.AnalysisResult , error ) {
4846 // TODO: think about the sonatype API and "--offline"
49- var err error
50- log .Logger .Info ("JAR files found" )
51- a .client , err = javadb .NewClient ()
47+ client , err := javadb .NewClient ()
5248 if err != nil {
5349 return nil , xerrors .Errorf ("Unable to initialize the Java DB: %s" , err )
5450 }
55- defer func () { _ = a .client .Close () }()
56- log .Logger .Info ("Analyzing JAR files takes a while..." )
51+ defer func () { _ = client .Close () }()
5752
5853 // Skip analyzing JAR files as the nil client means the Java DB was not downloaded successfully.
59- if a . client == nil {
54+ if client == nil {
6055 return nil , nil
6156 }
6257
6358 // It will be called on each JAR file
6459 onFile := func (path string , info fs.FileInfo , r dio.ReadSeekerAt ) (* types.Application , error ) {
65- p := jar .NewParser (a . client , jar .WithSize (info .Size ()), jar .WithFilePath (path ))
60+ p := jar .NewParser (client , jar .WithSize (info .Size ()), jar .WithFilePath (path ))
6661 return language .ParsePackage (types .Jar , path , r , p , input .Options .FileChecksum )
6762 }
6863
0 commit comments