Skip to content

Commit

Permalink
cscli alerts list: sort remediation keys
Browse files Browse the repository at this point in the history
avoid printing
"ban: ... captcha: ..."
in one line, and
"captcha: ... ban: ..."
in another
  • Loading branch information
mmetc committed Jun 5, 2024
1 parent 37a0a98 commit 468172d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/crowdsec-cli/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"

"github.com/crowdsecurity/go-cs-lib/maptools"

"github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/require"
"github.com/crowdsecurity/crowdsec/pkg/apiclient"
"github.com/crowdsecurity/crowdsec/pkg/cwversion"
Expand All @@ -41,12 +43,12 @@ func DecisionsFromAlert(alert *models.Alert) string {
decMap[k] = v + 1
}

for k, v := range decMap {
for _, key := range maptools.SortedKeys(decMap) {
if len(ret) > 0 {
ret += " "
}

ret += fmt.Sprintf("%s:%d", k, v)
ret += fmt.Sprintf("%s:%d", key, decMap[key])
}

return ret
Expand Down

0 comments on commit 468172d

Please sign in to comment.