Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
title: Canonical selectors
description: Use consistent Gateway selector names across policy types, and keep existing expressions that use legacy selector names.
pcx_content_type: reference
products:
- cloudflare-one
sidebar:
order: 14
---

Canonical selectors give the same Gateway condition a consistent field name across supported policy types. For example, `ip.src` represents Source IP in DNS, HTTP, and network policies.

Use canonical names when writing new expressions. Existing expressions using legacy names remain supported, and you can continue to use those names through the API or the expression editor. No migration is required.

## Selector names

The following table maps canonical selectors to their corresponding legacy names. Each legacy name retains its existing policy-type and action restrictions.

| Selector | Canonical field | Legacy fields |
| --------------------- | --------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| Source IP | `ip.src` | `dns.src_ip`, `net.src.ip`, `http.conn.src_ip` |
| Source Internal IP | `ip.src_internal` | `dns.src_internal_ip`, `net.src.internal_src_ip`, `http.conn.internal_src_ip` |
| Destination IP | `ip.dst` | `net.dst.ip`, `http.conn.dst_ip` |
| Source Country | `ip.src.country` | `dns.src.geo.country`, `net.src.geo.country`, `http.src_ip.geo.country` |
| Source Continent | `ip.src.continent` | `dns.src.geo.continent`, `net.src.geo.continent`, `http.src_ip.geo.continent` |
| Destination Country | `ip.dst.country` | `net.dst.geo.country`, `http.dst_ip.geo.country` |
| Destination Continent | `ip.dst.continent` | `net.dst.geo.continent`, `http.dst_ip.geo.continent` |
| Virtual Network | `vnet.id` | `net.vnet_id`, `http.conn.vnet_id` |
| Traffic Source | `onramp.type` | `net.onramp.type` |
| Traffic Destination | `offramp.type` | `net.offramp.type` |
| Browser Isolation | `is_isolated` | `net.is_isolated` |
| Host | `host` | `dns.fqdn`, `http.conn.hostname`, `http.request.host`, `net.fqdn.host` |
| Domain | `domains` | `dns.domains`, `http.conn.domains`, `http.request.domains`, `net.fqdn.domains` |
| Content Categories | `content_categories` | `dns.content_category`, `http.conn.content_category`, `http.request.uri.content_category`, `net.fqdn.content_category` |
| Security Categories | `security_categories` | `dns.security_category`, `http.conn.security_category`, `http.request.uri.security_category`, `net.fqdn.security_category` |

Canonical names do not make every field available in every policy type. Refer to the selector reference for [DNS](/cloudflare-one/traffic-controls/dns-policies/#selectors), [HTTP](/cloudflare-one/traffic-controls/http-policies/#selectors), [network](/cloudflare-one/traffic-controls/network-policies/#selectors), [egress](/cloudflare-one/traffic-controls/egress-policies/#selectors), or [resolver](/cloudflare-one/traffic-controls/resolver-policies/#selectors) policies for availability and restrictions.

Fields without a canonical replacement keep their existing names. For example, use `net.dst.port` for Destination Port, `http.request.method` for HTTP Method, and `dns.query_rtype` for Query Record Type.

## Expression examples

For a Source IP condition, use the following canonical expression in a compatible policy type:

```txt
ip.src in {192.0.2.0/24}
```

These existing expressions remain supported in their respective policy types:

| Policy type | Legacy expression |
| ----------- | ------------------------------------ |
| DNS | `dns.src_ip in {192.0.2.0/24}` |
| HTTP | `http.conn.src_ip in {192.0.2.0/24}` |
| Network | `net.src.ip in {192.0.2.0/24}` |

Use `host` for an exact hostname match:

```txt
host == "example.com"
```

`domains` returns an array. Keep `any()` and `[*]` when matching it:

```txt
any(domains[*] == "example.com")
```

Category fields also return arrays:

```txt
any(content_categories[*] in {17 85 102})
```

You can combine canonical and legacy fields in the same supported expression:

```txt
ip.src in {192.0.2.0/24} and net.dst.port == 443
```

## Scalar and array fields

Preserve the syntax required by each field's type. In particular, canonical `ip.dst` is a single IP address, while legacy `http.conn.dst_ip` is an array.

Use the canonical Destination IP expression:

```txt
ip.dst in {198.51.100.0/24}
```

The existing HTTP array expression remains valid:

```txt
any(http.conn.dst_ip[*] in {198.51.100.0/24})
```

When rewriting this expression, replace the complete condition. Changing only the field name would leave array syntax around a scalar field. Apply the same review to negation and list expressions.

## Dashboard behavior

The visual builder uses canonical selectors when you add a new condition or select a selector again. When you load an existing condition, the builder preserves its legacy selector while that selector remains unchanged. Editing its value does not require migrating the selector.

An expression can therefore contain both legacy and canonical selectors after editing. Both remain supported. Formatting and parentheses can change when an expression is serialized.

## Evaluation context

A canonical selector reads the value available in the policy's evaluation context. Host and category matching still follow the rules for that policy type and action. The shared name does not change when Gateway evaluates a policy or which traffic data is available.

For DNS policies, Resolved IP, Resolved Country, and Resolved Continent continue to use `dns.resolved_ips`, `dns.dst.geo.country`, and `dns.dst.geo.continent`. They are distinct from connection destination selectors.

Network SNI selectors, including `net.sni.host` and `net.sni.domains`, also keep their existing names and meanings. Do not replace them with `host` or `domains`.

Canonical selectors are part of [Gateway policy expressions](/cloudflare-one/traffic-controls/expression-syntax/). Use Gateway selector references when authoring policies, even when a field name also appears in the Rules language used by other Cloudflare products.
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ This setup ensures users will be blocked from accessing offensive sites using DN

## Selectors

Examples use [canonical selector names](/cloudflare-one/traffic-controls/canonical-selectors/). Existing expressions using the corresponding legacy names remain supported. No migration is required.

Gateway matches DNS queries against the following selectors, or criteria.

Each selector is evaluated during a specific phase of the DNS resolution process:
Expand Down Expand Up @@ -379,15 +381,15 @@ Use this selector to filter DNS responses by their `TXT` records.
<Render
file="gateway/selectors/domain-dns"
product="cloudflare-one"
params={{ APIendpoint: "dns.domains" }}
params={{ APIendpoint: "domains" }}
/>

### Host

<Render
file="gateway/selectors/host-dns"
product="cloudflare-one"
params={{ APIendpoint: "dns.fqdn" }}
params={{ APIendpoint: "host" }}
/>

### Indicator Feeds
Expand Down Expand Up @@ -474,7 +476,7 @@ Use this selector to apply policies to the source internal IP address of a DNS q

| UI name | API example | Evaluation phase |
| ------------------ | ---------------------------------- | --------------------- |
| Source Internal IP | `dns.src_internal_ip == 10.10.0.1` | Before DNS resolution |
| Source Internal IP | `ip.src_internal == 10.10.0.1` | Before DNS resolution |

### Users

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ To learn more about IPv4 and IPv6 egress behavior, refer to [Egress locations](/

## Selectors

Examples use [canonical selector names](/cloudflare-one/traffic-controls/canonical-selectors/). Existing expressions using the corresponding legacy names remain supported. No migration is required.

Selectors are the criteria that Gateway uses to match egress traffic against a policy. Gateway evaluates the following selectors:

### Application <Badge text="Beta" variant="caution"/>
Expand All @@ -113,7 +115,7 @@ Selectors are the criteria that Gateway uses to match egress traffic against a p
<Render
file="gateway/selectors/net-http-content-categories"
product="cloudflare-one"
params={{ APIendpoint: "net.fqdn.content_category" }}
params={{ APIendpoint: "content_categories" }}
/>

<Render
Expand Down Expand Up @@ -142,7 +144,7 @@ Selectors are the criteria that Gateway uses to match egress traffic against a p
<Render
file="gateway/selectors/destination-ip"
product="cloudflare-one"
params={{ APIendpoint: "net.dst.ip" }}
params={{ APIendpoint: "ip.dst" }}
/>

### Destination Port
Expand All @@ -158,7 +160,7 @@ Selectors are the criteria that Gateway uses to match egress traffic against a p
<Render
file="gateway/selectors/domain-http"
product="cloudflare-one"
params={{ APIendpoint: "net.fqdn.domains" }}
params={{ APIendpoint: "domains" }}
/>

<Render
Expand All @@ -171,7 +173,7 @@ Selectors are the criteria that Gateway uses to match egress traffic against a p
<Render
file="gateway/selectors/host-http"
product="cloudflare-one"
params={{ APIendpoint: "net.fqdn.host" }}
params={{ APIendpoint: "host" }}
/>

<Render
Expand Down Expand Up @@ -200,15 +202,15 @@ The country of the user making the request. <Render file="gateway/selectors/sour
<Render
file="gateway/selectors/source-internal-ip"
product="cloudflare-one"
params={{ one: "egress", two: "net.src.internal_src_ip" }}
params={{ one: "egress", two: "ip.src_internal" }}
/>

### Source IP

<Render
file="gateway/selectors/source-ip"
product="cloudflare-one"
params={{ APIendpoint: "net.src.ip" }}
params={{ APIendpoint: "ip.src" }}
/>

### Source Port
Expand All @@ -224,7 +226,7 @@ The country of the user making the request. <Render file="gateway/selectors/sour
<Render
file="gateway/selectors/virtual-network"
product="cloudflare-one"
params={{ one: "net.vnet_id" }}
params={{ one: "vnet.id" }}
/>

## Comparison operators
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ Gateway expressions follow this pattern:
For example:

```txt
dns.fqdn == "example.com"
http.request.host == "api.example.com"
host == "example.com"
ip.src == 192.0.2.1
identity.email == "user@company.com"
```

Expand All @@ -46,10 +46,10 @@ Gateway supports the following operators:

| Operator | Name | Example |
| --------- | -------------------------- | ------------------------------------------------ |
| `==` | Equals | `dns.fqdn == "example.com"` |
| `!=` | Does not equal | `http.request.host != "blocked.com"` |
| `==` | Equals | `host == "example.com"` |
| `!=` | Does not equal | `host != "blocked.com"` |
| `in` | Value is in set | `net.dst.port in {80 443}` |
| `matches` | Matches regular expression | `http.request.host matches ".*\\.example\\.com"` |
| `matches` | Matches regular expression | `host matches ".*\\.example\\.com"` |
| `>` | Greater than | `http.upload.file.size > 10` |
| `>=` | Greater than or equal to | `http.download.file.size >= 100` |
| `<` | Less than | `http.upload.file.size < 50` |
Expand All @@ -61,7 +61,7 @@ Combine multiple conditions using logical operators:

| Operator | Name | Example |
| -------- | ----------- | --------------------------------------------------------------------- |
| `and` | Logical AND | `dns.fqdn == "example.com" and identity.email == "admin@company.com"` |
| `and` | Logical AND | `host == "example.com" and identity.email == "admin@company.com"` |
| `or` | Logical OR | `net.dst.port == 80 or net.dst.port == 443` |
| `not` | Logical NOT | `not(identity.email == "guest@company.com")` |

Expand All @@ -70,15 +70,15 @@ Combine multiple conditions using logical operators:
Some Gateway fields return arrays (multiple values). Use the `any()` function to match if any element in the array meets the condition:

```txt
any(http.request.uri.content_category[*] in {17 85 102})
any(content_categories[*] in {17 85 102})
```

```txt
any(identity.groups[*].name in {"Engineering" "Security"})
```

```txt
any(http.request.domains[*] == "example.com")
any(domains[*] == "example.com")
```

The `[*]` notation indicates that the function should evaluate all elements in the array.
Expand All @@ -88,41 +88,35 @@ The `[*]` notation indicates that the function should evaluate all elements in t
You can reference [lists](/cloudflare-one/reusable-components/lists/) in your expressions using the list UUID:

```txt
http.request.host in $<LIST_UUID>
host in $<LIST_UUID>
```

```txt
any(http.request.domains[*] in $<LIST_UUID>)
any(domains[*] in $<LIST_UUID>)
```

To find a list's UUID, go to **My Team** > **Lists** in Zero Trust and select the list. The UUID appears in the browser URL.

## Common field patterns
## Shared and policy-specific fields

Each Gateway policy type has its own set of available fields. The following table shows the field prefixes used by each policy type:
Use [canonical selectors](/cloudflare-one/traffic-controls/canonical-selectors/) for concepts shared across policy types, such as `ip.src`, `host`, and `domains`. Existing legacy selector names remain supported. No migration is required.

| Policy type | Field prefix | Example fields |
| -------------- | ----------------- | --------------------------------------------------------------- |
| DNS | `dns.` | `dns.fqdn`, `dns.content_category`, `dns.src_ip` |
| HTTP | `http.` | `http.request.host`, `http.request.uri`, `http.request.domains` |
| Network | `net.` | `net.dst.ip`, `net.dst.port`, `net.src.ip` |
| Identity | `identity.` | `identity.email`, `identity.groups`, `identity.name` |
| Device posture | `device_posture.` | `device_posture.checks.passed` |
Some fields apply to a particular policy type. For example, `http.request.method` describes an HTTP request, while `dns.query_rtype` describes a DNS query. Identity and device posture conditions use their own expression sections.

For a complete list of available fields for each policy type, refer to the selectors documentation linked at the top of this page.
For availability, refer to the selector reference for each policy type. The field name alone does not determine compatibility.

## Example expressions

### Block a domain in a DNS policy

```txt
dns.fqdn == "example.com"
host == "example.com"
```

### Block multiple content categories in an HTTP policy

```txt
any(http.request.uri.content_category[*] in {17 85 102})
any(content_categories[*] in {17 85 102})
```

### Allow traffic from a specific user group
Expand All @@ -134,13 +128,13 @@ any(identity.groups[*].name in {"Engineering"})
### Block traffic to a destination IP range in a Network policy

```txt
net.dst.ip in {10.0.0.0/8}
ip.dst in {10.0.0.0/8}
```

### Combine identity and traffic conditions

```txt
http.request.host == "internal.example.com" and identity.email matches ".*@company.com"
host == "internal.example.com" and identity.email matches ".*@company.com"
```

## Gateway versus Ruleset Engine
Expand All @@ -150,9 +144,9 @@ The following table summarizes the key differences between the Rules language](/
| | Ruleset Engine | Gateway |
| ------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| **Products** | WAF, Transform Rules, Cache Rules, Configuration Rules | DNS, HTTP, Network, Egress, Resolver policies |
| **Field examples** | `http.request.uri.path`, `cf.bot_management.score`, `ip.src` | `dns.fqdn`, `http.request.host`, `identity.email` |
| **Field examples** | `http.request.uri.path`, `cf.bot_management.score`, `ip.src` | `host`, `ip.src`, `identity.email` |
| **Identity fields** | Not available | Available (for example, `identity.email`, `identity.groups`) |
| **DNS fields** | Not available | Available (for example, `dns.fqdn`, `dns.content_category`) |
| **DNS fields** | Not available | Available (for example, `dns.query_rtype`, `dns.resolved_ips`) |
| **Documentation** | [Rules language](/ruleset-engine/rules-language/) | [Traffic policies](/cloudflare-one/traffic-controls/) |

:::note
Expand Down
Loading