diff --git a/internal/report/sbom/report.go b/internal/report/sbom/report.go index f3674cd9..09133b8f 100644 --- a/internal/report/sbom/report.go +++ b/internal/report/sbom/report.go @@ -29,16 +29,16 @@ type generateSbom struct { Email string `json:"email"` Branch string `json:"branch"` Locale string `json:"locale"` - Licenses bool `json:licenses` + Licenses bool `json:"licenses"` Vulnerabilities bool `json:"vulnerabilities"` - SendEmail bool `json:sendEmail` - VulnerabilityStatuses []string `json:vulnerabilityStatuses` + SendEmail bool `json:"sendEmail"` + VulnerabilityStatuses []string `json:"vulnerabilityStatuses"` } type generateSbomResponse struct { - Message string `json:message` - ReportUUID string `json:reportUuid` - Notes []string `json:notes` + Message string `json:"message"` + ReportUUID string `json:"reportUuid"` + Notes []string `json:"notes"` } type OrderArgs struct { diff --git a/internal/scan/scanner.go b/internal/scan/scanner.go index 67cf4679..2953021a 100644 --- a/internal/scan/scanner.go +++ b/internal/scan/scanner.go @@ -140,15 +140,14 @@ func (dScanner *DebrickedScanner) Scan(o IOptions) error { if failPipeline { return FailPipelineErr } - if dOptions.SBOM { - - return dScanner.scanReportSBOM(result.DetailsUrl, dOptions.BranchName) - } return nil } -func (dScanner *DebrickedScanner) scanReportSBOM(detailsURL, branch string) error { +func (dScanner *DebrickedScanner) scanReportSBOM(reportSBOM bool, detailsURL, branch string) error { + if !reportSBOM { + return nil + } reporter := sbom.Reporter{DebClient: *dScanner.client, FileWriter: io.FileWriter{}} repositoryID, commitID, err := reporter.ParseDetailsURL(detailsURL) if err != nil { @@ -272,6 +271,14 @@ func (dScanner *DebrickedScanner) scan(options DebrickedOptions, gitMetaObject g if err != nil { return nil, err } + err = dScanner.scanReportSBOM( + options.SBOM, + result.DetailsUrl, + options.BranchName, + ) + if err != nil { + return nil, err + } return result, nil } diff --git a/internal/scan/scanner_test.go b/internal/scan/scanner_test.go index 07b30b8d..15aa5c86 100644 --- a/internal/scan/scanner_test.go +++ b/internal/scan/scanner_test.go @@ -88,6 +88,7 @@ func TestScan(t *testing.T) { RepositoryName: repositoryName, CommitName: "commit", Fingerprint: false, + SBOM: false, BranchName: "", CommitAuthor: "", RepositoryUrl: "", @@ -151,6 +152,7 @@ func TestScanWithJsonPath(t *testing.T) { Exclusions: nil, RepositoryName: repositoryName, CommitName: "commit", + SBOM: false, BranchName: "", CommitAuthor: "", RepositoryUrl: "",