MCPcopy Index your code
hub / github.com/github/gh-aw / renderFirewallDiffMarkdownSection

Function renderFirewallDiffMarkdownSection

pkg/cli/audit_diff_render.go:140–188  ·  view source on GitHub ↗

renderFirewallDiffMarkdownSection renders the firewall diff sub-section as markdown

(diff *FirewallDiff)

Source from the content-addressed store, hash-verified

138
139// renderFirewallDiffMarkdownSection renders the firewall diff sub-section as markdown
140func renderFirewallDiffMarkdownSection(diff *FirewallDiff) {
141 if diff == nil || isEmptyFirewallDiff(diff) {
142 return
143 }
144
145 fmt.Fprintln(os.Stdout, "#### Firewall Changes")
146 fmt.Fprintln(os.Stdout)
147
148 if len(diff.NewDomains) > 0 {
149 fmt.Fprintf(os.Stdout, "**New domains (%d)**\n", len(diff.NewDomains))
150 for _, entry := range diff.NewDomains {
151 total := entry.Run2Allowed + entry.Run2Blocked
152 statusIcon := firewallStatusEmoji(entry.Run2Status)
153 anomalyTag := formatAnomalyTag(entry.IsAnomaly)
154 fmt.Fprintf(os.Stdout, "- %s `%s` (%d requests, %s)%s\n", statusIcon, entry.Domain, total, entry.Run2Status, anomalyTag)
155 }
156 fmt.Fprintln(os.Stdout)
157 }
158
159 if len(diff.RemovedDomains) > 0 {
160 fmt.Fprintf(os.Stdout, "**Removed domains (%d)**\n", len(diff.RemovedDomains))
161 for _, entry := range diff.RemovedDomains {
162 total := entry.Run1Allowed + entry.Run1Blocked
163 fmt.Fprintf(os.Stdout, "- `%s` (was %s, %d requests in previous run)\n", entry.Domain, entry.Run1Status, total)
164 }
165 fmt.Fprintln(os.Stdout)
166 }
167
168 if len(diff.StatusChanges) > 0 {
169 fmt.Fprintf(os.Stdout, "**Status changes (%d)**\n", len(diff.StatusChanges))
170 for _, entry := range diff.StatusChanges {
171 icon1 := firewallStatusEmoji(entry.Run1Status)
172 icon2 := firewallStatusEmoji(entry.Run2Status)
173 anomalyTag := formatAnomalyTag(entry.IsAnomaly)
174 fmt.Fprintf(os.Stdout, "- `%s`: %s %s → %s %s%s\n", entry.Domain, icon1, entry.Run1Status, icon2, entry.Run2Status, anomalyTag)
175 }
176 fmt.Fprintln(os.Stdout)
177 }
178
179 if len(diff.VolumeChanges) > 0 {
180 fmt.Fprintf(os.Stdout, "**Volume changes**\n")
181 for _, entry := range diff.VolumeChanges {
182 total1 := entry.Run1Allowed + entry.Run1Blocked
183 total2 := entry.Run2Allowed + entry.Run2Blocked
184 fmt.Fprintf(os.Stdout, "- `%s`: %d → %d requests (%s)\n", entry.Domain, total1, total2, entry.VolumeChange)
185 }
186 fmt.Fprintln(os.Stdout)
187 }
188}
189
190// renderMCPToolsDiffMarkdownSection renders the MCP tools diff sub-section as markdown
191func renderMCPToolsDiffMarkdownSection(diff *MCPToolsDiff) {

Callers 1

Calls 3

isEmptyFirewallDiffFunction · 0.85
firewallStatusEmojiFunction · 0.85
formatAnomalyTagFunction · 0.85

Tested by

no test coverage detected