Skip to content

Commit e06d79a

Browse files
authored
Rename domainStatusclassifyFirewallDomainStatus and statusEmojifirewallStatusEmoji (#24712)
1 parent b513c07 commit e06d79a

5 files changed

Lines changed: 25 additions & 25 deletions

File tree

pkg/cli/audit_cross_run.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ func buildCrossRunAuditReport(inputs []crossRunInput) *CrossRunAuditReport {
229229
agg.totalBlocked += stats.Blocked
230230
agg.perRun = append(agg.perRun, DomainRunStatus{
231231
RunID: in.RunID,
232-
Status: domainStatus(stats),
232+
Status: classifyFirewallDomainStatus(stats),
233233
Allowed: stats.Allowed,
234234
Blocked: stats.Blocked,
235235
})
@@ -354,7 +354,7 @@ func buildCrossRunAuditReport(inputs []crossRunInput) *CrossRunAuditReport {
354354
SeenInRuns: len(agg.perRun),
355355
TotalAllowed: agg.totalAllowed,
356356
TotalBlocked: agg.totalBlocked,
357-
OverallStatus: domainStatus(DomainRequestStats{Allowed: agg.totalAllowed, Blocked: agg.totalBlocked}),
357+
OverallStatus: classifyFirewallDomainStatus(DomainRequestStats{Allowed: agg.totalAllowed, Blocked: agg.totalBlocked}),
358358
PerRunStatus: fullPerRun,
359359
}
360360
report.DomainInventory = append(report.DomainInventory, entry)

pkg/cli/audit_cross_run_render.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func renderCrossRunReportMarkdown(report *CrossRunAuditReport) {
131131
fmt.Printf("| Domain | Status | Seen In | Allowed | Blocked |\n")
132132
fmt.Printf("|--------|--------|---------|---------|--------|\n")
133133
for _, entry := range report.DomainInventory {
134-
icon := statusEmoji(entry.OverallStatus)
134+
icon := firewallStatusEmoji(entry.OverallStatus)
135135
fmt.Printf("| `%s` | %s %s | %d/%d runs | %d | %d |\n",
136136
entry.Domain, icon, entry.OverallStatus, entry.SeenInRuns, report.RunsAnalyzed,
137137
entry.TotalAllowed, entry.TotalBlocked)
@@ -289,7 +289,7 @@ func renderCrossRunReportPretty(report *CrossRunAuditReport) {
289289
if len(report.DomainInventory) > 0 {
290290
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Domain Inventory (%d domains)", len(report.DomainInventory))))
291291
for _, entry := range report.DomainInventory {
292-
icon := statusEmoji(entry.OverallStatus)
292+
icon := firewallStatusEmoji(entry.OverallStatus)
293293
fmt.Fprintf(os.Stderr, " %s %-45s %s seen=%d/%d allowed=%d blocked=%d\n",
294294
icon, entry.Domain, entry.OverallStatus, entry.SeenInRuns, report.RunsAnalyzed,
295295
entry.TotalAllowed, entry.TotalBlocked)

pkg/cli/audit_diff.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func computeFirewallDiff(run1ID, run2ID int64, run1, run2 *FirewallAnalysis) *Fi
109109
Status: "new",
110110
Run2Allowed: stats2.Allowed,
111111
Run2Blocked: stats2.Blocked,
112-
Run2Status: domainStatus(stats2),
112+
Run2Status: classifyFirewallDomainStatus(stats2),
113113
}
114114
// Anomaly: new denied domain
115115
if stats2.Blocked > 0 {
@@ -125,13 +125,13 @@ func computeFirewallDiff(run1ID, run2ID int64, run1, run2 *FirewallAnalysis) *Fi
125125
Status: "removed",
126126
Run1Allowed: stats1.Allowed,
127127
Run1Blocked: stats1.Blocked,
128-
Run1Status: domainStatus(stats1),
128+
Run1Status: classifyFirewallDomainStatus(stats1),
129129
}
130130
diff.RemovedDomains = append(diff.RemovedDomains, entry)
131131
} else {
132132
// Domain exists in both runs - check for changes
133-
status1 := domainStatus(stats1)
134-
status2 := domainStatus(stats2)
133+
status1 := classifyFirewallDomainStatus(stats1)
134+
status2 := classifyFirewallDomainStatus(stats2)
135135

136136
if status1 != status2 {
137137
// Status changed
@@ -198,8 +198,8 @@ func computeFirewallDiff(run1ID, run2ID int64, run1, run2 *FirewallAnalysis) *Fi
198198
return diff
199199
}
200200

201-
// domainStatus returns "allowed", "denied", or "mixed" based on request stats
202-
func domainStatus(stats DomainRequestStats) string {
201+
// classifyFirewallDomainStatus returns "allowed", "denied", or "mixed" based on request stats
202+
func classifyFirewallDomainStatus(stats DomainRequestStats) string {
203203
if stats.Allowed > 0 && stats.Blocked == 0 {
204204
return "allowed"
205205
}

pkg/cli/audit_diff_render.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func renderFirewallDiffMarkdownSection(diff *FirewallDiff) {
149149
fmt.Printf("**New domains (%d)**\n", len(diff.NewDomains))
150150
for _, entry := range diff.NewDomains {
151151
total := entry.Run2Allowed + entry.Run2Blocked
152-
statusIcon := statusEmoji(entry.Run2Status)
152+
statusIcon := firewallStatusEmoji(entry.Run2Status)
153153
anomalyTag := ""
154154
if entry.IsAnomaly {
155155
anomalyTag = " ⚠️"
@@ -171,8 +171,8 @@ func renderFirewallDiffMarkdownSection(diff *FirewallDiff) {
171171
if len(diff.StatusChanges) > 0 {
172172
fmt.Printf("**Status changes (%d)**\n", len(diff.StatusChanges))
173173
for _, entry := range diff.StatusChanges {
174-
icon1 := statusEmoji(entry.Run1Status)
175-
icon2 := statusEmoji(entry.Run2Status)
174+
icon1 := firewallStatusEmoji(entry.Run1Status)
175+
icon2 := firewallStatusEmoji(entry.Run2Status)
176176
anomalyTag := ""
177177
if entry.IsAnomaly {
178178
anomalyTag = " ⚠️"
@@ -324,7 +324,7 @@ func renderFirewallDiffPrettySection(diff *FirewallDiff) {
324324
}
325325
config.Rows = append(config.Rows, []string{
326326
entry.Domain,
327-
statusEmoji(entry.Run2Status) + " " + entry.Run2Status,
327+
firewallStatusEmoji(entry.Run2Status) + " " + entry.Run2Status,
328328
strconv.Itoa(total),
329329
anomalyNote,
330330
})
@@ -342,7 +342,7 @@ func renderFirewallDiffPrettySection(diff *FirewallDiff) {
342342
total := entry.Run1Allowed + entry.Run1Blocked
343343
config.Rows = append(config.Rows, []string{
344344
entry.Domain,
345-
statusEmoji(entry.Run1Status) + " " + entry.Run1Status,
345+
firewallStatusEmoji(entry.Run1Status) + " " + entry.Run1Status,
346346
strconv.Itoa(total),
347347
})
348348
}
@@ -362,8 +362,8 @@ func renderFirewallDiffPrettySection(diff *FirewallDiff) {
362362
}
363363
config.Rows = append(config.Rows, []string{
364364
entry.Domain,
365-
statusEmoji(entry.Run1Status) + " " + entry.Run1Status,
366-
statusEmoji(entry.Run2Status) + " " + entry.Run2Status,
365+
firewallStatusEmoji(entry.Run1Status) + " " + entry.Run1Status,
366+
firewallStatusEmoji(entry.Run2Status) + " " + entry.Run2Status,
367367
anomalyNote,
368368
})
369369
}
@@ -583,8 +583,8 @@ func renderTokenUsageDiffPrettySection(run1ID, run2ID int64, diff *TokenUsageDif
583583
}
584584
}
585585

586-
// statusEmoji returns the status emoji for a domain status
587-
func statusEmoji(status string) string {
586+
// firewallStatusEmoji returns the status emoji for a domain status
587+
func firewallStatusEmoji(status string) string {
588588
switch status {
589589
case "allowed":
590590
return "✅"

pkg/cli/audit_diff_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ func TestDomainStatus(t *testing.T) {
243243

244244
for _, tt := range tests {
245245
t.Run(tt.name, func(t *testing.T) {
246-
result := domainStatus(tt.stats)
246+
result := classifyFirewallDomainStatus(tt.stats)
247247
assert.Equal(t, tt.expected, result, "Domain status should match")
248248
})
249249
}
@@ -297,11 +297,11 @@ func TestFirewallDiffJSONSerialization(t *testing.T) {
297297
}
298298

299299
func TestStatusEmoji(t *testing.T) {
300-
assert.Equal(t, "✅", statusEmoji("allowed"), "Allowed should show checkmark")
301-
assert.Equal(t, "❌", statusEmoji("denied"), "Denied should show X")
302-
assert.Equal(t, "⚠️", statusEmoji("mixed"), "Mixed should show warning")
303-
assert.Equal(t, "❓", statusEmoji("unknown"), "Unknown should show question mark")
304-
assert.Equal(t, "❓", statusEmoji(""), "Empty should show question mark")
300+
assert.Equal(t, "✅", firewallStatusEmoji("allowed"), "Allowed should show checkmark")
301+
assert.Equal(t, "❌", firewallStatusEmoji("denied"), "Denied should show X")
302+
assert.Equal(t, "⚠️", firewallStatusEmoji("mixed"), "Mixed should show warning")
303+
assert.Equal(t, "❓", firewallStatusEmoji("unknown"), "Unknown should show question mark")
304+
assert.Equal(t, "❓", firewallStatusEmoji(""), "Empty should show question mark")
305305
}
306306

307307
func TestIsEmptyDiff(t *testing.T) {

0 commit comments

Comments
 (0)