Skip to main content
Although you can’t create a custom rule yourself yet—we do that for you—you can add it when it’s ready. All you need is Expert Editor and the config files located in the activeguard/core/rule_sets/90_local/ folder:
  1. Open Expert Editor.
  2. In the folder view in the left pane, expand activeguard, then core, rule_sets, and finally 90_local. You will see three folders: params, rules, and templates: Folders containing rules
  3. Use the context menu for the rules folder to create a new file: Hamburger icon for the context menu
  4. Enter <rule_name>.xml—for example, CUSTOM_spam_keyword_match.xml—as the name for the file in the dialog box that appears, and click Create. The rule can also be put into arbitrary subfolders of the rules folder.
  5. Click the file you have just created in the left pane and paste the content of the custom rule we provided to you into the right pane.
  6. Now, expand the params folder in the left pane and click the local.properties file. In the right pane, add the state parameter to activate the rule. The parameter should consist of the name of the rule XML file you created in the step #4 with the _state suffix and the ACTIVE keyword, e.g., CUSTOM_spam_keyword_match_state=ACTIVE. Click Publish.

Custom rule with a reference to a new custom list

In case your custom rule references to a new custom list, you will also need to add this new custom list.
Creating the lists folderIf there is no lists folder inside 90_local, hover the mouse cursor over the folder icon next to 90_local. The icon will change to a vertical ellipsis (…) or a hamburger (see step #3 in the previous section). Click it to display the context menu, select New Folder, enter lists as the name of the folder in the dialog box that appears, and click Create.
  1. Use the context menu for the lists folder to create a new file inside of it (see step #5 in the previous section).
  2. Enter <list_name>.list.info.json—for example, CUSTOM_spam_domains.list.info.json—as the name for the file in the dialog box that appears and click Create.
  3. Click the file you have just created in the left pane and add the following content to this file in the right pane (the values in the key:values pairs here are just examples):
    where
    • displayName is the title/name of the list (no.1 on the screenshot below)
    • category is the name of the category the list belongs to (existing or a new one; no.2 on the screenshot below)
    • description is the description of the list displayed in the right pane after selecting a list in the left pane of the Lists view (no.3 on the screenshot below).
    List elements in the Lists view
  4. Click Publish to apply changes. Will be automatically active after one minute. The new list should be visible on the Lists page.

Adding a YARA rule

You can block emails using a YARA rule by adding it to a custom rule. This YARA-based rule consists of 3 main elements:
  1. Condition that applies the rule to specified objects.
  2. Actual YARA rule.
  3. Decision which tags or quarantines the matched email.
In the activeguard/core/rule_sets/90_local/rules/examples folder, you will find an example empty rule:
Let’s modify this example to create a YARA rule. We’re going to implement a YARA rule which finds a CVE-2018-0802 exploit of a vulnerability in Word, so it needs to be applied to Word and RTF files.
  1. Start with giving a name to your rule, e.g., YARA_cve_2018_0802, activating the rule in the state property, and selecting the email flow it should be applied to in applyTo:
    The allowed values for applyTo are: ALL, INCOMING, OUTGOING, INTERNAL. The priority values are within the range of 0-1000. We recommend setting the priority to at least above 20 to ensure the built-in tag rules still apply. Then, either set it between 300 and 400 to ensure the rule has precedence over the built-in quarantine rules, or set it above 700 to ensure that it does not have precedence over the built-in quarantine rules, i.e., is applied afterward.
  2. Write a condition that would match all Word and RTF attachments during the file scan:
  3. Now, add the actual YARA rule and close the condition block:
  4. It’s time to decide what to do when an attachment matches your YARA rule. The simplest approach is to tag the message (here we used the exploit name as a tag), and then create a campaign that will, for example, quarantine the emails with this tag:
  5. Finish your custom rule by closing the condition:
The whole rule should look like this:

Multiple YARA rules

It is possible to use multiple YARA rules in one custom rule. All you have to do is to put them in the <or>…</or> block, just like you did with the fileType selector: