Skip to content

Commit

Permalink
Fix for pdf report not using default engines (#587)
Browse files Browse the repository at this point in the history
* fix for pdf report not using default engines

* fix for pdf report not using default engines

* Update one-scan.yml

* Update one-scan.yml

---------

Co-authored-by: Pedro Lopes <[email protected]>
  • Loading branch information
igorlombacx and pedrompflopes committed Oct 20, 2023
1 parent d6deb67 commit a04fa71
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions internal/commands/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -1110,11 +1110,11 @@ func exportSbomResults(sbomWrapper wrappers.ResultsSbomWrapper,
func exportPdfResults(pdfWrapper wrappers.ResultsPdfWrapper, summary *wrappers.ResultSummary, summaryRpt, formatPdfToEmail, pdfOptions string) error {
pdfReportsPayload := &wrappers.PdfReportsPayload{}
pollingResp := &wrappers.PdfPollingResponse{}

pdfOptionsSections, pdfOptionsEngines, err := validatePdfOptions(pdfOptions)
pdfOptionsSections, pdfOptionsEngines, err := parsePDFOptions(pdfOptions, summary.EnginesEnabled)
if err != nil {
return err
}

pdfReportsPayload.ReportName = reportNameScanReport
pdfReportsPayload.ReportType = "cli"
pdfReportsPayload.FileFormat = printer.FormatPDF
Expand Down Expand Up @@ -1179,7 +1179,7 @@ func validateSbomOptions(sbomOption string) (string, error) {
return "", errors.Errorf("invalid SBOM option: %s", sbomOption)
}

func validatePdfOptions(pdfOptions string) (pdfOptionsSections, pdfOptionsEngines []string, err error) {
func parsePDFOptions(pdfOptions string, enabledEngines []string) (pdfOptionsSections, pdfOptionsEngines []string, err error) {
var pdfOptionsSectionsMap = map[string]string{
"scansummary": "ScanSummary",
"executivesummary": "ExecutiveSummary",
Expand All @@ -1202,6 +1202,13 @@ func validatePdfOptions(pdfOptions string) (pdfOptionsSections, pdfOptionsEngine
return nil, nil, errors.Errorf("report option \"%s\" unavailable", s)
}
}
if pdfOptionsEngines == nil {
for _, engine := range enabledEngines {
if pdfOptionsEnginesMap[engine] != "" {
pdfOptionsEngines = append(pdfOptionsEngines, pdfOptionsEnginesMap[engine])
}
}
}
return pdfOptionsSections, pdfOptionsEngines, nil
}

Expand Down

0 comments on commit a04fa71

Please sign in to comment.