print missing "AS" values as empty strings instead of "0 " (#1867)
This commit is contained in:
parent
b0889d7751
commit
3beb84bcfe
6 changed files with 17 additions and 6 deletions
|
@ -65,7 +65,7 @@ func AlertsToTable(alerts *models.GetAlertsResponse, printMachine bool) error {
|
|||
*alertItem.Source.Value,
|
||||
*alertItem.Scenario,
|
||||
alertItem.Source.Cn,
|
||||
alertItem.Source.AsNumber + " " + alertItem.Source.AsName,
|
||||
alertItem.Source.GetAsNumberName(),
|
||||
DecisionsFromAlert(alertItem),
|
||||
*alertItem.StartAt,
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ func alertsTable(out io.Writer, alerts *models.GetAlertsResponse, printMachine b
|
|||
displayVal,
|
||||
*alertItem.Scenario,
|
||||
alertItem.Source.Cn,
|
||||
alertItem.Source.AsNumber + " " + alertItem.Source.AsName,
|
||||
alertItem.Source.GetAsNumberName(),
|
||||
DecisionsFromAlert(alertItem),
|
||||
*alertItem.StartAt,
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ func DecisionsToTable(alerts *models.GetAlertsResponse, printMachine bool) error
|
|||
*decisionItem.Scenario,
|
||||
*decisionItem.Type,
|
||||
alertItem.Source.Cn,
|
||||
alertItem.Source.AsNumber + " " + alertItem.Source.AsName,
|
||||
alertItem.Source.GetAsNumberName(),
|
||||
fmt.Sprintf("%d", *alertItem.EventsCount),
|
||||
*decisionItem.Duration,
|
||||
fmt.Sprintf("%t", *decisionItem.Simulated),
|
||||
|
|
|
@ -29,7 +29,7 @@ func decisionsTable(out io.Writer, alerts *models.GetAlertsResponse, printMachin
|
|||
*decisionItem.Scenario,
|
||||
*decisionItem.Type,
|
||||
alertItem.Source.Cn,
|
||||
alertItem.Source.AsNumber + " " + alertItem.Source.AsName,
|
||||
alertItem.Source.GetAsNumberName(),
|
||||
strconv.Itoa(int(*alertItem.EventsCount)),
|
||||
*decisionItem.Duration,
|
||||
strconv.Itoa(int(alertItem.ID)),
|
||||
|
|
|
@ -63,3 +63,14 @@ func (s Source) GetScope() string {
|
|||
}
|
||||
return *s.Scope
|
||||
}
|
||||
|
||||
func (s Source) GetAsNumberName() string {
|
||||
ret := ""
|
||||
if s.AsNumber != "0" {
|
||||
ret += s.AsNumber
|
||||
}
|
||||
if s.AsName != "" {
|
||||
ret += " " + s.AsName
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
|
|
@ -58,11 +58,11 @@ teardown() {
|
|||
|
||||
run -0 cscli alerts list -o raw
|
||||
assert_line "id,scope,value,reason,country,as,decisions,created_at"
|
||||
assert_line --regexp ".*,Ip,10.20.30.40,manual 'ban' from 'githubciXXXXXXXXXXXXXXXXXXXXXXXX([a-zA-Z0-9]{16})?',,\" \",ban:1,.*"
|
||||
assert_line --regexp ".*,Ip,10.20.30.40,manual 'ban' from 'githubciXXXXXXXXXXXXXXXXXXXXXXXX([a-zA-Z0-9]{16})?',,,ban:1,.*"
|
||||
|
||||
run -0 cscli alerts list -o raw --machine
|
||||
assert_line "id,scope,value,reason,country,as,decisions,created_at,machine"
|
||||
assert_line --regexp "^[0-9]+,Ip,10.20.30.40,manual 'ban' from 'githubciXXXXXXXXXXXXXXXXXXXXXXXX([a-zA-Z0-9]{16})?',,\" \",ban:1,.*,githubciXXXXXXXXXXXXXXXXXXXXXXXX([a-zA-Z0-9]{16})?$"
|
||||
assert_line --regexp "^[0-9]+,Ip,10.20.30.40,manual 'ban' from 'githubciXXXXXXXXXXXXXXXXXXXXXXXX([a-zA-Z0-9]{16})?',,,ban:1,.*,githubciXXXXXXXXXXXXXXXXXXXXXXXX([a-zA-Z0-9]{16})?$"
|
||||
}
|
||||
|
||||
@test "cscli alerts inspect" {
|
||||
|
|
Loading…
Reference in a new issue