CEL Expression Reference
Complete reference for firewall rule expressions.
CIFP uses Google's Common Expression Language (CEL) for firewall rule expressions. Every expression must evaluate to a bool.
Available Variables
| Variable | Type | Example value |
|---|---|---|
| request.method | string | "GET" |
| request.url | string | "https://api.openai.com/v1/models" |
| request.host | string | "api.openai.com" |
| request.path | string | "/v1/models" |
| request.headers | map<string,string> | {"content-type": "application/json"} |
| request.body_sample | string | First 4 KB of request body (UTF-8, lossy) |
| client.ip | string | "203.0.113.45" |
| client.username | string | "proxy-abc123-u1a2b3" |
Operators
| Operator | Meaning | Example |
|---|---|---|
| == | Equals | request.method == "POST" |
| != | Not equals | request.host != "localhost" |
| && | AND | request.method == "GET" && request.host == "api.openai.com" |
| || | OR | request.method == "GET" || request.method == "HEAD" |
| ! | NOT | !request.path.startsWith("/admin") |
| in | List membership | request.method in ["GET", "POST"] |
String Functions
| Function | Example |
|---|---|
| .startsWith(prefix) | request.path.startsWith("/v1/") |
| .endsWith(suffix) | request.url.endsWith(".json") |
| .contains(substr) | request.url.contains("api.github.com") |
| .matches(regex) | request.host.matches("^(api|www)\.example\.com$") |
| .size() | request.path.size() < 200 |
| .lower() | request.method.lower() == "get" |
Header Access
Headers are a map<string,string>. Keys are lowercase. Access them with bracket notation:
bash
# Check Content-Type
request.headers["content-type"] == "application/json"
# Check if header exists
"x-custom-header" in request.headers
# Safe access with has()
has(request.headers.authorization)Numeric Comparisons
bash
# Deny requests with large bodies (over 1 MB)
int(request.headers["content-length"]) > 1048576Full Rule Examples
bash
# Allow only GET to api.openai.com
request.host == "api.openai.com" && request.method == "GET"
# Allow any method to openai or anthropic
request.host in ["api.openai.com", "api.anthropic.com"]
# Deny requests that look like exfiltration (body contains base64 of something large)
request.body_sample.size() > 2048 && request.method == "POST"
# HITL (human review) for any DELETE
request.method == "DELETE"
# Allow requests from internal IPs only
client.ip.startsWith("10.") || client.ip.startsWith("192.168.")
# Deny all — catch-all at priority 9999
trueCompile Errors
CEL expressions are compiled when you create or update a rule. If your expression is invalid, the API returns a 400 with the CEL compile error. Rules with compile errors are never stored.