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)
| 257 | // protocolMatches checks if a rule's protocol constraint matches the request. |
| 258 | // "both" matches everything; "https" matches only HTTPS; "http" matches only HTTP. |
| 259 | func 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. |
no test coverage detected