===================
Environments |beta|
===================

.. note::

    This feature is in beta testing. 

Administrators can monitor the packages installed in user environments, view any Common Vulnerabilities and Exposures (CVEs) associated with them and, if necessary, enforce security standards by blocking the environment from use. IT administrators can also provide a custom message to guide users through environment remediation. This telemetric data assists your IT administrators with auditing tasks by ensuring users are compliant with your security requirements and providing historical tracking for infrastructure audits. 

Members can use these tools to ensure their local environments are in compliance with organizational security requirements and avoid machine quarantines or losing access to an environment due to administrator intervention. 

In order to utilize the Environments feature, *organization members (including administrators) must first complete the required setup steps to enable environment management*. For more information and instructions for enabling environment management, see the :ref:`Quickstart guide <env_mgmt_setup>`.

Logging environments
====================

With ``anaconda-env-log`` installed, all newly created environments are automatically logged within conda, and existing environments are automatically logged whenever you perform certain ``conda`` actions (``install``, ``remove``, ``rename``, or ``update``) in them. Existing environments can also be logged manually by running the following command: 

.. caution::

    You must log in to Anaconda Cloud using the CLI prior to manually logging an environment.

    .. code-block:: none

        # Replace <ENV_NAME> with the  name of the environment you want to log to your organization
        conda env-log log --name <ENV_NAME>

Viewing logged environments
===========================

Environments logged with an organization can be viewed at any time from the |environments| **Environments** page. Members can view the environments they've logged, while administrators have access to view every environment logged with the organization. 

#. Navigate to your |organizations| page. 
#. Select your organization.
#. Select |environments| **Environments** from the left-hand navigation.

    .. thumbnail:: ../img/view_org_environments.png

The **Environments** page shows you:
    * Environment names and locations
    * The number of packages in the environments
    * The number of CVEs associated with the packages in the environments
    * The environment's creator
    * The last time the environments were updated

.. tip:: 
    
    Use the filters at the top of the table to locate environments efficiently. 

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

Exploring logged environments
=============================

Environments that are logged with an organization can be browsed to gain insights into the packages that they contain. You can see which packages are present in the environment as well as any CVEs associated with them. 

Viewing environment packages
----------------------------

The environment's **Packages** page shows you which packages are in an environment and what channels they were sourced from.

#. Navigate to your |organizations| page. 
#. Select your organization.
#. Select |environments| **Environments** from the left-hand navigation.
#. Select the package count displayed under the **PACKAGES** column.

    .. thumbnail:: ../img/env_pkgs.png
        :align: center
        
.. note:: 
    
    Use the navigation controls at the bottom to browse the environment's packages.

Viewing CVEs
------------

.. tab-set:: 

    .. tab-item:: Viewing environment CVEs

        The **CVEs** panel shows all of the CVEs associated with the environment by name and severity. 

        #. Navigate to your |organizations| page. 
        #. Select your organization.
        #. Select |environments| **Environments** from the left-hand navigation.
        #. Select the CVE count displayed under the **CVES** column.

        Use the filters at the top of the panel to locate critical CVEs efficiently.

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

    .. tab-item:: Viewing package CVEs

        Narrow your view to CVEs associated with a specific package in an environment: 

        #. Navigate to your |organizations| page. 
        #. Select your organization.
        #. Select |environments| **Environments** from the left-hand navigation.
        #. Select the package count displayed under the **PACKAGES** column.
        #. Locate the package. 
        #. Click the CVE count displayed under the **CVE** column beside the package.

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

.. note:: 

    * The **active** filter is automatically applied to the CVE panel's displayed results. 
    * For additional information about a CVE, :ref:`search for it in a channel that has no policy applied <search_cve>`.

Scanning environments
=====================

Scanning an environment checks the *most recently saved conda environment log* for CVEs associated with the packages it contains. 

.. note:: 
    
    Environments are automatically scanned when created, but *not* when they are logged or when the log updates. To ensure an accurate assessment of an environment's current CVE state, perform a scan before you explore it in Anaconda Cloud. You can also scan environments locally to identify potential issues immediately.

.. tab-set:: 

    .. tab-item:: Scanning from your organization

        To scan an environment that has been logged with an organization:

        #. Navigate to your |organizations| page. 
        #. Select your organization.
        #. Select |environments| **Environments** from the left-hand navigation.
        #. Select the environment you want to scan from the list. 
        #. Click **Update Scan**.
        
            .. thumbnail:: ../img/evn_scan_in_cloud.png
                :align: center

            .. note:: 

                There is no visual notification that the scan has performed. After scanning, review the packages in the environment for newly associated CVEs.
                
    .. tab-item:: Scanning locally

        Use ``anaconda-audit`` to scan a local environment.
        
        #. Open Anaconda Prompt (Terminal on macOS/Linux).
        #. Scan an environment by running the following command:

            .. code-block:: none 

                # Replace <ENV_NAME> with the name of the environment you want to scan
                anaconda audit scan --name <ENV_NAME>                

.. _block_environment:

Blocking environments
=====================

Administrators can take action on environments that don't meet security standards by utilizing organizational environment security status controls, which allow them to place a warning on an environment or block access to it completely. In both cases, administrators can enter a personalized message with guidance on what actions must be taken to restore access. Organization members who have had their environment blocked will receive the administrator's message next time they try to activate the environment.

#. Navigate to your |organizations| page. 
#. Select your organization.
#. Select |environments| **Environments** from the left-hand navigation.
#. Select the environment you want to take action on. 
#. Click **Update Status**.

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

#. Select a status to apply to the environment and enter a custom message, if necessary.
#. Click **Save**. 

Archiving environments
======================

Archiving environments allows administrators to maintain an organized workspace by moving inactive or obsolete environments to a dedicated tab. This separation reduces clutter in the active environment list, making it easier to manage.

#. Navigate to your |organizations| page. 
#. Select your organization.
#. Select |environments| **Environments** from the left-hand navigation.
#. Select the environment you want to take action on. 
#. Click **Archive**. 

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

.. note:: 

    Archived environments are still available for use. If you would like to prevent the environment from being used, :ref:`block the environment <block_environment>`. 

.. |environments| raw:: html

    <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 640 512"><path d="M128 80H512c8.8 0 16 7.2 16 16V320h48V96c0-35.3-28.7-64-64-64H128C92.7 32 64 60.7 64 96V320h48V96c0-8.8 7.2-16 16-16zM50.7 400H589.3c-6.6 18.6-24.4 32-45.3 32H96c-20.9 0-38.7-13.4-45.3-32zM32 352c-17.7 0-32 14.3-32 32c0 53 43 96 96 96H544c53 0 96-43 96-96c0-17.7-14.3-32-32-32H32zM281 177c9.4-9.4 9.4-24.6 0-33.9s-24.6-9.4-33.9 0l-48 48c-9.4 9.4-9.4 24.6 0 33.9l48 48c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9l-31-31 31-31zM393 143c-9.4-9.4-24.6-9.4-33.9 0s-9.4 24.6 0 33.9l31 31-31 31c-9.4 9.4-9.4 24.6 0 33.9s24.6 9.4 33.9 0l48-48c9.4-9.4 9.4-24.6 0-33.9l-48-48z"/></svg>

.. |beta| raw:: html

    <svg class="inline" width="31" height="14" viewBox="0 0 31 14" fill="none" xmlns="http://www.w3.org/2000/svg">
    <rect width="31" height="14" rx="3" fill="#6D5BF6"/>
    <path d="M6.88281 7.58203H5.41797L5.41016 6.68359H6.59766C6.8112 6.68359 6.98177 6.66016 7.10938 6.61328C7.23698 6.5638 7.32943 6.49219 7.38672 6.39844C7.44661 6.30469 7.47656 6.1875 7.47656 6.04688C7.47656 5.88542 7.44661 5.75521 7.38672 5.65625C7.32682 5.55729 7.23177 5.48568 7.10156 5.44141C6.97396 5.39453 6.80859 5.37109 6.60547 5.37109H5.93359V10H4.5625V4.3125H6.60547C6.95703 4.3125 7.27083 4.34505 7.54688 4.41016C7.82292 4.47266 8.05729 4.56901 8.25 4.69922C8.44531 4.82943 8.59375 4.99349 8.69531 5.19141C8.79688 5.38672 8.84766 5.61719 8.84766 5.88281C8.84766 6.11458 8.79818 6.33203 8.69922 6.53516C8.60026 6.73828 8.4349 6.90365 8.20312 7.03125C7.97396 7.15625 7.66016 7.22135 7.26172 7.22656L6.88281 7.58203ZM6.82812 10H5.08594L5.55469 8.94531H6.82812C7.01562 8.94531 7.16536 8.91667 7.27734 8.85938C7.39193 8.79948 7.47396 8.72135 7.52344 8.625C7.57552 8.52604 7.60156 8.41667 7.60156 8.29688C7.60156 8.15104 7.57682 8.02474 7.52734 7.91797C7.48047 7.8112 7.40495 7.72917 7.30078 7.67188C7.19661 7.61198 7.05729 7.58203 6.88281 7.58203H5.73047L5.73828 6.68359H7.11719L7.4375 7.04297C7.81771 7.02734 8.11849 7.08073 8.33984 7.20312C8.5638 7.32552 8.72396 7.48698 8.82031 7.6875C8.91667 7.88802 8.96484 8.09766 8.96484 8.31641C8.96484 8.6888 8.88411 9 8.72266 9.25C8.5638 9.5 8.32552 9.6875 8.00781 9.8125C7.6901 9.9375 7.29688 10 6.82812 10ZM14.6406 8.94531V10H11.6094V8.94531H14.6406ZM12.0977 4.3125V10H10.7266V4.3125H12.0977ZM14.25 6.57031V7.58984H11.6094V6.57031H14.25ZM14.6523 4.3125V5.37109H11.6094V4.3125H14.6523ZM19.0352 4.3125V10H17.6641V4.3125H19.0352ZM20.7461 4.3125V5.37109H15.9922V4.3125H20.7461ZM24.2617 5.50781L22.875 10H21.4023L23.4922 4.3125H24.4258L24.2617 5.50781ZM25.4102 10L24.0195 5.50781L23.8398 4.3125H24.7852L26.8867 10H25.4102ZM25.3555 7.87891V8.9375H22.4375V7.87891H25.3555Z" fill="white"/>

.. |organizations| raw:: html 

    <a href="https://anaconda.cloud/profile/organizations" target="_blank" rel="noreferrer noopener nofollow">Organizations</a>