Skip to content

Commit

Permalink
fix: Use new flag for vulnerability type
Browse files Browse the repository at this point in the history
  • Loading branch information
afsmeira committed Aug 29, 2024
1 parent 59c3446 commit f143080
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions internal/tool/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions internal/tool/tool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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{
Expand Down Expand Up @@ -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,
},
Expand All @@ -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)
Expand Down

0 comments on commit f143080

Please sign in to comment.