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

Function protocolMatches

pkg/cli/firewall_policy.go:259–269  ·  view source on GitHub ↗

protocolMatches checks if a rule's protocol constraint matches the request. "both" matches everything; "https" matches only HTTPS; "http" matches only HTTP.

(rule PolicyRule, isHTTPS bool)

Source from the content-addressed store, hash-verified

257// protocolMatches checks if a rule's protocol constraint matches the request.
258// "both" matches everything; "https" matches only HTTPS; "http" matches only HTTP.
259func protocolMatches(rule PolicyRule, isHTTPS bool) bool {
260 switch strings.ToLower(rule.Protocol) {
261 case "https":
262 return isHTTPS
263 case "http":
264 return !isHTTPS
265 default:
266 // "both" or empty — matches everything
267 return true
268 }
269}
270
271// findMatchingRule finds the first matching policy rule for a given audit entry.
272// Rules are evaluated in order; the first matching rule wins.

Callers 1

findMatchingRuleFunction · 0.85

Calls 1

ToLowerMethod · 0.80

Tested by

no test coverage detected