PHP WebShell

Текущая директория: /usr/lib/python3/dist-packages/uaclient/api/u/pro/security/fix/cve/execute/__pycache__

Просмотр файла: v1.cpython-310.pyc

o

UٵgO�	@sddlmZddlmZddlmZddlmZmZddl	m
Z
mZmZm
Z
mZddlmZmZddlmZddlmZmZmZmZGd	d
�d
e�ZGdd�de�ZGd
d�dee�Zdedefdd�Zdededefdd�Zeddeed�Zdddegdddd�Zd S)!�)�List)�APIEndpoint)�AdditionalInfo)�	FixStatus�get_expected_overall_status)�
FailedUpgrade�FixExecuteError�FixExecuteResult�UpgradedPackage�_execute_fix)�CVEFixPlanOptions�_plan)�UAConfig)�
DataObject�Field�StringDataValue�	data_listc@s2eZdZedee�dd�gZdeefdd�Z	dS)�CVEFixExecuteOptions�cvesz)A list of CVE (i.e. CVE-2023-2650) titles��doccC�
||_dS�N�r)�selfr�r�P/usr/lib/python3/dist-packages/uaclient/api/u/pro/security/fix/cve/execute/v1.py�__init__%�
zCVEFixExecuteOptions.__init__N)
�__name__�
__module__�__qualname__rrr�fieldsr�strrrrrrrs��rc@sBeZdZededd�edee�dd�gZdede	efdd�Z
dS)	�CVEAPIFixExecuteResult�statuszThe status of fixing the CVEsrrz&A list of ``FixExecuteResult`` objectscCs||_||_dSr�r%r)rr%rrrrr3s
zCVEAPIFixExecuteResult.__init__N)rr r!rrrr	r"r#rrrrrrr$)s��	r$c@s*eZdZededd�gZdefdd�ZdS)�CVESAPIFixExecuteResult�	cves_dataz,A list of ``CVEAPIFixExecuteResult`` objectsrcCrr�r()rr(rrrrArz CVESAPIFixExecuteResult.__init__N)rr r!rr$r"rrrrrr'8s��r'�options�returncCst|t��Sr)�_executer)r*rrr�executeEsr-�cfgcCs`tt|jd�|d�}g}tjjj}|jjD]}t|�}t	||j
�}|�|�qtt
||d�d�S)z@
    This endpoint fixes the specified CVEs on the machine.
    r)r.r&r))r
rrr�SYSTEM_NOT_AFFECTED�value�msgr(rrr%�appendr'r$)r*r.�fix_plan�cves_result�all_cves_status�cve�
cve_resultrrrr,Is
���r,�v1�
CVEFixExecute)�version�name�fn�options_cls�30Tz�
from uaclient.api.u.pro.security.fix.cve.execute.v1 import execute, CVEFixExecuteOptions

options = CVEFixExecuteOptions(cves=["CVE-1234-1234", "CVE-1234-1235"])
result = execute(options)
z_pro api u.pro.security.fix.cve.execute.v1 --data '{"cves": ["CVE-1234-1234", "CVE-1234-1235"]}'a�
{
    "cves_data": {
        "status": "fixed",
        "cves": [
            {
                "title": "CVE-1234-56789",
                "description": "..."
                "status": "fixed",
                "upgraded_packages": {
                    "name": "pkg1",
                    "version": "1.1",
                    "pocket": "standard-updates"
                },
                "errors": []
            }
        ]
    }
}
at
.. tab-item:: Explanation
    :sync: explanation

    When using the CVE endpoint, the expected output is as follows:

    .. code-block:: json

        {
            "_schema_version": "v1",
            "data": {
                "attributes": {
                    "cves_data": {
                        "cves": [
                            {
                                "description": "description",
                                "errors": null,
                                "status": "fixed",
                                "title": "CVE-2021-27135",
                                "upgraded_packages": [
                                    {
                                        "name": "xterm",
                                        "pocket": "standard-updates",
                                        "version": "VERSION"
                                    }
                                ]
                            }
                        ],
                        "status": "fixed"
                    }
                },
                "meta": {
                    "environment_vars": []
                },
                "type": "CVEFixExecute"
            },
            "errors": [],
            "result": "success",
            "version": "30",
            "warnings": []
        }

    From this output, we can see that the **cves_data** object contains two
    attributes:

    * **cves**: A list of CVE objects detailing what happened during the fix
      operation.
    * **status**: The status of the fix operation considering **all** CVEs.
      This means that if one CVE cannot be fixed, this field will reflect that.

    If we take a look at a CVE object, we will see the following structure:

    * **title**: The title of the CVE.
    * **description**: The CVE description.
    * **error**: Any error captured when fixing the CVE will appear here. The
      error object will be detailed in a following section.
    * **status**: The expected status of the CVE after the fix operation.
      There are three possible scenarios: **fixed**, **still-affected** and
      **not-affected**. The system is considered **still-affected** if there
      is something that prevents any required packages from being upgraded.
      The system is considered **not-affected** if the CVE doesn't affect the
      system at all.
    * **upgraded_packages**: A list of UpgradedPackage objects referencing each
      package that was upgraded during the fix operation. The UpgradedPackage
      object always contain the **name** of the package, the **version** it was
      upgraded to and the **pocket** where the package upgrade came from.

    **What errors can be generated?**

    There some errors that can happen when executing this endpoint. For
    example, the system might require the user to attach to a Pro subscription
    to install the upgrades, or the user might run the command as non-root
    when a package upgrade is needed.

    In those situations, the error JSON error object will follow this
    representation:

    .. code-block:: json

        {
            "error_type": "error-type",
            "reason": "reason",
            "failed_upgrades": [
                {
                    "name": "pkg1",
                    "pocket": "esm-infra"
                }
            ]
        }

    We can see that the representation has the following fields:

    * **error_type**: The error type
    * **reason**: The explanation of why the error happened
    * **failed_upgrade**: A list of objects that always contain the name of the
      package that was not upgraded and the pocket where the upgrade would have
      come from.
)�
introduced_in�requires_network�example_python�result_class�
exceptions�example_cli�example_json�extraN) �typingr�uaclient.api.apir�uaclient.api.data_typesr�'uaclient.api.u.pro.security.fix._commonrr�2uaclient.api.u.pro.security.fix._common.execute.v1rrr	r
r�+uaclient.api.u.pro.security.fix.cve.plan.v1rr
�uaclient.configr�uaclient.data_typesrrrrrr$r'r-r,�endpoint�_docrrrr�<module>sD

��
��
�

Выполнить команду


Для локальной разработки. Не используйте в интернете!