Skip to content

Commit

Permalink
Don't log skipping rules as errors (mindersec#1658)
Browse files Browse the repository at this point in the history
Commit 0ef1926 added logging for
remediation and alert levels, but it turns out that we would even log
skipped remediations and alerts as errors which made the logs very
spammy.

Let's fix all but fatal errors.
  • Loading branch information
jhrozek authored Nov 15, 2023
1 parent 7c5836e commit d8c9ae8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions internal/engine/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,22 @@ func logEval(
evalLog.Err(params.GetEvalErr()).Msg("result - evaluation")

// log remediation
logger.Err(params.GetActionsErr().RemediateErr).
logger.Err(filterActionErrorForLogging(params.GetActionsErr().RemediateErr)).
Str("action", "remediate").
Str("action_status", string(evalerrors.ErrorAsRemediationStatus(params.GetActionsErr().RemediateErr))).
Msg("result - action")

// log alert
logger.Err(params.GetActionsErr().AlertErr).
logger.Err(filterActionErrorForLogging(params.GetActionsErr().AlertErr)).
Str("action", "alert").
Str("action_status", string(evalerrors.ErrorAsAlertStatus(params.GetActionsErr().AlertErr))).
Msg("result - action")
}

func filterActionErrorForLogging(err error) error {
if evalerrors.IsActionFatalError(err) {
return err
}

return nil
}

0 comments on commit d8c9ae8

Please sign in to comment.