Skip to content
Open
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
24 changes: 24 additions & 0 deletions pkg/apiserver/papi_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,30 @@ func AlertCmd(ctx context.Context, message *Message, p *Papi, sync bool) error {
}

log.Infof("Received order %s from PAPI (%d decisions)", alert.UUID, len(alert.Decisions))
decisionsToKeep := make([]*models.Decision, 0)
for _, decision := range alert.Decisions {
if decision.Value == nil {
continue
}
isAllowlisted, reason, err := p.DBClient.IsAllowlisted(ctx, *decision.Value)
if err != nil {
log.Errorf("Failed to check if decision '%s' is allowlisted: %s", *decision.Value, err)
// keep the decision in case of error during allowlist check
decisionsToKeep = append(decisionsToKeep, decision)
continue
}
if isAllowlisted {
log.Infof("Decision '%s' is allowlisted, removing it (%s)", *decision.Value, reason)
continue
}
decisionsToKeep = append(decisionsToKeep, decision)
}
alert.Decisions = decisionsToKeep

if len(alert.Decisions) == 0 {
log.Infof("All decisions are allowlisted for alert %s, skipping alert creation", alert.UUID)
return nil
}

/*Fix the alert with missing mandatory items*/
if alert.StartAt == nil || *alert.StartAt == "" {
Expand Down