> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/documentation/use-octoxlabs/policies-and-profiles/security-policies.md).

# Security Policies

Define security policies from saved queries, assign them to asset profiles, and understand how they lower a device's security score.

A security policy is a named check. It holds one or more saved device queries, each with a percentage. A query describes a **bad** state, for example "no EDR agent installed" or "not joined to Active Directory". When a device in an assigned asset profile matches the query, its security score drops by that percentage.

### Before you begin

* Open **Device Profiling** > **Security Policy** in the left menu. You need the permission to add policies to create one.
* Create and save the device queries that describe the conditions you want to penalise. See Create and Save Queries. Policy queries are always device queries.

### The Security Policy list

The list shows **Policy Name**, **Description** and **Active Status** (a switch that turns the policy on or off). Search by name, or select policies and use **Actions** > **Export Selected Items**. Use **Create New Security Policy** to add one.

### Create a security policy

{% stepper %}
{% step %}

#### Open the form

Choose **Create New Security Policy**.
{% endstep %}

{% step %}

#### Name the policy

Enter a **Policy Name** (required). Names must be unique, ignoring upper and lower case. Add a **Description** if you like, and leave **Active** checked to use the policy right away.
{% endstep %}

{% step %}

#### Add queries and percentages

Under **Queries**, select a saved device query and enter its **Percentage**. Choose **Add Row** to add more queries, or the delete icon to remove one. A policy needs at least one query: without it the form shows "You have to add at least 1 query to define security policy."

The percentage is how much a matching device's score drops. Use whole numbers from 1 to 99.
{% endstep %}

{% step %}

#### Assign asset profiles and save

In the **Assigned Asset Profiles** panel, use **Select Asset Profiles** to choose the profiles whose devices should be assessed. You can also assign policies from the profile, see Asset Profiles. Choose **Create**.
{% endstep %}
{% endstepper %}

IMAGEHERE: The Create New Security Policy form with two query rows with percentages, and the Assigned Asset Profiles panel.

### How the security score is calculated

The score is calculated for each device at the end of every discovery, in the step **Octoxlabs Security Score Calculation**, and is stored in the `OctoxlabsSecurityScore` field.

1. Only **active** profiles and **active** policies take part.
2. A device is scored only if it matches an active asset profile. A device that matches no active profile has no score and is left out of averages.
3. A device that matches an active profile starts at a score of 100. If none of the policy queries assigned to the profile match it, the score stays 100.
4. For each assigned policy whose query matches the device, the device's current score is lowered by the query's percentage and rounded up to a whole number. Reductions from several policies are applied one after another.
5. A policy lowers a device's score once. If the same policy reaches a device through two profiles, or two of its queries both match, it is not applied twice, and the device detail page lists the policy once.

Changes to profiles or policies take effect at the next discovery. Dashboards show the result as the overall score, a score per severity or query, a history, or the devices with the lowest scores. See the Chart and widget reference.

{% hint style="warning" %}
Percentages are not points. A policy of 20% lowers the current score by 20% of its value, so the same policy takes fewer points from a device that has already lost score to another policy.
{% endhint %}

### Edit or delete a policy

Open a policy to change its name, queries, percentages, status or assigned profiles, then choose **Save**. To stop using a policy without losing it, switch **Active Status** off in the list. Removing a profile from the **Assigned Asset Profiles** panel shows a notice that the profile was removed from the policy.

### Example policies

A new installation includes four example policies, all inactive. Each uses one built-in device query.

| Policy                        | Percentage |
| ----------------------------- | ---------- |
| DLP not Installed Policy      | 20         |
| AD Joined Policy              | 30         |
| EDR/ EPP not Installed Policy | 40         |
| CVSS3 Score up to 7+ Policy   | 50         |

### Troubleshooting

| Symptom or message                                 | Cause                                                                                  | Fix                                                                             |
| -------------------------------------------------- | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| "A policy with this name already exists."          | Another policy has the same name, ignoring case.                                       | Choose a different name.                                                        |
| "Percentage must be between 1 and 99."             | The percentage is outside the allowed range.                                           | Enter a whole number from 1 to 99.                                              |
| A device has no score although a policy matches it | The device is not in an active profile, or the policy is not assigned to that profile. | Check the profile query and **Assigned Security Policies**. See Asset Profiles. |
| The score did not change after an edit             | Scores are recalculated during a discovery.                                            | Start a discovery or wait for the next one. See Discovery and Aggregation.      |

### What's next?

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Asset Profiles</strong></td><td>Choose which devices a policy is assessed on.</td><td></td></tr><tr><td><strong>Create and Save Queries</strong></td><td>Write the queries that describe a bad state.</td><td></td></tr><tr><td><strong>Dashboards</strong></td><td>Show the score and the lowest-scoring devices.</td><td></td></tr></tbody></table>
