# Creating and managing custom sensitivity rules

{% hint style="info" %}
**Required license:** Professional

**Required global permission:** Create and manage sensitivity rules
{% endhint %}

By default, when a Structural security scan runs on a workspace, it looks for the [built-in sensitivity types](https://docs.tonic.ai/app/generation/identify-sensitive-data/sensitivity-types-built-in).

You can also define custom sensitivity rules to identify other values and the corresponding recommended generator. Your data might include values that are specific to your organization.

Each custom sensitivity rule specifies:

* The data type for matching columns.
* Text matching criteria for the names of matching columns.
* The recommended generator preset.

## Displaying the list of custom sensitivity rules <a href="#sensitivity-rules-list" id="sensitivity-rules-list"></a>

To display the current list of sensitivity rules, in the Structural navigation menu, click **Sensitivity Rules**.

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2FzBw3c5NyWim0cqRDTrI0%2FSensivityRulesList.png?alt=media&#x26;token=ada9b15a-a3f5-463b-8867-7e6e1bd79ced" alt=""><figcaption><p>Sensitivity Rules view with the list of custom sensitivity rules</p></figcaption></figure>

The list contains the sensitivity rules for a self-hosted Structural instance or a Structural Cloud organization.

For each rule, the list includes:

* The rule name and description
* The recommended generator preset
* When the rule was most recently modified

## Filtering the rules <a href="#sensitivity-rules-filter" id="sensitivity-rules-filter"></a>

You can filter the rule list by the following:

* Rule name
* Rule description
* Generator preset name
* Name of the user who most recently updated the rule

In the filter field, start to type text from any of those values. As you type, the list is filtered to only include matching rules.

Note that when the list is filtered, you cannot change the display sequence of the rules.

## Setting the rule sequence <a href="#sensitivity-rules-sequence" id="sensitivity-rules-sequence"></a>

Structural applies the rules based on their display order in the list.

If a column matches more than one rule, Structural applies the first matching rule.

To change the display order of a rule, drag and drop it to the new location in the list.

Note that you cannot change the rule sequence when the list is filtered.

## Creating and editing a sensitivity rule <a href="#sensitivity-rule-create-edit" id="sensitivity-rule-create-edit"></a>

### **Creating a sensitivity rule** <a href="#sensitivity-rule-create" id="sensitivity-rule-create"></a>

To create a sensitivity rule:

1. On the **Sensitivity Rules** view, click **New Custom Rule**.
2. On the **Create Custom Rule** view, [configure the new rule](#sensitivity-rule-config).
3. Click **Save**.

### **Editing a sensitivity rule** <a href="#sensitivity-rule-edit" id="sensitivity-rule-edit"></a>

To change the configuration of a sensitivity rule:

1. On the **Sensitivity Rules** view, click the edit icon for the rule.
2. On the **Edit Custom Rule** view, [update the configuration](#sensitivity-rule-config).
3. Click **Save**.

Note that any changes to a sensitivity rule do not take effect until the next sensitivity scan.

## **Sensitivity rule configuration** <a href="#sensitivity-rule-config" id="sensitivity-rule-config"></a>

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2Fi69B985JB7AX8HMoM3uJ%2FSensitivityRuleDetailsFull.png?alt=media&#x26;token=506be7de-113e-488d-bb9f-43e426a46751" alt=""><figcaption><p>Details view for a custom sensitivity rule</p></figcaption></figure>

### **Rule name and description** <a href="#sensitivity-rule-name-description" id="sensitivity-rule-name-description"></a>

In the **Name** field, type the name of the sensitivity rule. The rule name becomes the sensitivity type for matching columns. The rule name must be unique, and also cannot match the name of a built-in sensitivity type.

Optionally, in the **Description** field, type a longer description of the sensitivity rule.

### **Data type** <a href="#sensitivity-rule-data-type" id="sensitivity-rule-data-type"></a>

From the **Data Type** dropdown list, select the data type for matching columns. For example, a rule might only be used for columns that contain text.

The available data types are general types that map to specific data types in a given database. The available types are:

* Array
* Binary
* Boolean
* Continuous Numerical
* Date Range
* Datetime
* Integer
* JSON
* MAC Address
* Network Address
* Text
* UUID
* XML

### **Column name criteria** <a href="#sensitivity-rule-column-name-conditions" id="sensitivity-rule-column-name-conditions"></a>

Under **Column Name Match**, provide the criteria to identify matching columns based on the column name.

Note that a matching column must match both the data type and the column name criteria.

#### **Configuring text matching conditions** <a href="#column-name-criteria-text-match" id="column-name-criteria-text-match"></a>

When you provide a list of text matching conditions, a matching column must match all of the conditions. In other words, the conditions are joined by `AND`.

To apply the same generator preset to columns that have completely different names, you must create separate sensitivity rules.

To create a list of text matching conditions:

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2FKnC9U3iiy8IestPv8bLo%2FSensitivityRuleColumnNameMatches.png?alt=media&#x26;token=6309d751-1b3a-4d58-ad3a-f0ca4781a7ce" alt=""><figcaption><p>Column name text match rules for a custom sensitivity rule</p></figcaption></figure>

1. Click **Text Match**.
2. To add a column name condition, click **Add String Match**.
3. For each condition:
   1. From the comparison type dropdown list, select the type of comparison. For example, **Contains**, **Starts with**, **Ends with**.
   2. In the comparison text field, provide the text to check for.\
      \
      The comparison text is case insensitive. For example, if you set a condition to match column names that contain the text `term`, it also matches column names that contain `TERM` or `Term` or `tErM`.
4. To remove a column name condition, click its delete icon.

#### **Providing a regular expression** <a href="#column-name-criteria-regex" id="column-name-criteria-regex"></a>

To use a regular expression to identify matching columns based on the column name:

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2Fw4bsODLE1KBc1f2YVv7M%2FSensitivityRuleRegexMatch.png?alt=media&#x26;token=e14b351c-37a5-4ffb-8884-6182e09cd31f" alt=""><figcaption><p>Column name regular expression field for a custom sensitivity rule</p></figcaption></figure>

1. Click **Regular Expression**.
2. In the field, provide the regular expression.

### **Generator preset to apply** <a href="#sensitivity-rule-generator-preset" id="sensitivity-rule-generator-preset"></a>

From the **Recommended Generator Preset** dropdown list, select the generator preset that is the recommended generator for matching columns.

To search for a specific preset, begin to type the generator preset name.

## Managing generator preset configuration <a href="#sensitivity-rule-preset-config" id="sensitivity-rule-preset-config"></a>

{% hint style="info" %}
**Required global permission:** Create and manage generator presets
{% endhint %}

When you configure a sensitivity rule, you can also create a new generator preset or update the configuration of the selected generator preset.

To create a new generator preset, click **Create Preset**. On the generator preset details panel, provide the generator preset configuration, then click **Create**.

To edit the selected generator preset, click **Edit Current Preset**. On the generator preset details panel, update the generator preset configuration, then click **Save and Apply**.&#x20;

For more information about generator preset configuration, go to [#generator-presets-configure](https://docs.tonic.ai/app/generators-assign-config/generator-presets#generator-presets-configure "mention").

## Previewing the rule results

If you have access to a workspace, then you can use the workspace to preview the sensitivity rule results.

Under **Test Results**, from the workspace dropdown list, select the workspace to use.

Structural searches the workspace schema for matching columns based on the sensitivity rule configuration.

It displays any matching columns. You can filter the matching columns based on the table or column name.

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2FTNOJlm9EojxBpAOMwIkE%2FSensitivityRuleTestResults.png?alt=media&#x26;token=dd882909-b8f7-4c93-b08e-ef1f3d99bad5" alt=""><figcaption><p>Test Results section to preview the results for a sensitivity rule</p></figcaption></figure>

For each matching column, the list includes:

* The column name and table
* A sample value from the source data. The sample source value is only present if you have the **Preview source data** permission for the workspace.
* A sample replacement value, based on the selected generator preset for the sensitivity rule. The sample replacement value is only present if you have the **Preview destination data** permission for the workspace.

## **Deleting a sensitivity rule** <a href="#sensitivity-rule-delete" id="sensitivity-rule-delete"></a>

To delete a sensitivity rule, on the **Sensitivity Rules** view, click the delete icon for the rule.

Note that existing generator recommendations for the rule remain in place until the next sensitivity scan.
