https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/uaclient/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/uaclient/__pycache__/security_status.cpython-310.pyc
o

��Jh�h�@s�ddlmZddlmZmZddlmZddlmZddlm	Z	ddl
mZmZm
Z
mZmZddlZddlmZmZmZmZdd	lmZdd
lmZddlmZmZmZmZmZddl m!Z!dd
l"m#Z#m$Z$ddl%m&Z&m'Z'm(Z(ddl)m*Z*m+Z+m,Z,m-Z-m.Z.dZ/Gdd�de�Z0dd�Z1edd�dd��Z2dedeej3ffdd�Z4dej3dej5de6fdd�Z7edd�d e6d!e6de8fd"d#��Z9d$e6d%e
e6efd!ej:de6fd&d'�Z;d(eej3dee6eeej:e6fffd)d*�Z<d+e!de
e6effd,d-�Z=dee
e6effd.d/�Z>d0ee6eeej:e6ffd%e
e6efdee
e6effd1d2�Z?d+e!de
e6effd3d4�Z@	5	6dUd7ee6eej3fd8e6d9e8ddfd:d;�ZAd<d=�ZBd>d?�ZCd@e6dAe6dBe'dCe&dDeDdEeDdFe8fdGdH�ZEdIdJ�ZFd+e!fdKdL�ZGdMdN�ZHdOdP�ZIdQdR�ZJdSdT�ZKdS)V�)�defaultdict)�datetime�timezone)�Enum)�	lru_cache)�choice)�Any�DefaultDict�Dict�List�TupleN)�
exceptions�	livepatch�messages�util)�_reboot_required)�_is_attached)�PreserveAptCfg�get_apt_cache_datetime�get_apt_pkg_cache�get_esm_apt_pkg_cache�get_pkg_candidate_version)�UAConfig)�ESMAppsEntitlement�ESMInfraEntitlement)�ApplicabilityStatus�ApplicationStatus�ContractStatus)�get_distro_info�get_kernel_info�get_release_info�is_current_series_lts�is_supported)�	esm-infra�esm-appsc@s$eZdZdZdZdZdZdZdZdS)�UpdateStatusz2Represents the availability of a security package.�upgrade_available�upgrade_available_not_preferred�pending_attach�pending_enable�upgrade_unavailableN)	�__name__�
__module__�__qualname__�__doc__�	AVAILABLE�AVAILABLE_NOT_PREFERRED�
UNATTACHED�NOT_ENABLED�UNAVAILABLE�r4r4�:/usr/lib/python3/dist-packages/uaclient/security_status.pyr%(sr%cCstt�|��dS)N)�printr�create_package_list_str)�packagesr4r4r5�print_package_list1sr9)�maxsizecCsRt�j}dd�|�fddd�|�fddd�|�fd	dd
�|�fddd�|�fd	iS)N�Ubuntuz{}-security�standard-security�
UbuntuESMAppsz{}-apps-securityr$�	UbuntuESMz{}-infra-securityr#z{}-apps-updatesz{}-infra-updates)r �series�format)r?r4r4r5�%get_origin_information_to_service_map5s�rA�return�strcCsvtt�}tt��)}dd�|jD�}||d<t�|�}|D]}|t||��|�qWd�|S1s4wY|S)NcSsg|]}|jr|�qSr4)�current_ver��.0�packager4r4r5�
<listcomp>Gs
��z4get_installed_packages_by_origin.<locals>.<listcomp>�all)	r�listrrr8�apt_pkg�DepCache� get_origin_for_installed_package�append)�result�cache�installed_packages�	dep_cacherGr4r4r5� get_installed_packages_by_originAs"
�
�
�
�
�
rSrGrRcCs�|jsdS|jj}t|�dkr |�|�}|r|j|krdS|j}|D]!\}}t��|j|jfd�}|tvr9|S|jdkrC|j	Sq"dS)a
    Returns the origin for a package installed in the system.

    Technically speaking, packages don't have origins - their versions do.
    We check the available versions (installed, candidate) to determine the
    most reasonable origin for the package.
    ���unknownr;�third-party)
rD�	file_list�len�get_candidate_verrA�get�origin�archive�ESM_SERVICES�	component)rGrR�available_origins�	candidater\�_�servicer4r4r5rMVs$
�

�rM�pkg�versioncCst|dd�}|r||kSdS)z;Returns True if the package version is a candidate version.F)�check_esm_cache)r)rdre�candidate_versionr4r4r5�_is_candidate_version{srh�service_name�ua_infocCsl|dvs|dr ||dvr t|jj|j�}|rtjjStjjS|ds(tjjS||dvr2tj	jStj
jS)z�Defines the update status for a package based on the service name.

    For ESM-[Infra|Apps] packages, first checks if Pro is attached. If this is
    the case, also check for availability of the service.
    )r<�standard-updates�attached�enabled_services�entitled_services)rh�
parent_pkg�name�ver_strr%r/�valuer0r1r2r3)rirjre�is_candidater4r4r5�get_update_status�s"
�
����rtr8cCs>tt�}tt���}|D]�}|jr�|jD]C}||jkrVd}|jD]\}}t��|j	|j
f�}|r=||�||jf�d}nq|jdd}	|sVd|	j
vrV|d�||	jf�q|j
|vr�||j
}
|
jD]'}||jkr�|jD]\}}t��|j	|j
f�}|r�||�||jf�nqnqdqWd�|S1s�wY|S)z�Filters a list of packages looking for available updates.

    All versions greater than the installed one are reported, based on where
    it is provided, including ESM pockets, excluding backports.
    FTr�	backportsrkN)rrJrrrD�version_listrXrAr[r\r]rN�siterp)r8rO�	esm_cacherGre�counted_as_securityr\rbrc�expected_origin�esm_packager4r4r5�filter_updates�sZ



����
��




�����
�.�.r|�cfgcCs�t|�j}|ggd�}|rQt|�}t|�}|��tjkr#|d�d�|��dt	j
kr3|d�d�|��tjkrA|d�d�|��dt	j
krQ|d�d�|S)z7Returns the Pro information based on the config object.)rlrmrnrnr$rrmr#)r�is_attachedrr�contract_statusr�ENTITLEDrN�application_statusr�ENABLED)r}r~rj�infra_entitlement�apps_entitlementr4r4r5�get_ua_info�s*
�
�
�r�cCs�zt��}WntjygYSwt�j}|durF|durF||jkrF|jdurF|jjdkrF|jjdurFt	|jj�dkrFdd�|jjD�SgS)N�appliedrcSs"g|]
}|jpd|jpdd��qS)rTF�rp�patchedr�)rF�fixr4r4r5rHs��z,get_livepatch_fixed_cves.<locals>.<listcomp>)
r�statusr
�ProcessExecutionErrorr�proc_version_signature_version�kernel�state�fixesrY)�	lp_status�our_kernel_versionr4r4r5�get_livepatch_fixed_cvess"�

�r��upgradable_versionscCsTg}|��D]!\}}|D]\}}t|||�}|�|jj|j||||jd��qq|S)N)rGrerir�r\�
download_size)�itemsrtrNrorprq�size)r�rj�updatesrcrvrer\r�r4r4r5�create_updates_lists���
r�cCst|�}d|i}t�}|d}t|�|d<t|�}g|d<t||�}t|d�|d<t|d�|d<t|d	�|d
<t|d�|d<t|d
�|d<t|d�|d<t|d�|d<t|d�|d<t|d�|d<t|d�|d<t|d�|d<t|�j|d<d||dt�id�S)agReturns the status of security updates on a system.

    The returned dict has a 'packages' key with a list of all installed
    packages which can receive security updates, with or without ESM,
    reflecting the availability of the update based on the Pro status.

    There is also a summary with the Ubuntu Pro information and the package
    counts.
    �uarI�num_installed_packagesrk�main�num_main_packages�
restricted�num_restricted_packages�universe�num_universe_packages�
multiverse�num_multiverse_packagesrW�num_third_party_packagesrV�num_unknown_packagesr#�num_esm_infra_packagesr$�num_esm_apps_packages�num_esm_infra_updates�num_esm_apps_updatesr<�num_standard_security_updates�reboot_requiredz0.1�
fixed_cves)�_schema_version�summaryr8r)r�rSrYr|r�rr�r�)r}rjr��packages_by_originrQr�r�r4r4r5�security_status_dict/s:

���r�rIF�
package_lists�
show_items�always_showc	CsBt|d�}ttjj|d��dtt|��d}|dvr=t|d�t|d�t|d�}ttj�|�j||d	d
��|dvret|d�t|d
�t|d�}|sW|rettj�|�j||dd
��|dvr�t|d�}|ss|r�ttj�|�j||d��|dvr�t|d�}|s�|r�ttj	�|�j||d��td�dS)NrI)�count� rU)rIr#r�r�r#�Main/Restricted)�offsetr��
repository)rIr$r�r�r$�Universe/Multiverse)rIrWrW)r�r�)rIrVrVrT)
rYr6r�SS_SUMMARY_TOTALr@rC�SS_SUMMARY_ARCHIVE�	pluralize�SS_SUMMARY_THIRD_PARTY�SS_SUMMARY_UNAVAILABLE)	r�r�r��total_packagesr��packages_mr�packages_um�packages_thirdparty�packages_unknownr4r4r5�_print_package_summaryasn

�
����

�
����������	r�cCsHt�j}t|�j}d�t|j�t|j��}tt	j
j|d��td�dS)Nz{}/{}��daterT)r r?r�eolr@rC�month�yearr6r�SS_INTERIM_SUPPORT)r?�eol_dater�r4r4r5�_print_interim_release_support�s

r�cCsDt�j}t|�rt|�j}ttjjt	|j
�d��dSttj�dS)Nr�)r r?r"rr�r6r�SS_LTS_SUPPORTr@rCr��SS_NO_SECURITY_COVERAGE)r?r�r4r4r5�_print_lts_support�s

r�rcr��service_status�service_applicability�installed_updates�available_updatesr~c
Cs�t�j}t|�j}|tjkrtjj||t	|j
�d�}	ntjj||t	|j
�d�}	|r7|	dtj�
|�j|d�7}	|rG|	dtj�
|�j|d�7}	t|	�|rd|tjkrd|tjkrdtd�ttjj|d��td�dS)N)r�rcr�)rcr�r�r�)r�rT�rc)r r?r�eol_esmrr�r�SS_SERVICE_ENABLEDr@rCr��SS_SERVICE_ADVERTISE�SS_SERVICE_ENABLED_COUNTSr��SS_SERVICE_ADVERTISE_COUNTSr6�DISABLEDr�
APPLICABLE�SS_SERVICE_COMMAND)
rcr�r�r�r�r�r~r?�eol_date_esm�messager4r4r5�_print_service_support�sF	

��
�
�
�
��

r�cCsft�}|durttj�td�dSt�tj�}||}|jdkr1ttj	j
|jd��td�dSdS)NrTr)�days)rr6r�SS_UPDATE_UNKNOWNr�nowr�utcr��SS_UPDATE_DAYSr@)�last_apt_updater��time_since_updater4r4r5�_print_apt_update_call�s

�r�c
	Cs�t|�}t|�}|��d}|��d}|��d}|��d}t�j}t�}t|�d}	t�}
t	|
d|
d|
d�d}t	|
d|
d|
d�d}t
|
�ttj
�td	�t�|spt|�rit�ttj�dS|tjkrxt�|	r�ttj�nttj�td	�tdd
||t|
d�t|�|	d�|
ds�|
ds�|
dr�tdd||t|
d�t|�|	d�|	s�ttj�dSdS)
Nrrlr�r�r#r�r�r$rTr��rcr�r�r�r�r�r~r�)rrr��applicability_statusr r?r!r�rSr|r�r6r�SS_HELP_CALLr�r"r��SS_NO_INTERIM_PRO_SUPPORTrr�r��SS_IS_ATTACHED�SS_IS_NOT_ATTACHEDr�rY�
SS_LEARN_MORE)
r}�
esm_infra_ent�esm_apps_ent�esm_infra_status�esm_infra_applicability�esm_apps_status�esm_apps_applicabilityr?�is_ltsr~r��"security_upgradable_versions_infra�!security_upgradable_versions_appsr4r4r5�security_status�s���������




����
�
�r�cC�zt�}|d}dd�|D�}t|ddd�|r6ttj�td�ttj�t|�ttjjt	|�d��dSttj
�dS)NrWcS�g|]}|j�qSr4�rprEr4r4r5rHA�z-list_third_party_packages.<locals>.<listcomp>T�r�r�rT�rG)rSr�r6r�SS_THIRD_PARTY�SS_PACKAGES_HEADERr9�SS_SHOW_HINTr@r�SS_NO_THIRD_PARTY)r��third_party_packages�
package_namesr4r4r5�list_third_party_packages>s�

rcCr�)NrVcSr�r4r�rEr4r4r5rHUr�z-list_unavailable_packages.<locals>.<listcomp>Tr�rTr�)rSr�r6r�SS_UNAVAILABLEr�r9rr@r�SS_NO_UNAVAILABLE)r��unknown_packagesrr4r4r5�list_unavailable_packagesRs�

rc	s�t�}|d}|d|d}||}t�}t|�d}|D]
\}}|�|j�qt�j}	t�}
t|�}t	|�}|�
�d}
|��d}tdd�|D���tdd�|D���t��fdd�|D��}t
|dd	d
�|
syt|	�rrt�ttj�dS|
tjkr�t�td�tdd|
|t|�t|�d
d�ttjjdd��td�t|	�s�r�ttjjdd��t���r�ttjjdd��t���pƈ}|r�|r�tjjdd�}ntjjdd�}t|�t|�|r�ttjjt |�d��dSdSdS)Nr#r�r�rcSr�r4r�rEr4r4r5rHr�z+list_esm_infra_packages.<locals>.<listcomp>cSr�r4r�rEr4r4r5rH�r�c�&g|]}|j�vr|j�vr|j�qSr4r�rE��available_package_names�installed_package_namesr4r5rH��

�Tr�rTr�Fr�r�r�)!rS�setr|�addror r?r!rrr�r��sortedr�r"r�r6rr�rr�r�r�rY�SS_SERVICE_HELPr@�SS_UPDATES_AVAILABLEr9�SS_UPDATES_INSTALLED�SS_FURTHER_OTHER_PACKAGES�SS_OTHER_PACKAGESrr)r}r��infra_packages�mr_packages�all_infra_packages�
infra_updates�security_upgradable_versions�updaterbr?r�r�r�r�r��remaining_package_names�	hint_list�msgr4r
r5�list_esm_infra_packagesgs������	�

�	��rc	s�t�}|d}|d|d}||}t�}t|�d}|D]
\}}|�|j�qt�}	t|�}
|
��d}|
��d}t	dd�|D���t	dd�|D���t	��fdd�|D��}
t
|dd	d
�|	sjttj
�dStdd||t|�t|�dd
�ttjjdd��td�|rԈr�ttjjdd��t���r�ttjjdd��t���p��}|
r�|r�tjjdd�}ntjjdd�}t|�t|
�|r�ttjjt|�d��dSdSdS)Nr$r�r�rcSr�r4r�rEr4r4r5rH�r�z*list_esm_apps_packages.<locals>.<listcomp>cSr�r4r�rEr4r4r5rH�r�cr	r4r�rEr
r4r5rH�r
Tr�r�Fr�r�rTr�)rSrr|rror!rr�r�rr�r6rr�r�rYrr@rr9rrrrr)r}r��
apps_packages�um_packages�all_apps_packages�apps_updatesrrrbr�r�r�r�rrrr4r
r5�list_esm_apps_packages�s~������	�
�	��r$)rIF)L�collectionsrrr�enumr�	functoolsr�randomr�typingrr	r
rrrK�uaclientr
rrr�5uaclient.api.u.pro.security.status.reboot_required.v1r�(uaclient.api.u.pro.status.is_attached.v1r�uaclient.aptrrrrr�uaclient.configr�uaclient.entitlementsrr�(uaclient.entitlements.entitlement_statusrrr�uaclient.systemrrr r!r"r^r%r9rA�PackagerSrLrCrM�boolrh�Versionrtr|r�r�r�r�r�r�r��intr�r�r�rrrr$r4r4r4r5�<module>s�	

���
�%�
��
��
�@!�
�
�4����
�?	������
�2MY

https://t.me/RX1948 - 2025