> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hiddenlayer.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Runtime Security Rules

> View HiddenLayer detection rules and create custom rules with CEL expressions for use in Runtime Security Policy Packs.

Rules define what Runtime Security can detect or enforce. HiddenLayer rules are ready to use, and you can add your own custom rules when you need something specific. Rules don't have an action on their own: you choose the action for each rule inside each [Policy Pack](https://docs.hiddenlayer.ai/docs/products/runtime/console/runtime_security_policy_packs.md).

## Prerequisites

* The Policy permission set to Read to view rules. To create, edit, duplicate, or delete rules, you need the Policy permission set to Write. See [Permissions for Products and Features](https://docs.hiddenlayer.ai/docs/products/console/apikey_aisec_platform.md#permissions-for-products-and-features).

## Rule types

| Type | Description |
| - | - |
| HiddenLayer | Rules written and maintained by HiddenLayer. You can view, duplicate, and search by these rules, but you can't edit or delete them. |
| Custom | Rules created by your organization. You can view, edit, duplicate, delete, and search by these rules. |

## View rules

1. In the Console, go to **Runtime Security > Policy**.
2. Select the **Rules** tab.

Each rule card shows the rule name, threat level, description, and whether it's a HiddenLayer or Custom rule. Click a rule card to expand it and see:

* **Policy Packs using this rule**: links to each Policy Pack that includes the rule, with the action that pack takes when the rule matches.
* **Expression**: the CEL expression the rule evaluates.
* Who created and last modified the rule, and when.

### Search and filter rules

* Use **Search Rules** to find a rule by name.
* Filter by rule author: **All**, **HiddenLayer**, or **Custom**.
* Use the filter menu to narrow the list by:
  * **Created**: a creation date range.
  * **Creator**: only rules **Created by me**.
* Use the **Rule Packs** list to show only the rules in a rule pack. Rule packs are curated groups of HiddenLayer rules that you can add to a Policy Pack in one step, organized **By category** or **By framework**.
* Use the sort menu to sort rules by name.

> [!NOTE]
>
> Rule packs contain only HiddenLayer rules, and only custom rules have a creator. Because of this, some filters clear each other. For example, selecting a rule pack clears the **Custom** and **Created by me** filters.

## Create a rule

1. In the Console, go to **Runtime Security > Policy**, then select the **Rules** tab.
2. Click **Add Rule**.
3. Enter the rule details.
   * **Name**: Required. Up to 64 characters. Rule names must be unique.
   * **Description**: Optional. Describe what the rule detects, up to 500 characters.
   * **Threat Level**: Critical, High, Medium, or Low. The default is Medium.
   * **Expression (CEL)**: Required. The CEL expression the rule evaluates. The expression is validated as you type, and you can't create the rule while it has errors.
4. Optionally, click **Import from Saved Query** to use the expression from a saved Investigate query. Editing the imported expression doesn't change the original saved query.
5. Click **Create**.

To use the rule, add it to a Policy Pack and choose its action. See [Policy Packs](https://docs.hiddenlayer.ai/docs/products/runtime/console/runtime_security_policy_packs.md).

## Manage rules

Open the actions menu on a rule card to manage the rule.

### Edit a rule

You can only edit custom rules.

1. Open the actions menu on the rule card and select **Edit Rule**.
2. Make your changes.
3. Click **Save**.

### Duplicate a rule

You can duplicate both HiddenLayer and custom rules. The copy is a custom rule that you can edit.

1. Open the actions menu on the rule card and select **Duplicate Rule**.
2. The new rule is named **Copy of** followed by the original name. Change the name and other details as needed.
3. Click **Create**.

### Search by rule

Open the actions menu on the rule card and select **Search by Rule**. Runtime Security Investigate opens and shows the interactions where the rule was detected.

### Delete a rule

You can only delete custom rules.

1. Open the actions menu on the rule card and select **Delete Rule**.
2. Confirm the deletion.

Deleting a rule also removes it from the custom Policy Packs and Projects that use it.

## Related

* [Policy Packs](https://docs.hiddenlayer.ai/docs/products/runtime/console/runtime_security_policy_packs.md)
* [Projects](https://docs.hiddenlayer.ai/docs/products/runtime/console/runtime_security_projects.md)
