diff --git a/internal/tool/tool.go b/internal/tool/tool.go index 8e170ec..aa87c8e 100644 --- a/internal/tool/tool.go +++ b/internal/tool/tool.go @@ -95,6 +95,10 @@ func (t codacyTrivy) runVulnerabilityScanning(ctx context.Context, toolExecution SkipDBUpdate: true, SkipJavaDBUpdate: true, }, + PackageOptions: flag.PackageOptions{ + // Only scan libraries not OS packages. + PkgTypes: []string{types.PkgTypeLibrary}, + }, ReportOptions: flag.ReportOptions{ // Listing all packages will allow to obtain the line number of a vulnerability. ListAllPkgs: true, @@ -107,10 +111,6 @@ func (t codacyTrivy) runVulnerabilityScanning(ctx context.Context, toolExecution // Then filter issues from files that were not supposed to be analysed. Target: toolExecution.SourceDir, }, - VulnerabilityOptions: flag.VulnerabilityOptions{ - // Only scan libraries not OS packages. - VulnType: []types.VulnType{types.VulnTypeLibrary}, - }, } runner, err := t.runnerFactory.NewRunner(ctx, config) diff --git a/internal/tool/tool_test.go b/internal/tool/tool_test.go index 0c076d4..57df35c 100644 --- a/internal/tool/tool_test.go +++ b/internal/tool/tool_test.go @@ -60,6 +60,9 @@ func TestRun(t *testing.T) { SkipDBUpdate: true, SkipJavaDBUpdate: true, }, + PackageOptions: flag.PackageOptions{ + PkgTypes: []string{types.PkgTypeLibrary}, + }, ReportOptions: flag.ReportOptions{ ListAllPkgs: true, }, @@ -68,9 +71,6 @@ func TestRun(t *testing.T) { Scanners: types.Scanners{types.VulnerabilityScanner}, Target: sourceDir, }, - VulnerabilityOptions: flag.VulnerabilityOptions{ - VulnType: []types.VulnType{types.VulnTypeLibrary}, - }, } report := types.Report{ @@ -293,6 +293,9 @@ func TestRunScanFilesystemError(t *testing.T) { SkipDBUpdate: true, SkipJavaDBUpdate: true, }, + PackageOptions: flag.PackageOptions{ + PkgTypes: []string{types.PkgTypeLibrary}, + }, ReportOptions: flag.ReportOptions{ ListAllPkgs: true, }, @@ -301,9 +304,6 @@ func TestRunScanFilesystemError(t *testing.T) { Scanners: types.Scanners{types.VulnerabilityScanner}, Target: sourceDir, }, - VulnerabilityOptions: flag.VulnerabilityOptions{ - VulnType: []types.VulnType{types.VulnTypeLibrary}, - }, } mockRunner := NewMockRunner(ctrl)