Skip to content

Commit 9043f34

Browse files
authored
fix: cloud uploads on diff scans (#1327)
* fix: cloud uploads on diff scans * fix: remove unused flag
1 parent d1c350a commit 9043f34

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

internal/commands/artifact/run.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ func (r *runner) Report(
380380
if err != nil {
381381
return false, err
382382
}
383+
reportoutput.UploadReportToCloud(reportData, r.scanSettings)
383384

384385
endTime := time.Now()
385386

internal/report/output/output.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/google/uuid"
1010
"github.com/hhatto/gocloc"
1111
"golang.org/x/exp/maps"
12+
"golang.org/x/exp/slices"
1213

1314
"github.com/bearer/bearer/internal/commands/process/settings"
1415
"github.com/bearer/bearer/internal/flag"
@@ -52,19 +53,15 @@ func GetData(
5253
}
5354

5455
// add report-specific items
55-
attemptCloudUpload := false
5656
switch config.Report.Report {
5757
case flag.ReportDataFlow:
5858
return data, err
5959
case flag.ReportSecurity:
60-
attemptCloudUpload = true
6160
err = security.AddReportData(data, config, baseBranchFindings)
6261
case flag.ReportSaaS:
6362
if err = security.AddReportData(data, config, baseBranchFindings); err != nil {
6463
return nil, err
6564
}
66-
67-
attemptCloudUpload = true
6865
err = saas.GetReport(data, config, false)
6966
case flag.ReportPrivacy:
7067
err = privacy.AddReportData(data, config)
@@ -74,15 +71,17 @@ func GetData(
7471
return nil, fmt.Errorf(`--report flag "%s" is not supported`, config.Report.Report)
7572
}
7673

77-
if attemptCloudUpload && config.Client != nil && config.Client.Error == nil {
78-
// send SaaS report to Cloud
79-
data.SendToCloud = true
80-
saas.SendReport(config, data)
81-
}
82-
8374
return data, err
8475
}
8576

77+
func UploadReportToCloud(report *types.ReportData, config settings.Config) {
78+
if slices.Contains([]string{flag.ReportSecurity, flag.ReportSaaS}, config.Report.Report) {
79+
if config.Client != nil && config.Client.Error == nil {
80+
saas.SendReport(config, report)
81+
}
82+
}
83+
}
84+
8685
func GetDataflow(reportData *types.ReportData, report globaltypes.Report, config settings.Config, isInternal bool) error {
8786
if reportData.Detectors == nil {
8887
if err := detectors.AddReportData(reportData, report, config); err != nil {

internal/report/output/types/types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010

1111
type ReportData struct {
1212
ReportFailed bool
13-
SendToCloud bool
1413
Files []string
1514
FoundLanguages []string
1615
Detectors []any

0 commit comments

Comments
 (0)