> 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/adapters/c/csv-file-policies.md).

# CSV File Policies

The CSV File Policies adapter reads security policies and rules from a CSV file on the connector host and adds them to the inventory.

## Use cases

* List imported policies.

```
Adapters = csv-file-policies
```

## Before you begin

### Network

| Source         | Destination                                                            | Port | Protocol |
| -------------- | ---------------------------------------------------------------------- | ---- | -------- |
| Not applicable | The file is read from the connector host. No network access is needed. | -    | -        |

### Required permissions

| Scope or role           | Permission | Needed for                                                                       |
| ----------------------- | ---------- | -------------------------------------------------------------------------------- |
| Read access to the file | Read       | The connector process must read the file in `/opt/octoxlabs/connector/media/csv` |

## Create credentials in CSV File Policies

This adapter has no credentials. Prepare the file instead.

{% stepper %}
{% step %}

### Create the CSV file

Create a CSV file with a header row. Name the columns with the canonical column names listed in **Fields fetched** so that rows map automatically. Separate multiple values in one cell with the list separator (default `|`).
{% endstep %}

{% step %}

### Copy the file to the connector

Copy the file to `/opt/octoxlabs/connector/media/csv` on the connector host. The connector must be able to read it, so check the file permissions.
{% endstep %}

{% step %}

### Name the file

Enter the file name in the **Filename** parameter. A glob pattern such as `export_*.csv` is allowed. When several files match, the most recently modified file is used.
{% endstep %}

{% step %}

### Fill the required columns

**PolicyType** is required in every row. Use one of `NetworkPolicy`, `DevicePolicy`, `ApplicationPolicy`, `IdentityPolicy` or `DatabaseAccessPolicy`. Other rows are skipped.
{% endstep %}

{% step %}

### Format addresses and ports

Separate several addresses or ports with the list separator, for example `10.0.0.0/8|192.168.0.0/16`. `any` or `all` means every address.
{% endstep %}

{% step %}

### Set the direction

Internet facing is calculated only when **Direction** is `Inbound`, `Outbound` or `Both`. Disabled rules and deny, block or drop actions are never internet facing.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter         | Required | Type               | Default    | Description                                                                                                                   |
| ----------------- | -------- | ------------------ | ---------- | ----------------------------------------------------------------------------------------------------------------------------- |
| Filename          | Yes      | Text               |            | Name or glob pattern of the CSV file, relative to `/opt/octoxlabs/connector/media/csv`. Absolute paths and `..` are rejected. |
| Primary Key Field | No       | Text               | PrimaryKey | Name of the column with the unique identifier of each row. Rows without a usable primary key are skipped.                     |
| Separator         | No       | Text (1 character) | ,          | Column separator.                                                                                                             |
| List Separator    | No       | Text (1 character) | \|         | Separator for several values in one cell.                                                                                     |
| Quote Char        | No       | Text (1 character) | "          | Quote character for cell values.                                                                                              |

## Troubleshooting

| Error message                                                                 | Cause                                       | Fix                                                        |
| ----------------------------------------------------------------------------- | ------------------------------------------- | ---------------------------------------------------------- |
| File not found with this pattern.                                             | No file in the CSV folder matches Filename. | Copy the file to the folder and check the name or pattern. |
| No such file.                                                                 | The resolved path is not a file.            | Check Filename.                                            |
| (file name) file is empty.                                                    | The file has no header row.                 | Add a header row.                                          |
| An absolute path is not allowed; give a name relative to the adapter's folder | Filename starts with `/`.                   | Use a relative name.                                       |
| '..' is not allowed; the file must stay inside the adapter's folder           | Filename contains `..`.                     | Use a name inside the CSV folder.                          |

## Change history

{% hint style="info" %}
Available starting from version 6.9.1.
{% endhint %}
