Skip to content

Commit

Permalink
Fixed dashboard and html-report command bugs (#104)
Browse files Browse the repository at this point in the history
Invalid files cause the app to crash, so this fixes that. I found this while tinkering in a pipeline.

Signed-off-by: Dave Shanley <dshanley@splunk.com>
  • Loading branch information
daveshanley committed Jul 26, 2022
1 parent 716f925 commit 45b28d7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ func GetDashboardCommand() *cobra.Command {

var err error
vacuumReport, specBytes, _ := vacuum_report.BuildVacuumReportFromFile(args[0])
if len(specBytes) <= 0 {
pterm.Error.Printf("Failed to read specification: %v\n\n", args[0])
return err
}

var resultSet *model.RuleResultSet
var ruleset *motor.RuleSetExecutionResult
Expand All @@ -51,6 +55,7 @@ func GetDashboardCommand() *cobra.Command {
rulesetFlag, _ := cmd.Flags().GetString("ruleset")
resultSet, ruleset, err = BuildResults(rulesetFlag, specBytes, customFunctions)
if err != nil {
pterm.Error.Printf("Failed to render dashboard: %v\n\n", err)
return err
}
specIndex = ruleset.Index
Expand Down
6 changes: 6 additions & 0 deletions cmd/html_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ func GetHTMLReportCommand() *cobra.Command {
start := time.Now()
var err error
vacuumReport, specBytes, _ := vacuum_report.BuildVacuumReportFromFile(args[0])
if len(specBytes) <= 0 {
pterm.Error.Printf("Failed to read specification: %v\n\n", args[0])
return err
}

var resultSet *model.RuleResultSet
var ruleset *motor.RuleSetExecutionResult
Expand All @@ -70,10 +74,12 @@ func GetHTMLReportCommand() *cobra.Command {
rulesetFlag, _ := cmd.Flags().GetString("ruleset")
resultSet, ruleset, err = BuildResults(rulesetFlag, specBytes, customFunctions)
if err != nil {
pterm.Error.Printf("Failed to generate report: %v\n\n", err)
return err
}
specIndex = ruleset.Index
specInfo = ruleset.SpecInfo

specInfo.Generated = time.Now()
stats = statistics.CreateReportStatistics(specIndex, specInfo, resultSet)

Expand Down

0 comments on commit 45b28d7

Please sign in to comment.