Skip to content

Commit

Permalink
✨ add specific score type for snoozed checks (#1558)
Browse files Browse the repository at this point in the history
* ✨ add specific score type for snoozed checks

Signed-off-by: Ivan Milchev <[email protected]>

* handle snoozed for type labels

Signed-off-by: Ivan Milchev <[email protected]>

---------

Signed-off-by: Ivan Milchev <[email protected]>
  • Loading branch information
imilchev authored Jan 29, 2025
1 parent 0b7f7e6 commit be70b2b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions policy/executor/internal/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,10 @@ func (nodeData *ReportingJobNodeData) score() (*policy.Score, error) {
if c.impact.GetScoring() == explorer.ScoringSystem_DISABLED {
s.Type = policy.ScoreType_Disabled
} else if s.Type == policy.ScoreType_Result {
// If the impact is ignore, then the score type should be Snoozed
if c.impact.GetScoring() == explorer.ScoringSystem_IGNORE_SCORE {
s.Type = policy.ScoreType_Snoozed
}
// We cant just forward the score if impact is set and we have a result.
// We still need to apply impact to the score
if c.impact != nil {
Expand Down
9 changes: 9 additions & 0 deletions policy/resolved_policy_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,15 @@ func (b *resolvedPolicyBuilder) gatherGlobalInfoFromPolicy(policy *Policy) {
action := normalizeAction(g.Type, c.Action, impact)
if action != explorer.Action_UNSPECIFIED && action != explorer.Action_MODIFY {
actions[c.Mrn] = action

// If the action is ignore, then the check is snoozed
if action == explorer.Action_IGNORE {
if impact == nil {
impact = &explorer.Impact{}
}
impact.Scoring = explorer.ScoringSystem_IGNORE_SCORE
impact.Action = explorer.Action_IGNORE
}
}

if impact != nil {
Expand Down
3 changes: 3 additions & 0 deletions policy/score.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const (
ScoreType_Unscored
ScoreType_OutOfScope
ScoreType_Disabled
ScoreType_Snoozed
)

// TypeLabel prints the score's type in a human-readable way
Expand All @@ -35,6 +36,8 @@ func (s *Score) TypeLabel() string {
return "out of scope"
case ScoreType_Disabled:
return "disabled"
case ScoreType_Snoozed:
return "snoozed"
default:
return "unknown type"
}
Expand Down

0 comments on commit be70b2b

Please sign in to comment.