Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ add specific score type for snoozed checks #1558

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
imilchev marked this conversation as resolved.
Show resolved Hide resolved
)

// 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
Loading