PHP WebShell

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

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

o

Uٵg�"�	@sddlmZmZddlmZddlmZddlmZm	Z	ddl
mZmZm
Z
mZmZddlmZmZddlmZddlmZmZmZmZGd	d
�d
e�ZGdd�de�ZGd
d�de�ZGdd�dee�Zdedefdd�Zdededefdd�Zeddeed�Z dddegddd d!�Z!d"S)#�)�List�Optional)�APIEndpoint)�AdditionalInfo)�	FixStatus�get_expected_overall_status)�
FailedUpgrade�FixExecuteError�FixExecuteResult�UpgradedPackage�_execute_fix)�USNFixPlanOptions�_plan)�UAConfig)�
DataObject�Field�StringDataValue�	data_listc@s2eZdZedee�dd�gZdeefdd�Z	dS)�USNFixExecuteOptions�usnsz'A list of USNs (i.e. USN-6188-1) titles��doccC�
||_dS�N�r)�selfr�r�P/usr/lib/python3/dist-packages/uaclient/api/u/pro/security/fix/usn/execute/v1.py�__init__%�
zUSNFixExecuteOptions.__init__N)
�__name__�
__module__�__qualname__rrr�fieldsr�strrrrrrrs��rc@sLeZdZededd�edee�ddd�gZ	ddedeeefd	d
�Z	dS)�FixExecuteUSNResult�
target_usnz+The ``FixExecuteResult`` for the target USNr�related_usnsFz;A list of ``FixExecuteResult`` objects for the related USNs)�requiredrNcC�||_||_dSr)r&r')rr&r'rrrr8s
zFixExecuteUSNResult.__init__r)
r r!r"rr
rr#rrrrrrrr%)s&�����
�r%c@sBeZdZededd�edee�dd�gZdede	efdd�Z
dS)	�USNAPIFixExecuteResult�statuszThe status of fixing the USNsrrz)A list of ``FixExecuteUSNResult`` objectscCr)r�r+r)rr+rrrrrKs
zUSNAPIFixExecuteResult.__init__N)r r!r"rrrr%r#r$rrrrrrr*As��	r*c@s*eZdZededd�gZdefdd�ZdS)�USNSAPIFixExecuteResult�	usns_dataz,A list of ``USNAPIFixExecuteResult`` objectsrcCrr�r.)rr.rrrrYrz USNSAPIFixExecuteResult.__init__N)r r!r"rr*r#rrrrrr-Ps��r-�options�returncCst|t��Sr)�_executer)r0rrr�execute]sr3�cfgc
Cs�tt|jd�|d�}g}tjjj}|jjD]1}t|j	�}t
||j�}t|d�}|jtj
jjkrAg}|jD]	}	|�t|	��q4||_|�|�qtt||d�d�S)z@
    This endpoint fixes the specified USNs on the machine.
    r)r4)r&r,r/)rr
rr�SYSTEM_NOT_AFFECTED�value�msgr.r�target_usn_planrr+r%�SYSTEM_STILL_VULNERABLE�related_usns_plan�appendr'r-r*)
r0r4�fix_plan�usns_result�all_usns_status�usn�target_usn_result�usn_fix_execute_result�related_usns_result�related_usnrrrr2as0

���
��r2�v1�
USNFixExecute)�version�name�fn�options_cls�30Tz�
from uaclient.api.u.pro.security.fix.usn.execute.v1 import execute, USNFixExecuteOptions

options = USNFixExecuteOptions(usns=["USN-1234-1", "USN-1235-1"])
result = execute(options)
zYpro api u.pro.security.fix.usn.execute.v1 --data '{"usns": ["USN-1234-1", "USN-1235-1"]}'a
{
    "usns_data": {
        "status": "fixed",
        "usns": [
            {
                "target_usn": {
                    "title": "CVE-1234-56789",
                    "status": "fixed",
                    "upgraded_packages": {
                        "name": "pkg1",
                        "version": "1.1",
                        "pocket": "standard-updates"
                    },
                    "error": null
                },
                "related_usns": []
            }
        ]
    }
}
a�
.. tab-item:: Explanation
    :sync: explanation

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

    .. code-block:: json

        {
            "usns_data": {
                "status": "fixed",
                "usns": [
                    {
                        "target_usn": {
                            "title": "CVE-1234-56789",
                            "status": "fixed",
                            "upgraded_packages": {
                                "name": "pkg1",
                                "version": "1.1",
                                "pocket": "standard-updates"
                            },
                            "error": null
                        },
                        "related_usns": []
                    }
                ]
            }
        }

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

    * **usns**: A list of USN objects detailing what happened during the fix
      operation.
    * **status**: The status of the fix operation considering **all** USNs.
      This means that if one USN cannot be fixed, this field will reflect that.
      Note that related USNs don't interfere with this attribute, meaning that
      a related USN can fail to be fixed without modifying the **status**
      value.

    Each **usn** object contains a reference for both **target_usn** and
    **related_usns**. The target is the USN requested to be fixed by the user,
    while related USNs are USNs that are related to the main USN and an
    attempt to fix them will be performed by the endpoint too. To better
    understand that distinction, please refer to
    :ref:`our explanation of CVEs and USNs <expl-cve-usn>`.

    With that said both **target_usn** object and any object from
    **related_usns** follow this structure:

    * **title**: The title of the USN.
    * **description**: The USN description.
    * **error**: Any error captured when fixing the USN will appear here. The
      error object will be detailed in a following section.
    * **status**: The expected status of the USN 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 USN 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)"�typingrr�uaclient.api.apir�uaclient.api.data_typesr�'uaclient.api.u.pro.security.fix._commonrr�2uaclient.api.u.pro.security.fix._common.execute.v1rr	r
rr�+uaclient.api.u.pro.security.fix.usn.plan.v1r
r�uaclient.configr�uaclient.data_typesrrrrrr%r*r-r3r2�endpoint�_docrrrr�<module>sF

��
�)�
�

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


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