Skip to content

Commit

Permalink
fix(detectExecuteScan) Generate reports for project with no components (
Browse files Browse the repository at this point in the history
SAP#4905)

* fix(detectExecuteScan) Generate reports for project with no components

* Resolved merge conflicts
  • Loading branch information
andrew-kireev authored Apr 24, 2024
1 parent 7a3024c commit af28a72
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 49 deletions.
13 changes: 11 additions & 2 deletions cmd/detectExecuteScan.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,11 @@ func createVulnerabilityReport(config detectExecuteScanOptions, vulns *bd.Vulner
CounterHeader: "Entry#",
}

vulnItems := vulns.Items
var vulnItems []bd.Vulnerability
if vulns != nil {
vulnItems = vulns.Items
}

sort.Slice(vulnItems, func(i, j int) bool {
return vulnItems[i].OverallScore > vulnItems[j].OverallScore
})
Expand Down Expand Up @@ -716,7 +720,12 @@ func postScanChecksAndReporting(ctx context.Context, config detectExecuteScanOpt
errorsOccured := []string{}
vulns, err := getVulnerabilitiesWithComponents(config, influx, sys)
if err != nil {
return errors.Wrap(err, "failed to fetch vulnerabilities")
if config.GenerateReportsForEmptyProjects &&
strings.Contains(err.Error(), "No Components found for project version") {
log.Entry().Debug(err.Error())
} else {
return errors.Wrap(err, "failed to fetch vulnerabilities")
}
}

if config.CreateResultIssue && len(config.GithubToken) > 0 && len(config.GithubAPIURL) > 0 && len(config.Owner) > 0 && len(config.Repository) > 0 {
Expand Down
105 changes: 58 additions & 47 deletions cmd/detectExecuteScan_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions resources/metadata/detectExecuteScan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,15 @@ spec:
- STEPS
- STAGES
- PARAMETERS
- name: generateReportsForEmptyProjects
type: bool
default: false
description:
"If enabled, it will generate reports for empty projects. This could be useful to see the compliance reports in Sirius"
scope:
- STEPS
- STAGES
- PARAMETERS
- name: pomPath
type: string
description: Path to the pom file which should be installed including all children.
Expand Down

0 comments on commit af28a72

Please sign in to comment.