Skip to content

Commit

Permalink
fix: cloud uploads on diff scans
Browse files Browse the repository at this point in the history
  • Loading branch information
elsapet committed Oct 13, 2023
1 parent a816913 commit 2b9a1e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions internal/commands/artifact/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ func (r *runner) Report(
if err != nil {
return false, err
}
reportoutput.UploadReportToCloud(reportData, r.scanSettings)

endTime := time.Now()

Expand Down
21 changes: 11 additions & 10 deletions internal/report/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/google/uuid"
"github.com/hhatto/gocloc"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"

"github.com/bearer/bearer/internal/commands/process/settings"
"github.com/bearer/bearer/internal/flag"
Expand Down Expand Up @@ -52,19 +53,15 @@ func GetData(
}

// add report-specific items
attemptCloudUpload := false
switch config.Report.Report {
case flag.ReportDataFlow:
return data, err
case flag.ReportSecurity:
attemptCloudUpload = true
err = security.AddReportData(data, config, baseBranchFindings)
case flag.ReportSaaS:
if err = security.AddReportData(data, config, baseBranchFindings); err != nil {
return nil, err
}

attemptCloudUpload = true
err = saas.GetReport(data, config, false)
case flag.ReportPrivacy:
err = privacy.AddReportData(data, config)
Expand All @@ -74,15 +71,19 @@ func GetData(
return nil, fmt.Errorf(`--report flag "%s" is not supported`, config.Report.Report)
}

if attemptCloudUpload && config.Client != nil && config.Client.Error == nil {
// send SaaS report to Cloud
data.SendToCloud = true
saas.SendReport(config, data)
}

return data, err
}

func UploadReportToCloud(report *types.ReportData, config settings.Config) {
if slices.Contains([]string{flag.ReportSecurity, flag.ReportSaaS}, config.Report.Report) {
if config.Client != nil && config.Client.Error == nil {
// send SaaS report to Cloud
report.SendToCloud = true
saas.SendReport(config, report)
}
}
}

func GetDataflow(reportData *types.ReportData, report globaltypes.Report, config settings.Config, isInternal bool) error {
if reportData.Detectors == nil {
if err := detectors.AddReportData(reportData, report, config); err != nil {
Expand Down

0 comments on commit 2b9a1e5

Please sign in to comment.