This commit is contained in:
Thibault "bui" Koechlin 2021-12-22 15:45:41 +01:00 committed by GitHub
parent 64d8c0357b
commit 6b13d73fca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -34,6 +34,7 @@ var (
func DecisionsToTable(alerts *models.GetAlertsResponse) error {
/*here we cheat a bit : to make it more readable for the user, we dedup some entries*/
var spamLimit map[string]bool = make(map[string]bool)
var skipped = 0
/*process in reverse order to keep the latest item only*/
for aIdx := len(*alerts) - 1; aIdx >= 0; aIdx-- {
@ -42,6 +43,7 @@ func DecisionsToTable(alerts *models.GetAlertsResponse) error {
for _, decisionItem := range alertItem.Decisions {
spamKey := fmt.Sprintf("%t:%s:%s:%s", *decisionItem.Simulated, *decisionItem.Type, *decisionItem.Scope, *decisionItem.Value)
if _, ok := spamLimit[spamKey]; ok {
skipped++
continue
}
spamLimit[spamKey] = true
@ -100,6 +102,9 @@ func DecisionsToTable(alerts *models.GetAlertsResponse) error {
}
}
table.Render() // Send output
if skipped > 0 {
fmt.Printf("%d duplicated entries skipped\n", skipped)
}
}
return nil
}