> ## Documentation Index
> Fetch the complete documentation index at: https://anaconda.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Managing policies with the CLI

A policy is a security control you can apply to a channel or mirror to restrict the packages users can source from them. For general information about policies, see [Policies](https://anaconda.com/docs/psm-on-prem/6.8.0/admin/policies.md).

> [!WARNING]
>
> Policy filters only work for conda repositories. If your channel contains Std Python or R packages, use the [mirror filters](https://anaconda.com/docs/psm-on-prem/6.8.0/cli/mirrors.md#filtering-mirrored-packages).

## Creating a policy

To create a policy, use `--create` along with configuration options. These options let you define filtering criteria such as platforms, licenses, CVEs, and package names:

```sh theme={null}
conda repo policy --create \
    --name copperhead_cybersecurity \
    --description "Policy to enforce secure package inclusion for sidewinderscribe channel." \
    --platform linux-64,osx-64 \
    --cve-score 7 \
    --cve-score-comparator "<="
```

Creating a policy doesn't apply it to a channel. To apply it, [assign the policy](#assigning-a-policy) to a channel after you create it.

> [!TIP]
>
> This command is formatted for readability. If your shell supports line continuation (bash, zsh), you can run it as shown. Otherwise, remove the backslashes (`\`) and combine it into a single line.

### Basic configuration options

* `--name`: Set the name of the policy
* `--description`: (Optional) Provide a description for the policy

### Platform filtering options

* `--platform`: Include platforms, separated by commas
* `--platform-not`: Exclude platforms, separated by commas

Available platforms: `linux-32`, `linux-64`, `linux-aarch64`, `linux-armv6l`, `linux-armv7l`, `linux-ppc64`, `linux-ppc64le`, `linux-s390x`, `osx-64`, `osx-arm64`, `win-32`, `win-64`, `zos-znoarch`

### License filtering options

* `--license`: Include licenses, separated by commas
* `--license-not`: Exclude licenses, separated by commas

Supported licenses: `AGPL`, `GPL`, `GPL2`, `GPL3`, `LGPL`, `BSD`, `MIT`, `APACHE`, `PSF`, `Public-Domain`, `Proprietary`, `MOZILLA`, `OTHER`, `None`, `CC`

### Package filtering options

* `--package-name`: Include package names, separated by commas
* `--exclude-package-name`: Exclude package names, separated by commas
* `--exclude-package-name-exception`: Remove exclusions for specified packages, separated by commas
* `--include-dependencies`: Include dependencies
* `--exclude-dependencies`: Exclude dependencies
* `--only-signed-packages`: Restrict to signed packages only
* `--keep-legacy-packages`: Include both `.conda` and `.tar.bz2` files for packages that contain them

### Date-based filtering options

Date format: `YYYY-MM-DD`

* `--package-created-from`: Filter packages created on or after the specified date
* `--package-created-to`: Filter packages created on or before the specified date

### CVE filtering options

* `--cve-score`: Set a CVE score threshold for filtering
* `--cve-score-comparator`: Comparator for CVE score (`==`, `<=`, `>=`, `<`, `>`; default: `<=`). Quote the value on the command line, for example `"<="`.
* `--cve-status`: Include CVE statuses, separated by commas
* `--exclude-cve-status`: Exclude CVE statuses, separated by commas

Supported statuses: `active`, `reported`, `mitigated`, `cleared`, `disputed`

* `--cve-link-status-and-score`: Define the relationship between CVE status and score (`and` or `or`; default: `and`)
* `--cve-allowlist`: Add specific CVE IDs to an allowlist, separated by commas (format: `CVE-YYYY-#####`)
* `--exclude-uncurated-cve-packages`: Exclude uncurated CVE packages

## Viewing policies

To view all policies:

```sh theme={null}
conda repo policy --list-all
```

To view a specific policy:

```sh theme={null}
conda repo policy --show <POLICY_ID>
```

Comments

Replace \<POLICY\_ID> with the ID of your policy.

## Assigning a policy

To assign a policy to a channel:

```sh theme={null}
conda repo policy --assign <POLICY_ID> --channel <CHANNEL_NAME>
```

Comments

Replace \<POLICY\_ID> with the ID of your policy.\\

Replace \<CHANNEL\_NAME> with the name of the channel.

> [!NOTE]
>
> Policies can also be applied directly to mirrors. For more information, see [Creating a mirror with a policy](https://anaconda.com/docs/psm-on-prem/6.8.0/cli/mirrors.md#creating-a-mirror-with-a-policy).

## Unassigning a policy

```sh theme={null}
conda repo policy --unassign <POLICY_ID> --channel <CHANNEL_NAME>
```

Comments

Replace \<POLICY\_ID> with the ID of your policy.\\

Replace \<CHANNEL\_NAME> with the name of the channel.

## Editing a policy

To edit an existing policy, use `--edit` with the same configuration options available for creating a policy, plus the policy ID:

```sh theme={null}
conda repo policy --edit <POLICY_ID> --description "Updated description"
```

Comments

Replace \<POLICY\_ID> with the ID of your policy.

> [!NOTE]
>
> Editing a filtering option clears the previous filter value. For example, if you create a policy with the `win-32` platform filter, running `conda repo policy --edit <POLICY_ID> --platform "win-64"` replaces the `win-32` filter with `win-64`—it does not add both.

> [!TIP]
>
> To clear filters in a policy, provide an empty string for the filtering option using `--edit`. For example, to remove the platform filter, use `--platform ""`. This works for platform and license filtering arguments.

## Deleting a policy

```sh theme={null}
conda repo policy --delete <POLICY_ID>
```

Comments

Replace \<POLICY\_ID> with the ID of your policy.

## Related

* [Policies](https://anaconda.com/docs/psm-on-prem/6.8.0/admin/policies.md): Managing policies through the GUI
* [`policy` command reference](https://anaconda.com/docs/psm-on-prem/6.8.0/cli/commands/policy): Full options and flags
