MCPcopy Create free account
hub / github.com/github/gh-aw / isRequestAllowed

Function isRequestAllowed

pkg/cli/firewall_log.go:244–269  ·  view source on GitHub ↗

isRequestAllowed determines if a request was allowed based on decision and status This mirrors the logic from the JavaScript parser

(decision, status string)

Source from the content-addressed store, hash-verified

242// isRequestAllowed determines if a request was allowed based on decision and status
243// This mirrors the logic from the JavaScript parser
244func isRequestAllowed(decision, status string) bool {
245 // Check status code first
246 if statusCode, err := strconv.Atoi(status); err == nil {
247 if statusCode == http.StatusOK || statusCode == http.StatusPartialContent || statusCode == http.StatusNotModified {
248 return true
249 }
250 if statusCode == http.StatusForbidden || statusCode == http.StatusProxyAuthRequired {
251 return false
252 }
253 }
254
255 // Check decision field
256 if strings.Contains(decision, "TCP_TUNNEL") ||
257 strings.Contains(decision, "TCP_HIT") ||
258 strings.Contains(decision, "TCP_MISS") {
259 return true
260 }
261
262 if strings.Contains(decision, "NONE_NONE") ||
263 strings.Contains(decision, "TCP_DENIED") {
264 return false
265 }
266
267 // Default to denied for safety
268 return false
269}
270
271// parseFirewallLog parses a firewall log file and returns analysis
272func parseFirewallLog(logPath string, verbose bool) (*FirewallAnalysis, error) {

Callers 2

TestIsRequestAllowedFunction · 0.70
parseFirewallLogFunction · 0.70

Calls

no outgoing calls

Tested by 1

TestIsRequestAllowedFunction · 0.56