# Create Content Compliance Rule - Monitoring

{% hint style="info" %}
This document is only applicable to new customers who are setting up Gmail DLP for the first time. If you are an existing customer and have setup Gmail DLP previously, refer [this documentation](https://help.nightfall.ai/gmail/installation/content_compliance_rules/monitroring-1).
{% endhint %}

The first content compliance rule is used to monitor all outgoing emails.&#x20;

{% hint style="info" %}
**Important**

It is mandatory for you to create this rule to monitor outgoing emails for sensitive data.&#x20;
{% endhint %}

## Prerequisites

In the Nightfall UI, navigate to **Integrations** from the left navigation bar and click the **Manage** button for the Gmail integration.&#x20;

<figure><img src="https://2214688951-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mg3wgFIu8T7XAT1u-f_%2Fuploads%2Fx50tBf6b8clyp92OWifU%2Fimage.png?alt=media&#x26;token=c2b9520d-ce2e-442b-9bcb-484fa58a7e5f" alt=""><figcaption></figcaption></figure>

All the headers and expressions required to create the compliance rules are available in the **Installation** section under Gmail settings as displayed in the image below. Keep this screen open to copy/paste the headers as you create the content compliance rules in Google Workspace. We will refer to this page as the **Gmail settings** page throughout the document.&#x20;

<figure><img src="https://2214688951-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mg3wgFIu8T7XAT1u-f_%2Fuploads%2FkRhioBDvmyAfoTw9Rp9W%2Fimage.png?alt=media&#x26;token=bc14b829-557c-4ccf-a443-18cff369c289" alt=""><figcaption></figcaption></figure>

## Content Compliance Rule

The steps to create content compliance rule are as follows.&#x20;

1. Log in to your Google Workspace with an admin account.
2. Navigate to the admin console.&#x20;
3. From the left menu, expand **Apps** > **Google Workspace > Gmail.**
4. Scroll down and click **Hosts**.
5. Click **ADD ROUTE**.

<figure><img src="https://2214688951-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mg3wgFIu8T7XAT1u-f_%2Fuploads%2FNpEhDujnPEHx1HOnvRAb%2Fimage.png?alt=media&#x26;token=8480ad5c-343a-4306-ac7e-c9f1cf1b355a" alt=""><figcaption></figcaption></figure>

6. Enter a name for the mail route.&#x20;
7. Type the following host name.

```http
2r2xfv8u7uz5.fips.qbns.mail-manager-smtp.amazonaws.com
```

8. Enter **25** as the port number.&#x20;
9. Click **SAVE**.

<figure><img src="https://2214688951-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mg3wgFIu8T7XAT1u-f_%2Fuploads%2Fo4evo9Y9QPjkyzVV7YVw%2Fimage.png?alt=media&#x26;token=2aecba1e-7487-4476-b61b-f4ad274c27de" alt="" width="375"><figcaption></figcaption></figure>

10. Scroll down and click **Compliance**.

<figure><img src="https://2214688951-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mg3wgFIu8T7XAT1u-f_%2Fuploads%2FPfbSSnvD0uLOrHPWWfgP%2Fimage.png?alt=media&#x26;token=b24132da-b280-425e-85da-2c4c5e6d0884" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
When you click **Compliance**, you can view the list of Organization Units (OUs) on the left of the screen (see image below). You can directly configure the compliance rules and routing rules on your production OU (OU at the top most level) by selecting the same.&#x20;

However, Nightfall recommends that you initially configure the rules on a subset OU (one of the nested OUs) which has a small set of users. When you click on a nested OU, the rules are created only for the nested OU that you select. Once you verify that the configuration is working as expected on the nested OU, you can configure the compliance rules on the production OU.&#x20;
{% endhint %}

<figure><img src="https://2214688951-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mg3wgFIu8T7XAT1u-f_%2Fuploads%2FXtsYSSVF94uxKSYNSQvm%2Fimage.png?alt=media&#x26;token=c4929ee4-41f0-40ae-9c4c-cdb06d54d9e5" alt="" width="563"><figcaption></figcaption></figure>

5. Scroll down to the **Content Compliance** section and click **ADD ANOTHER RULE**. (If you have not created any Compliance rule previously, the button might be displayed as **CONFIGURE**).

<figure><img src="https://2214688951-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mg3wgFIu8T7XAT1u-f_%2Fuploads%2FhzYUMTB0QlfN2BaQJcFs%2Fimage.png?alt=media&#x26;token=f81f66a2-f021-4321-a23f-bc039d4e025a" alt=""><figcaption></figcaption></figure>

### **Step 1 - Email Messages to Affect**

1. Enter a name for the compliance rule. For example, Nightfall DLP.
2. Select **Outbound** and **Internal - Sending** checkboxes in the **Email messages to affect** section.

<figure><img src="https://2214688951-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mg3wgFIu8T7XAT1u-f_%2Fuploads%2FNmu7H3nwFTEFT1A1zF0j%2Fimage.png?alt=media&#x26;token=42f106d6-1c78-4c4b-918d-1459c37be27b" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="info" %}
If you select only the **Outbound** check box, only those emails that are routed out of your organization to external domains, are scanned. If you wish to scan internal emails (emails that are sent between the employees of your organization), you must select the **Internal - Sending** check box.
{% endhint %}

### Step 2 - Add Expressions

1. In step 2 of the content compliance rule, select the **If ALL of the following match the message** option.
2. You need to **add two expressions in step 2 of content compliance rule.** Click **ADD**.

<figure><img src="https://2214688951-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mg3wgFIu8T7XAT1u-f_%2Fuploads%2FVD32ndvRfq2T95j8hvnI%2Fimage.png?alt=media&#x26;token=95dc193b-4ff0-4806-8e43-ad9b07312424" alt="" width="563"><figcaption></figcaption></figure>

3. In the **Add** **setting** dialog box, select the **Advanced Content** match option.
4. In the **Location** drop-down menu, select **Sender header.**
5. In the **Match** **type** drop-down menu select **Matches Regex.**
6. Navigate to the **Gmail settings** page on the Nightfall UI, refer to the regular expression format defined under the **Monitoring Content Compliance Rule** section, and create a regular expression that matches your organization name.

{% hint style="info" %}
For example, if your organization name is Contoso.com, you can create the regular expression as `.*@contoso\.com$`

If you are using multiple domains to send emails from your organization and you need to scan outgoing emails from all those domains for sensitive data, you can use a regular expression to specify multiple domains as illustrated in installation instructions in the Nightfall console. For example, `(.`*`@domain-name.extension$|.`*`@domain-name.extension$)`
{% endhint %}

7. In the **Regexp** field, enter the regular expression to match your organization name.
8. Click **SAVE**.

<figure><img src="https://2214688951-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mg3wgFIu8T7XAT1u-f_%2Fuploads%2FHHAABrHoJCBw5fPWZHdk%2Fimage.png?alt=media&#x26;token=b1721aa2-9fca-42d6-8dc9-b76614ed34d0" alt="" width="563"><figcaption></figcaption></figure>

9. You can now add a second expression in step 2 of the content compliance rul&#x65;**.** Click **Add**.
10. Select **Advanced content match** in the drop-down menu.
11. In the **Location** drop-down menu, select **Full headers**.
12. &#x20;In the **Match** **type** drop-down menu select **Not Contains text.**
13. Navigate to the **Gmail settings** page on the Nightfall UI and copy the value from the **Header** field, located under the **Full Header** section.&#x20;
14. Return to the Google Admin Workspace window and paste the copied value in the **Content** field.
15. Click **SAVE**.

<figure><img src="https://2214688951-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mg3wgFIu8T7XAT1u-f_%2Fuploads%2FzIcM2ZXZ1oTcJgAWwPIk%2Fimage.png?alt=media&#x26;token=3aa4e5ef-2ec5-42f0-813c-d313bbb41f80" alt="" width="563"><figcaption></figcaption></figure>

The condition expression is created as follows. This expression ensures that all the emails that are not yet scanned by Nightfall are scanned.

<figure><img src="https://2214688951-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mg3wgFIu8T7XAT1u-f_%2Fuploads%2Fpu0tZbhZ7G2RPg6ftiKq%2Fimage.png?alt=media&#x26;token=881edbf9-75ad-4ef3-a429-c0fe79a5436e" alt="" width="563"><figcaption></figcaption></figure>

### Step 3 - Modify Message and Add Custom Headers

1. In step 3, select **Modify message**.
2. Under the **Headers** section, select the **Add X-Gm-Original-To header** check box.
3. &#x20;Select the **Add custom headers** check box. The **Custom headers** section is displayed once you select this check box.
4. Click **ADD** under **Custom headers** to add a new custom header.

<figure><img src="https://2214688951-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mg3wgFIu8T7XAT1u-f_%2Fuploads%2Fk3MvUE9slR1DDrQp2Lid%2Fimage.png?alt=media&#x26;token=1df17e91-bd69-4f69-9828-34f2adcb25e9" alt="" width="563"><figcaption></figcaption></figure>

There are two fields; **Header key** and **Header value**.

<figure><img src="https://2214688951-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mg3wgFIu8T7XAT1u-f_%2Fuploads%2FI8yr0G6bDR0azYxH8aTK%2Fimage.png?alt=media&#x26;token=2e377333-5ba8-4463-9a50-052297031a02" alt="" width="563"><figcaption></figcaption></figure>

5. Navigate to the **Gmail settings** page on the Nightfall UI and copy the value from the **Authentication** field, located under the **Messaging Modification** section.
6. Return to the Google Admin Workspace window and paste the copied value in the **Header key** fiel&#x64;**.**&#x20;
7. Navigate to the **Gmail settings** page on the Nightfall UI and copy the value from the **Nightfall UUID** field, located under the **Messaging Modification** section.
8. Return to the Google Admin Workspace window and paste the copied value in the **Header value** field.&#x20;
9. Click **SAVE**.

<figure><img src="https://2214688951-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mg3wgFIu8T7XAT1u-f_%2Fuploads%2F3CiyhxQYb2RYeA804Nlm%2Fimage.png?alt=media&#x26;token=91cdd51b-d4b8-4385-bfce-718d2fdc4b9a" alt="" width="563"><figcaption></figcaption></figure>

10. Scroll down to the **Route** section and select the **Change Route** check box.&#x20;
11. From the dropdown menu, select the routing rule created in the [#content-compliance-rule](#content-compliance-rule "mention") section (step 5).&#x20;

<figure><img src="https://2214688951-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mg3wgFIu8T7XAT1u-f_%2Fuploads%2FEOyLX9unh6XYLlMn4Qok%2Fimage.png?alt=media&#x26;token=34f524a1-9284-40fe-ba4f-3be474334665" alt="" width="563"><figcaption></figcaption></figure>

12. Scroll down to the **Encryption (onward delivery only)** section and select the **Require secure transport (TLS)** check box.&#x20;
13. Click **SAVE**.

<figure><img src="https://2214688951-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mg3wgFIu8T7XAT1u-f_%2Fuploads%2FKsDeo2urGRTUYSj9wsxV%2Fimage.png?alt=media&#x26;token=127d3a73-8fd2-4469-bfec-6aa55b3eeeda" alt="" width="375"><figcaption></figcaption></figure>
