Skip to content
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
3 changes: 2 additions & 1 deletion pkg/display/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,9 @@ func displayReport(report *models.Report, stats *models.ReportStats, withIPs boo
rd.PrintRow("Number of IPs", strconv.Itoa(len(report.IPs)), keyStyle, valueStyle)

knownIPPercent := float64(stats.NbIPs-stats.NbUnknownIPs) / float64(stats.NbIPs) * 100
ipsInBlocklistPercent := float64(stats.IPsBlockedByBlocklist) / float64(stats.NbIPs) * 100
rd.PrintRow("Number of known IPs", fmt.Sprintf("%d (%.0f%%)", stats.NbIPs-stats.NbUnknownIPs, knownIPPercent), keyStyle, GetPercentKnownColor(valueStyle, knownIPPercent))

rd.PrintRow("Number of IPs in Blocklist", fmt.Sprintf("%d (%.0f%%)", stats.IPsBlockedByBlocklist, ipsInBlocklistPercent), keyStyle, GetPercentKnownColor(valueStyle, knownIPPercent))
PrintSection(sectionStyle, "Stats")

topWriter := tabwriter.NewWriter(os.Stdout, 0, 8, 10, '\t', tabwriter.AlignRight)
Expand Down
23 changes: 12 additions & 11 deletions pkg/models/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ type Report struct {
}

type ReportStats struct {
NbIPs int
TopReputation map[string]int
TopBehaviors map[string]int
TopClassifications map[string]int
TopCountries map[string]int
TopCVEs map[string]int
TopAS map[string]int
TopIPRange map[string]int
TopBlocklists map[string]int
NbUnknownIPs int
AverageBNScore float64
NbIPs int
TopReputation map[string]int
TopBehaviors map[string]int
TopClassifications map[string]int
TopCountries map[string]int
TopCVEs map[string]int
TopAS map[string]int
TopIPRange map[string]int
TopBlocklists map[string]int
NbUnknownIPs int
AverageBNScore float64
IPsBlockedByBlocklist int
}
24 changes: 13 additions & 11 deletions pkg/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ import (

func GetIPsStats(ips []*cticlient.SmokeItem) *models.ReportStats {
stats := &models.ReportStats{
NbIPs: 0,
NbUnknownIPs: 0,
TopReputation: make(map[string]int, 0),
TopBehaviors: make(map[string]int, 0),
TopClassifications: make(map[string]int, 0),
TopCountries: make(map[string]int, 0),
TopAS: make(map[string]int, 0),
TopCVEs: make(map[string]int, 0),
TopIPRange: make(map[string]int, 0),
TopBlocklists: make(map[string]int, 0),
AverageBNScore: 0.0,
NbIPs: 0,
NbUnknownIPs: 0,
TopReputation: make(map[string]int, 0),
TopBehaviors: make(map[string]int, 0),
TopClassifications: make(map[string]int, 0),
TopCountries: make(map[string]int, 0),
TopAS: make(map[string]int, 0),
TopCVEs: make(map[string]int, 0),
TopIPRange: make(map[string]int, 0),
TopBlocklists: make(map[string]int, 0),
AverageBNScore: 0.0,
IPsBlockedByBlocklist: 0,
}
sumBNScore := 0

Expand Down Expand Up @@ -89,6 +90,7 @@ func GetIPsStats(ips []*cticlient.SmokeItem) *models.ReportStats {
}
stats.TopBlocklists[blocklist.Label] += 1
}
stats.IPsBlockedByBlocklist += 1
}

if len(ip.CVEs) > 0 {
Expand Down