==============
Policy filters
==============

.. caution::

   Policy filters are only available to Business and Enterprise tier customers.

A policy filter is an additional security measure you can apply to a channel to restrict the available packages that can be sourced from it. You can filter packages by license family, common vulnerability and exposure (CVE) score, CVE status, package age, platform, and by using conda spec. For more information about CVE scores and statuses, see :doc:`Common Vulnerabilities and Exposures (CVEs) <cve>`.

Creating a policy filter
========================

#. From the |satellite-dish| **Channels** page, click **Create** |plus| under **POLICIES**.

   .. thumbnail:: ../img/ab_create_policy.png
      :align: center

#. Provide a unique name for your policy. Anaconda recommends making it something descriptive.
#. In the **Exclude package if** section, click |filter| **Add filter**.
#. In the **FILTER GROUP** section that appears, set filter parameters for packages you wish to *exclude* from channels with this policy. 
#. Click |filter| **Add Filter to Group** to include additional parameters for this filter group, or click |filter| **Add filter** to add a separate filter for this policy. 
#. Repeat this process to apply further package filtering preferences.
#. If necessary, in the **Override exclusions and include a package if** section, click |filter| **Add filter**. Here, you can apply filters to *include* specific packages that would otherwise be *excluded* by this filter. 

   .. note::

      You can only include packages based on `conda spec <https://docs.conda.io/projects/conda-build/en/latest/resources/package-spec.html#package-match-specifications>`_. 

.. dropdown:: Example policy filter
      :animate: fade-in
      :color: primary

         Let's say you want to filter out packages with a CVE score greater than 7, but only if their CVE Status has not been *Cleared* by NIST. Your policy filter would look like this:

         .. thumbnail:: ../img/ab_policy_filter_dialog.png
            :align: center

Applying a policy filter
========================

Applying a policy filter to a channel restricts the packages that are able to be sourced from it. 

#. From the |satellite-dish| **Channels** page, click **Apply** |plus| beside a channel's name. 
#. Select a policy to apply to the channel.
#. Click **Apply** to confirm. 

Once the policy is applied, the status beneath the policy will transition through the following phases:

* In Queue
* In Progress
* Completed
* Scheduled

The **Scheduled** status indicates the channel is set to auto-update. This means the filter will be reapplied to the channel every four hours and will update the channel's contents accordingly. 

.. note:: 

    Remove the policy filter by clicking |X| **Remove Policy**  beside the policy name in the channel list. 

Package files that have been removed from a channel due to a policy filter display the specific reasons they were excluded. 

.. thumbnail:: ../img/ab_channel_artifacts_removed.png
    :align: center

.. note:: 

    Removed files are not grouped, and some packages have multiple pages of files. For packages with many files, it is best to use the search box to narrow results.

Editing a policy filter
=======================

.. caution::
    
    Policies that are currently in use cannot be edited.

#. Select the policy name from the **POLICIES** list. 
#. Change the parameters of the filter as if you were creating a policy. 
#. Click **Save**.

.. note:: 

    A |triangle-exclamation| warning displayed beside your filter indicates that it has become deprecated. Deprecated filters still work, but Anaconda recommends you update your policies to no longer use these filters.

Viewing the policy report
=========================

Once you have applied a policy filter to a channel, view the **Policy Report** to see a breakdown of the number of package files across various platforms that have been removed, and how many remain.

From the |satellite-dish| **Channels** page, click the **POLICY RESULTS** for any channel to open the **Policy Report**.

.. thumbnail:: ../img/ab_artifacts_removed.png
   :align: center

.. note:: 
    
    From here, you can download the policy report or the :ref:`policy report delta <channel_deltas>` in ``.csv`` format.

.. |plus| raw:: html

      <i class="fa-light fa-plus"></i>
              
.. |triangle-exclamation| raw:: html

   <i class="fa-solid fa-triangle-exclamation"></i>

.. |filter| raw:: html

   <i class="fa-solid fa-filter"></i>

.. |pencil| raw:: html

   <i class="fa-solid fa-pencil"></i>

.. |satellite-dish| raw:: html

    <svg xmlns="http://www.w3.org/2000/svg" height="1em" width="1em" viewBox="0 0 512 512"><path d="M192 24c0 13.3 10.7 24 24 24c137 0 248 111 248 248c0 13.3 10.7 24 24 24s24-10.7 24-24C512 132.5 379.5 0 216 0c-13.3 0-24 10.7-24 24zm24 80c-13.3 0-24 10.7-24 24s10.7 24 24 24c79.5 0 144 64.5 144 144c0 13.3 10.7 24 24 24s24-10.7 24-24c0-106-86-192-192-192zm-7 233l40-40c9.4-9.4 9.4-24.6 0-33.9s-24.6-9.4-33.9 0l-40 40L71 199c-13.5-13.5-35.9-12.3-45.1 4.4C9.4 233.2 0 267.5 0 304C0 418.9 93.1 512 208 512c36.5 0 70.8-9.4 100.6-25.9c16.7-9.2 17.8-31.6 4.4-45.1L209 337zM48 304c0-18.1 3-35.5 8.5-51.6L259.6 455.5C243.5 461 226.1 464 208 464c-88.4 0-160-71.6-160-160z"/></svg>

.. |X| raw:: html

    <i class="fa-solid fa-xmark"></i>