From f1430805d85089c1f8db31ac3e71adbfe47466f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Meira?= Date: Thu, 29 Aug 2024 09:27:40 +0100 Subject: [PATCH] fix: Use new flag for vulnerability type See https://github.com/aquasecurity/trivy/pull/7104 --- internal/tool/tool.go | 8 ++++---- internal/tool/tool_test.go | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) 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)