Custom finding types
Last updated Oct 8, 2026 In addition to providing predefined finding types to detect security issues within SaaS and cloud applications, Cloudflare CASB allows custom finding types to be defined from scratch, providing full control over the security conditions CASB detects.
Prerequisites
- A Cloud or SaaS integration has been added.
- Familiarity with Rego ↗︎.
Standard and custom finding types
Cloudflare CASB provides two ways that security risks are detected. In Cloudflare One ↗︎, they are differentiated in Cloud & SaaS findings > Finding types library as entries with Origin value "Standard" or "Custom".
- Standard finding type - A predefined finding type created and managed by Cloudflare CASB. It can be inspected and duplicated, but not changed.
- Custom finding type - A finding type that is created and managed in the account with Rego expressions.
The following table shows the capabilities of a CASB customer's account for both standard and custom finding types:
| Capability | Standard finding types | Custom finding types |
|---|---|---|
| Inspect detection logic | ✅ | ✅ |
| Create posture finding types | ❌ | ✅ |
| Create content finding types | ❌ | ❌ |
| Duplicate posture finding types | ✅ | ✅ |
| Duplicate content finding types | ❌ | ❌ |
| Edit posture finding types | ❌ | ✅ |
| Edit content finding types | ❌ | ❌ |
| Delete posture finding types | ❌ | ✅ |
| Delete content finding types | ❌ | ❌ |
| Disable posture finding types | ❌ | ❌ |
| Disable content finding types | ❌ | ❌ |
How custom finding types work
Example scenario
A security team at a company that uses Google Workspace wants to have visibility into when a group for executives, the board, or the legal team is open to people outside the company. The company names these groups with the prefixes exec-, board-, and legal-, and one of them, the outside counsel group, is allowed to have external members. Given that this depends on the company's own group naming convention and exception, CASB does not include a standard finding type for this exact scenario, so the team creates a custom finding type.
- Define the finding type. In the Finding types library, the team creates a custom finding type. They name it "Sensitive group open to outsiders", set the severity to High, choose Google Workspace as the provider, and write a Rego expression that returns "fail" when a group whose address starts with
exec-,board-, orlegal-allows external members (unless it is the outside counsel group), lets anyone join, or lets anyone post. - See the results. As CASB receives updates for the company's Google Workspace groups, it evaluates each one. Groups that match appear as finding instances under Posture Findings, so the team can see which sensitive groups are open. Groups with other names are never flagged.
- Take action. The team creates a CASB policy for this finding type that sends a webhook to their messaging admin automation. Each new finding instance now triggers the automation to restrict the group.
The following sections describe each part of this flow in detail.
Finding type fields
A custom finding type consists of the following fields:
| Field | Description |
|---|---|
| Finding Type Name | The display name of the finding type. |
| Description | A definition for what the finding type detects against. |
| Severity | The impact of the finding type: Low, Medium, High, or Critical. |
| Provider | The integration vendor the finding type detects against. |
| Asset Class | The set of asset fields available to the detection logic. These fields appear under Available asset fields in the finding type builder. |
| Category Type | The classification of the findings it generates. |
| Integrations | The integrations CASB evaluates this finding type against. Select Apply to all integrations to use all of them. |
| Rego Package | The detection logic CASB uses to generate findings. |
CASB evaluates a custom finding type against an asset when it is created or updated and exists within the set of configured integrations. They are not run retroactively against existing assets.
Continuing the example scenario, one board group has an external member, and a new executive group is open to anyone:
| Day | Event | Finding created? |
|---|---|---|
| Sunday | The board-directors@example.com group allows external members and is updated. |
No. The "Sensitive group open to outsiders" finding type does not exist yet. |
| Monday | The security team creates the "Sensitive group open to outsiders" finding type. | No. CASB does not evaluate board-directors, because it has not changed since the finding type was created. |
| Tuesday | The exec-staff@example.com group is created and anyone can join it. |
Yes. CASB evaluates the new group and creates a finding instance. |
| Wednesday | A member is added to board-directors. |
Yes. CASB evaluates the group again and creates a finding instance, because it still allows external members. |
| Thursday | The legal-outside-counsel@example.com group, which allows external members, is updated. |
No. CASB evaluates the group and its result is "pass", because it is the approved exception, so no finding instance is created. |
Rego detection logic
Custom finding types are written in Rego ↗︎, the open-source policy language used by Open Policy Agent (OPA). For an introduction to Rego, refer to the OPA documentation ↗︎. CASB uses Rego v1 and supports a restricted subset of Rego built-ins ↗︎ and operations.
The following expression is the one the security team writes in the example scenario. It detects sensitive groups that are open to people outside the company:
sensitive_prefixes := ["exec-", "board-", "legal-"]
external_exceptions := {"legal-outside-counsel@example.com"}
default result := "pass"
email := lower(input.asset.email)
sensitive if strings.any_prefix_match(email, sensitive_prefixes)
result := "fail" if {
sensitive
input.asset.allowExternalMembers == true
not email in external_exceptions
}
result := "fail" if {
sensitive
input.asset.whoCanJoin == "ANYONE_CAN_JOIN"
}
result := "fail" if {
sensitive
input.asset.whoCanPostMessage == "ANYONE_CAN_POST"
}
This expression works as follows:
sensitive_prefixesandexternal_exceptionshold the company's values. They are written into the expression, because CASB cannot fetch lists from another system during evaluation.default result := "pass"sets the result to "pass" for every asset unless another rule in the expression changes it. Therefore, assets that do not match are never flagged.email := lower(input.asset.email)lowercases the group's address, so thatBoard-Directors@example.comis treated the same asboard-directors@example.com.sensitiveis true when the address starts with any of the three prefixes.strings.any_prefix_matchchecks the whole list in one call. Groups with other names never match.result := "fail" if { ... }changes the result to "fail" when everything inside the braces is true. This will create a finding instance.- The first rule checks if sensitive groups allow external members without explicit approvals.
- The second rule checks for sensitive groups that let anyone join.
- The third rule checks for sensitive groups that let anyone post.
Rego guidelines for custom finding type expressions
- The expression must define a
resultthat returns either "pass" or "fail". A "fail" result means the asset matches the finding type and creates a finding instance. - Add
default result := "pass"so assets that do not match a fail condition return "pass". - No need to add a package declaration or any import statements, this includes
import rego.v1. CASB adds these automatically, and the editor does not accept them. - Fields from the selected asset class can be read from
input.asset. - Some asset classes include related assets, such as a file and its owner. When available, reference fields from related assets through
input.associated.
Rego validation
Select Validate in the finding type builder to check a Rego expression before creating the finding. Validation compiles the expression and checks it against the asset schema. It reports any syntax errors or unsupported Rego built-ins it finds.
Validation does not execute the expression against data. To confirm the expression detects the intended conditions, verify the finding type's behavior after it is created.
Supported Rego built-ins
Custom finding types support the following Rego built-ins and operators. Any built-in not listed here is unsupported.
<details>
<summary>
Supported built-ins and operators
</summary>
| Category | Built-ins |
|---|---|
| Operators | <code>=</code>, <code>==</code>, <code>!=</code>, <code>></code>, <code>>=</code>, <code><</code>, <code><=</code>, <code>in</code> |
| Aggregates | <code>count</code>, <code>max</code>, <code>min</code>, <code>product</code>, <code>sort</code>, <code>sum</code> |
| Arrays | <code>array.concat</code>, <code>array.flatten</code>, <code>array.reverse</code>, <code>array.slice</code> |
| Conversion | <code>to_number</code> |
| Encoding and serialization | <code>base64.decode</code>, <code>base64.encode</code>, <code>base64.is_valid</code>, <code>base64url.decode</code>, <code>base64url.encode</code>, <code>base64url.encode_no_pad</code>, <code>hex.decode</code>, <code>hex.encode</code>, <code>json.is_valid</code>, <code>json.marshal</code>, <code>json.marshal_with_options</code>, <code>json.unmarshal</code>, <code>urlquery.decode</code>, <code>urlquery.decode_object</code>, <code>urlquery.encode</code>, <code>urlquery.encode_object</code> |
| Glob and graph | <code>glob.match</code>, <code>glob.quote_meta</code>, <code>graph.reachable</code>, <code>graph.reachable_paths</code>, <code>walk</code> |
| CIDR | <code>net.cidr_contains</code>, <code>net.cidr_contains_matches</code>, <code>net.cidr_intersects</code>, <code>net.cidr_is_valid</code>, <code>net.cidr_merge</code> |
| Numbers | <code>abs</code>, <code>ceil</code>, <code>div</code>, <code>floor</code>, <code>minus</code>, <code>mul</code>, <code>plus</code>, <code>rem</code>, <code>round</code> |
| JSON and objects | <code>json.filter</code>, <code>json.remove</code>, <code>object.filter</code>, <code>object.get</code>, <code>object.keys</code>, <code>object.remove</code>, <code>object.subset</code>, <code>object.union</code>, <code>object.union_n</code> |
| Regular expressions | <code>regex.globs_match</code>, <code>regex.is_valid</code>, <code>regex.match</code>, <code>regex.replace</code>, <code>regex.template_match</code> |
| Semantic versions | <code>semver.compare</code>, <code>semver.is_valid</code> |
| Sets | <code>and</code>, <code>intersection</code>, <code>or</code>, <code>union</code> |
| Strings | <code>concat</code>, <code>contains</code>, <code>endswith</code>, <code>format_int</code>, <code>indexof</code>, <code>indexof_n</code>, <code>lower</code>, <code>replace</code>, <code>split</code>, <code>sprintf</code>, <code>startswith</code>, <code>strings.any_prefix_match</code>, <code>strings.any_suffix_match</code>, <code>strings.count</code>, <code>substring</code>, <code>trim</code>, <code>trim_left</code>, <code>trim_prefix</code>, <code>trim_right</code>, <code>trim_space</code>, <code>trim_suffix</code>, <code>upper</code> |
| Time | <code>time.add_date</code>, <code>time.clock</code>, <code>time.date</code>, <code>time.diff</code>, <code>time.format</code>, <code>time.now_ns</code>, <code>time.parse_duration_ns</code>, <code>time.parse_ns</code>, <code>time.parse_rfc3339_ns</code>, <code>time.weekday</code> |
| Types | <code>is_array</code>, <code>is_boolean</code>, <code>is_null</code>, <code>is_number</code>, <code>is_object</code>, <code>is_set</code>, <code>is_string</code>, <code>type_name</code> |
| Units | <code>units.parse</code>, <code>units.parse_bytes</code> |
| URI | <code>uri.is_valid</code>, <code>uri.parse</code> |
| UUID | <code>uuid.parse</code>, <code>uuid.rfc4122</code> |
</details>
Rego references
Custom finding type expressions use Rego v1 syntax and the Cloudflare-supported Rego built-ins listed in this section.
- Rego policy language ↗︎ - Rego language documentation.
- OPA built-ins ↗︎ - Full list of OPA built-ins. Custom finding types support a subset of this list.
- OPA style guide ↗︎ - General guidance for writing Rego expressions.
- OPA Playground ↗︎ - Sandbox for writing and testing general Rego expressions.
Note
The OPA documentation and Playground include built-ins that custom finding types do not support. An expression that works in the Playground may fail validation in Cloudflare One. Use only the built-ins listed on this page.
Create a custom finding type
- In Cloudflare One ↗︎, go to Cloud & SaaS findings > Finding types library.
- Select Create finding type.
- Under General Information, enter a finding type name and description. Then, select a severity.
- Under Scope Definition, select a provider and asset class.
- Choose whether the finding type applies to all integrations for the provider or to selected integrations.
- Under Detection Logic, enter the Rego expression. Use Available asset fields to identify supported fields.
- Select Validate. Resolve each validation error before continuing.
- Select Create finding type.
