Skip to content

Commit

Permalink
fix: updates report_url path
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwiniag committed Oct 16, 2024
1 parent e1c7b22 commit 77acf2d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/api/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func runScan(scanID string, image string, severity string, publishTarget string,
log.Printf("Error scanning image: %v", err)
updateScanStatus(scanID, StatusFailed)
// TODO: Save the error result
_, err := saveScanStatus(scanID, string(StatusFailed), nil, "", 0)
_, err := saveScanStatus(scanID, string(StatusFailed), nil, "")
if err != nil {
log.Println("Error saving scan status", err)
return
Expand All @@ -139,7 +139,7 @@ func runScan(scanID string, image string, severity string, publishTarget string,
websiteConfig := websites[publishTarget]

// Save the scan result for future retrieval
_, err = saveScanStatus(scanID, string(StatusCompleted), reportFilePaths, websiteConfig.ConfiguredDomain, websiteConfig.Port)
_, err = saveScanStatus(scanID, string(StatusCompleted), reportFilePaths, websiteConfig.ConfiguredDomain)
if err != nil {
log.Println("Error saving scan status", err)
return
Expand All @@ -148,13 +148,13 @@ func runScan(scanID string, image string, severity string, publishTarget string,
// ToDo: save the report if visibility=private|public and status=completed
}

func saveScanStatus(scanID, status string, reportFilePaths []string, configuredDomain string, port int) ([]string, error) {
func saveScanStatus(scanID, status string, reportFilePaths []string, configuredDomain string) ([]string, error) {
resultFilePath := fmt.Sprintf("/tmp/%s.json", scanID)
// Build the report URLs for each saved report
var reportURLs []string
for _, filePath := range reportFilePaths {
// Generate the URL from hostname, port, and the file path
reportURL := fmt.Sprintf("https://%s:%d/reports/%s", configuredDomain, port, filepath.Base(filePath))
reportURL := fmt.Sprintf("https://%s/reports/%s", configuredDomain, filepath.Base(filePath))
reportURLs = append(reportURLs, reportURL)
}
// Build the scan result
Expand Down

0 comments on commit 77acf2d

Please sign in to comment.