Skip to content

Commit

Permalink
feat(saas): upload the results of failed scan servers
Browse files Browse the repository at this point in the history
  • Loading branch information
MaineK00n committed Jul 28, 2022
1 parent 2907a89 commit a9de1ff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 28 deletions.
9 changes: 1 addition & 8 deletions subcmds/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,11 @@ func (p *ReportCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}
logging.Log.Infof("Loaded: %s", dir)

var res models.ScanResults
hasError := false
for _, r := range loaded {
if len(r.Errors) == 0 {
res = append(res, r)
} else {
logging.Log.Errorf("Ignored since errors occurred during scanning: %s, err: %v",
r.ServerName, r.Errors)
hasError = true
logging.Log.Errorf("Ignored since errors occurred during scanning: %s, err: %v", r.ServerName, r.Errors)
}
}

Expand Down Expand Up @@ -361,9 +358,5 @@ func (p *ReportCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}
}
}

if hasError {
return subcommands.ExitFailure
}

return subcommands.ExitSuccess
}
22 changes: 2 additions & 20 deletions subcmds/saas.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/future-architect/vuls/config"
"github.com/future-architect/vuls/logging"
"github.com/future-architect/vuls/models"
"github.com/future-architect/vuls/reporter"
"github.com/future-architect/vuls/saas"
"github.com/google/subcommands"
Expand Down Expand Up @@ -81,25 +80,12 @@ func (p *SaaSCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{})
return subcommands.ExitUsageError
}

var loaded models.ScanResults
if loaded, err = reporter.LoadScanResults(dir); err != nil {
res, err := reporter.LoadScanResults(dir)
if err != nil {
logging.Log.Error(err)
return subcommands.ExitFailure
}
logging.Log.Infof("Loaded: %s", dir)

var res models.ScanResults
hasError := false
for _, r := range loaded {
if len(r.Errors) == 0 {
res = append(res, r)
} else {
logging.Log.Errorf("Ignored since errors occurred during scanning: %s, err: %v",
r.ServerName, r.Errors)
hasError = true
}
}

if len(res) == 0 {
return subcommands.ExitFailure
}
Expand All @@ -121,10 +107,6 @@ func (p *SaaSCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{})
return subcommands.ExitFailure
}

if hasError {
return subcommands.ExitFailure
}

if !config.Conf.Debug {
if err := os.RemoveAll(dir); err != nil {
logging.Log.Warnf("Failed to remove %s. err: %+v", dir, err)
Expand Down

0 comments on commit a9de1ff

Please sign in to comment.