o
    K&b9y                     @   s:  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
mZ d dlmZ d dlmZmZ d dlmZ d dlmZmZmZmZmZmZmZmZmZ d dlmZmZ d dl m!Z! d d	l"m#Z#m$Z$m%Z%m&Z& d d
l'm(Z( dZ)dZ*dZ+dZ,e- Z.dZ/dZ0dZ1dZ2dZ3dZ4e#5 Z6G dd dej7Z8G dd dej9Z:G dd dej;Z<	ddee=ef de=ddfddZ>d e=ddfd!d"Z?ed#d$ Z@d%d& ZA	'dd(ee=ef d)ee=ef d e=dee=ef fd*d+ZBedd,de=fd-d.ZCedd,dee=e=f fd/d0ZDedd,de=deEfd1d2ZFedd,de=deEfd3d4ZGedd,dd6e=deEfd7d8ZHd e=deEfd9d:ZId;e=deEfd<d=ZJdd?e=d@eEde=fdAdBZKedd,ddCee= dee=e=f fdDdEZLd'g fdFe=dGee= de=fdHdIZMddFe=dKeEdeEfdLdMZNdNee= dOee= ddfdPdQZOdi ddfd;e=dReeP dSee=e=f dTee= dUeeQ deeeeee=e=f f f fdVdWZR		J		ddXee= dYeeeQ  dZeEdUeeS d[eee=e=f  dee=e=f fd\d]ZT		J			ddXee= dYeeeQ  dZeEdUeeS d^eeeS  d[eee=e=f  dee=e=f fd_d`ZUdae=dee= fdbdcZVdd?e=dee=dfeQddfdgdhZWdie=ddfdjdkZXdlee=ef dme=fdndoZYg dpZZeZfdqee= de=fdrdsZ[ddteee=  deEfdudvZ\dwe=deEfdxdyZ]dzee( deEfd{d|Z^d}e=de j fd~dZ_de=dee= de=dee= fddZ`de=de=fddZadS )    N)contextmanager)ENOENT)	lru_cachewraps)HTTPMessage)	AnyDictListMappingOptionalSequenceSetTupleUnion)errorrequest)urlparse)event_logger
exceptionsmessagesstatus)MessagingOperationsz/var/run/reboot-requiredz/var/run/reboot-required.pkgsz/etc/machine-idz/var/lib/dbus/machine-idz0(?P<release>\d+\.\d+) (LTS )?\((?P<series>\w+).*)z169.254.169.254Zmetadataz[fd00:ec2::254]zhttp://archive.ubuntu.comzhttps://esm.ubuntu.comzhttp://api.snapcraft.iozhttps://api.snapcraft.ioc                   @   s0   e Zd ZejdejdiZdejdefddZ	dS )LogFormatterzERROR: %(message)szDEBUG: %(message)srecordreturnc                 C   s    | j |jd}t||S )Nz%(message)s)FORMATSgetZlevelnologging	Formatterformat)selfr   Zlog_fmt r!   //usr/lib/python3/dist-packages/uaclient/util.pyr   9   s   zLogFormatter.formatN)
__name__
__module____qualname__r   ZERRORDEBUGr   Z	LogRecordstrr   r!   r!   r!   r"   r   2   s
    r   c                       s    e Zd ZdZ fddZ  ZS )DatetimeAwareJSONEncoderzBA json.JSONEncoder subclass that writes out isoformat'd datetimes.c                    s    t |tjr
| S t |S N)
isinstancedatetimeZ	isoformatsuperdefault)r    o	__class__r!   r"   r-   A   s   z DatetimeAwareJSONEncoder.default)r#   r$   r%   __doc__r-   __classcell__r!   r!   r/   r"   r(   >   s    r(   c                       s,   e Zd ZdZ fddZedd Z  ZS )DatetimeAwareJSONDecodera,  
    A JSONDecoder that parses some ISO datetime strings to datetime objects.

    Important note: the "some" is because we seem to only be able extend
    Python's json library in a way that lets us convert string values within
    JSON objects (e.g. '{"lastModified": "2019-07-25T14:35:51"}'). Strings
    outside of JSON objects (e.g. '"2019-07-25T14:35:51"') will not be passed
    through our decoder.

    (N.B. This will override any object_hook specified using arguments to it,
    or used in load or loads calls that specify this as the cls.)
    c                    s.   d|v r	| d t j|d| ji| d S )Nobject_hook)popr,   __init__r4   )r    argskwargsr/   r!   r"   r6   U   s   
z!DatetimeAwareJSONDecoder.__init__c              	   C   sL   |   D ]\}}t|tr#zt|}W n ty   |}Y nw || |< q| S r)   )itemsr*   r'   parse_rfc3339_date
ValueError)r.   keyvalue	new_valuer!   r!   r"   r4   Z   s   
z$DatetimeAwareJSONDecoder.object_hook)r#   r$   r%   r1   r6   staticmethodr4   r2   r!   r!   r/   r"   r3   G   s
    r3   orig_accessseriesr   c                 C   s   t t| td| v gstd| |du rt d n|}| di }|di |i }| D ]\}}| d |}t|trG|	| q1|| d |< q1dS )a  Apply series-specific overrides to an entitlement dict.

    This function mutates orig_access dict by applying any series-overrides to
    the top-level keys under 'entitlement'. The series-overrides are sparse
    and intended to supplement existing top-level dict values. So, sub-keys
    under the top-level directives, obligations and affordance sub-key values
    will be preserved if unspecified in series-overrides.

    To more clearly indicate that orig_access in memory has already had
    the overrides applied, the 'series' key is also removed from the
    orig_access dict.

    :param orig_access: Dict with original entitlement access details
    Zentitlementz?Expected entitlement access dict. Missing "entitlement" key: {}NrA   )
allr*   dictRuntimeErrorr   get_platform_infor   r5   r9   update)r@   rA   Zseries_nameZorig_entitlementZ	overridesr<   r=   Zcurrentr!   r!   r"   apply_series_overridesg   s   
rG   pathc              
   C   sF   zt |  W d S  ty" } z|jtkr|W Y d }~d S d }~ww r)   )osunlinkOSErrorerrnor   )rH   er!   r!   r"   del_file   s   
rN   c               	   c   s~    dd t  jD } | st d dV  dS | d }|j}|t jkr(dV  dS |d zdV  W || dS || w )a  
    A context manager that disables logging to console in its body

    N.B. This _will not_ disable console logging if it finds the console
    handler is configured at DEBUG level; the assumption is that this means we
    want as much output as possible, even if it risks duplication.

    This context manager will allow us to gradually move away from using the
    logging framework for user-facing output, by applying it to parts of the
    codebase piece-wise. (Once the conversion is complete, we should have no
    further use for it and it can be removed.)

    (Note that the @contextmanager decorator also allows this function to be
    used as a decorator.)
    c                 S   s   g | ]	}|j d kr|qS )z
ua-console)name).0Zhandlerr!   r!   r"   
<listcomp>   s    z*disable_log_to_console.<locals>.<listcomp>z0disable_log_to_console: no console handler foundNr   i  )r   Z	getLoggerhandlersdebuglevelr&   ZsetLevel)Zpotential_handlersZconsole_handlerZ	old_levelr!   r!   r"   disable_log_to_console   s"   


rU   c                    s    fdd}|S )a  Decorator to retry on exception for retry_sleeps.

    @param retry_sleeps: List of sleep lengths to apply between
       retries. Specifying a list of [0.5, 1] tells subp to retry twice
       on failure; sleeping half a second before the first retry and 1 second
       before the second retry.
    @param exception: The exception class to catch and retry for the provided
       retry_sleeps. Any other exception types will not be caught by the
       decorator.
    c                    s   t   fdd}|S )Nc               
      sx     }	 z| i |W S   y: } z!|s|dt| }tt||  t|d W Y d }~nd }~ww q)NT Retrying %d more times.r   )copylenr   rS   r'   timesleepr5   )r7   r8   ZsleepsrM   	retry_msg)	exceptionfretry_sleepsr!   r"   	decorator   s   z)retry.<locals>.wrapper.<locals>.decorator)r   )r]   r_   r\   r^   )r]   r"   wrapper   s   zretry.<locals>.wrapperr!   )r\   r^   ra   r!   r`   r"   retry   s   rb    	orig_dictnew_dictc           
      C   s   i }|   D ]M\}}||t}|s|n|d | }t|tr8||v r3t||| |d}|r2|||< qt||< q||krSd| d t| d }	tt	|	 |||< q|  D ]\}}|| vrd|||< qX|S )z<Return a dictionary of delta between orig_dict and new_dict..rH   zContract value for 'z' changed to '')
r9   r   DROPPED_KEYr*   rC   get_dict_deltasr'   r   rS   redact_sensitive_logs)
rd   re   rH   Zdeltasr<   r=   r>   Zkey_pathZ	sub_deltalogr!   r!   r"   rj      s@   


rj   )maxsizec                 C   s|   | j r| j di d}|r|S | d}tt|fD ]}tj|r0t|	d}|r0|  S qt
t }t|| |S )z=Get system's unique machine-id or create our own in data_dir.ZmachineTokenInfoZ	machineIdz
machine-id
)Zmachine_tokenr   Z	data_pathETC_MACHINE_IDDBUS_MACHINE_IDrI   rH   exists	load_filerstripr'   uuidZuuid4
write_file)ZcfgZcfg_machine_idZfallback_machine_id_filerH   contentZ
machine_idr!   r!   r"   get_machine_id   s    

rw   c                  C   s   t  } | dddd}| d }d|v rdj|d }tdd	|}||d
< tt|}|s9td| d ||	 }|
|d |d  d t }|j|d< tddg\}}| |d< |S )z
    Returns a dict of platform information.

    N.B. This dict is sent to the contract server, which requires the
    distribution, type and release keys.
    NAMEZUNKNOWNZLinux)ZdistributiontypeZVERSION, z{} ({})z\.\d LTSz LTSversionz<Could not parse /etc/os-release VERSION: {} (modified to {})releaserA   )r|   rA   Zkerneldpkgz--print-architectureZarch)parse_os_releaser   r   splitresubmatchREGEX_OS_RELEASE_VERSIONrD   	groupdictrF   lowerrI   unamer|   subpstrip)Z
os_releaseZplatform_infor{   r   Z
match_dictr   out_errr!   r!   r"   rE     s4   


rE   c                 C   s   t ddg\}}| |v S )N/usr/bin/ubuntu-distro-infoz--supported-esm)r   rA   r   r   r!   r!   r"   is_ltsC  s   r   c                 C   s8   t | sdS | dkrdS tdd| dg\}}t|dkS )zCReturn True when Ubuntu series supports ESM and is actively in ESM.FZtrustyTr   z--seriesz-yeolr   )r   r   intr   r!   r!   r"   is_active_esmI  s   
r   /runrun_pathc              	   C   s~   zt dg W dS  tjy   Y nw z	t g d W dS  ttfy'   Y nw dD ]}tj| |}tj|r< dS q*dS )z>Checks to see if this code running in a container of some sortZischrootF)zsystemd-detect-virtz--quietz--containerT)Zcontainer_typezsystemd/container)	r   r   ProcessExecutionErrorIOErrorrK   rI   rH   joinrq   )r   filenamerH   r!   r!   r"   is_containerV  s$   
r   c                 C   s   t j| ot | t jS r)   )rI   rH   isfileaccessX_OKrg   r!   r!   r"   is_exeq  s   r   urlc                 C   sR   zt | }W n
 ty   Y dS w |jdvrdS z|j W dS  ty(   Y dS w )NF)httpshttpT)r   r;   ZschemeZport)r   Z
parsed_urlr!   r!   r"   is_service_urlv  s   
r   Tr   decodec                 C   sH   t d|  t| d}| }W d   n1 sw   Y  |dS )z!Read filename and decode content.zReading file: %srbNutf-8)r   rS   openreadr   )r   r   streamrv   r!   r!   r"   rr     s
   

rr   release_filec                 C   sH   | sd} i }t |  D ]}|dd\}}|r!| d||< q|S )Nz/etc/os-release=   ")rr   
splitlinesr   r   )r   dataliner<   r=   r!   r!   r"   r~     s   r~   msgvalid_choicesc                 C   sR   d}d |ddd |D }	 t|  td }||v r#	 |S t| q)aG  Interactive prompt message, returning a valid choice from msg.

    Expects a structured msg which designates choices with square brackets []
    around the characters which indicate a valid choice.

    Uppercase and lowercase responses are allowed. Loop on invalid choices.

    :return: Valid response character chosen.
    rc   z{} is not one of: {}rz   c                 S   s   g | ]}|  qS r!   )upper)rP   choicer!   r!   r"   rQ     s    z"prompt_choices.<locals>.<listcomp>Tz> )r   r   eventinfoinputr   )r   r   r=   Z	error_msgr!   r!   r"   prompt_choices  s   


r   F
assume_yesc                 C   s2   |rdS | s	t j} t| }|  dv rdS dS )aV  
    Display a confirmation prompt, returning a bool indicating the response

    :param msg: String custom prompt text to emit from input call.
    :param assume_yes: Boolean set True to skip confirmation input and return
        True.

    This function will only prompt a single time, and defaults to "no" (i.e. it
    returns False).
    T)yZyesF)r   ZPROMPT_YES_NOr   r   r   )r   r   r=   r!   r!   r"   prompt_for_confirmation  s   r   
http_proxyhttps_proxyc                 C   s   i }| r| |d< |r||d< d tt}dD ]}tj|}|r2d tt|dtt}qt	
d| |tjd< |tjd< |rVt|}t|}t| dS dS )	a!  
    Configure urllib to use http and https proxies.

    :param http_proxy: http proxy to be used by urllib. If None, it will
                       not be configured
    :param https_proxy: https proxy to be used by urllib. If None, it will
                        not be configured
    r   r   ,)no_proxyNO_PROXYzSetting no_proxy: %sr   r   N)r   sortedUA_NO_PROXY_URLSrI   environr   setr   unionr   rS   r   ProxyHandlerbuild_openerZinstall_opener)r   r   Z
proxy_dictr   Zenv_varZproxy_valueproxy_handleropenerr!   r!   r"   configure_web_proxy  s.   



r   r   headersmethodtimeoutc           
         s:  |r|sd}t j| | |d}d fddt D }ttd|p%d| ||r.|dnd  d	}zt j	||d
d	}W n t
jyW } z
|d}W Y d }~nd }~ww td d j}	dtjddv rvt|	}	dfddtjD }ttd|pd| ||	 |r|	jfS )NZPOST)r   r   r   rz   c                    s   g | ]
}d  | | qS z
'{}': '{}')r   rP   k)r   r!   r"   rQ     s    zreadurl.<locals>.<listcomp>z'URL [{}]: {}, headers: {{{}}}, data: {}ZGETr   Fr   Tbodyzapplication/jsonzContent-typerc   c                    s   g | ]}d  | j| qS r   )r   r   r   )respr!   r"   rQ     s    z0URL [{}] response: {}, headers: {{{}}}, data: {})r   Requestr   r   r   rS   rk   r   r   Zurlopenr   Z	HTTPErrorsetattrr   r   r'   r   r   jsonloads)
r   r   r   r   r   reqZsorted_header_strZhttp_error_foundrM   rv   r!   )r   r   r"   readurl  sT   


r   r7   rcscaptureenvc           
      C   s  dd | D }|r| tj |du rdg}td| }ztj|tjtj|d}|j|d\}}	W n% t	yW   zt
j||j|d|	dd	 tyV   t
j|d
w w |j|vrmt
j||j|d|	dd	|rxtd||j|	 |d|	dfS )a  Run a command and return a tuple of decoded stdout, stderr.

    @param args: A list of arguments to feed to subprocess.Popen
    @param rcs: A list of allowed return_codes. If returncode not in rcs
        raise a ProcessExecutionError.
    @param capture: Boolean set True to log the command and response.
    @param timeout: Optional float indicating number of seconds to wait for
        subp to return.
    @param env: Optional dictionary of environment variable to pass to Popen.

    @return: Tuple of utf-8 decoded stdout, stderr
    @raises ProcessExecutionError on invalid command or returncode not in rcs.
    @raises subprocess.TimeoutError when timeout specified and the command
        exceeds that number of seconds.
    c                 S   s$   g | ]}t |tr|n|d qS )r   )r*   bytesencode)rP   xr!   r!   r"   rQ   5  s    z_subp.<locals>.<listcomp>Nr    )stdoutstderrr   r   r   )cmdZ	exit_coder   r   )r   zRan cmd: %s, rc: %s stderr: %s)rF   rI   r   rk   r   
subprocessPopenPIPEZcommunicaterK   r   r   
returncoder   UnboundLocalErrorr   rS   )
r7   r   r   r   r   Z
bytes_argsZredacted_cmdprocr   errr!   r!   r"   _subp  sP   

r   r^   c              
   C   s   |dur|  nd}	 zt| ||||d\}}W ||fS  tjyd } z<|r>ttt| d|j	|j
}	tt|	 |sA dt| }
ttt||
  t|d W Y d}~nd}~ww q)a  Run a command and return a tuple of decoded stdout, stderr.

     @param subp: A list of arguments to feed to subprocess.Popen
     @param rcs: A list of allowed return_codes. If returncode not in rcs
         raise a ProcessExecutionError.
     @param capture: Boolean set True to log the command and response.
     @param timeout: Optional float indicating number of seconds to wait for a
         subp call to return.
     @param retry_sleeps: Optional list of sleep lengths to apply between
        retries. Specifying a list of [0.5, 1] instructs subp to retry twice
        on failure; sleeping half a second before the first retry and 1 second
        before the next retry.
     @param env: Optional dictionary of environment variables to provide to
        subp.

    @return: Tuple of utf-8 decoded stdout, stderr
    @raises ProcessExecutionError on invalid command or returncode not in rcs.
    @raises subprocess.TimeoutError when timeout specified and the command
        exceeds that number of seconds.
    NT)r   zStderr: {}
Stdout: {}rV   r   )rW   r   r   r   r   rS   rk   r'   r   r   r   ZwarningrX   rY   rZ   r5   )r7   r   r   r   r^   r   r   r   rM   r   r[   r!   r!   r"   r   ]  s&   r   programc                 C   sr   t jj| v rt| r| S dd t jddt jD }dd |D }|D ]}t j|| }t|r6|  S q%dS )z;Find whether the provided program is executable in our PATHc                 S   s   g | ]}| d qS )r   )r   rP   pr!   r!   r"   rQ     s    
zwhich.<locals>.<listcomp>PATHrc   c                 S   s   g | ]}t j|qS r!   )rI   rH   abspathr   r!   r!   r"   rQ     s    N)	rI   rH   sepr   r   r   r   pathsepr   )r   pathsZnormalized_pathsrH   Zprogram_pathr!   r!   r"   which  s   r     rv   modec                 C   s^   t d|  t| d}||d |  W d   n1 s"w   Y  t| | dS )zWrite content to the provided filename encoding it if necessary.

    @param filename: The full path of the file to write.
    @param content: The content to write to the file.
    @param mode: The filesystem mode to set on the file.
    zWriting file: %swbr   N)r   rS   r   writer   flushrI   chmod)r   rv   r   Zfhr!   r!   r"   ru     s   
ru   	file_pathc                 C   s*   t j| rtd|  t |  dS dS )z<Remove a file if it exists, logging a message about removal.zRemoving file: %sN)rI   rH   rq   r   rS   rJ   )r   r!   r!   r"   remove_file  s   r   configpath_to_valuec                 C   s   | }i }| d}|d }|D ]}||krd}t|tr#|||}q dS t|}| dkr2dS | dkr:dS ttj	j
|d|d)	aK  Check if value parameter can be translated into a boolean 'True' value.

    @param config: A config dict representing
                   /etc/ubuntu-advantange/uaclient.conf
    @param path_to_value: The path from where the value parameter was
                          extracted.
    @return: A boolean value indicating if the value paramater corresponds
             to a 'True' boolean value.
    @raises exceptions.UserFacingError when the value provide by the
            path_to_value parameter can not be translated into either
            a 'False' or 'True' boolean value.
    rf   ZfalseFtrueTzboolean string: true or false)r   Zexpected_valuer=   )r   r*   rC   r   r'   r   r   ZUserFacingErrorr   ZERROR_INVALID_CONFIG_VALUEr   )r   r   r=   Zdefault_valuer   Z
leaf_valuer<   Z	value_strr!   r!   r"   is_config_value_true  s,   

r   )z(Bearer )[^\']+z(\'attach\', \')[^\']+z(\'machineToken\': \')[^\']+z(\'token\': \')[^\']+z((\'X-aws-ec2-metadata-token\': \')[^\']+z*(.*\[PUT\] response.*api/token,.*data: ).*z(https://bearer:)[^\@]+z1(/snap/bin/canonical-livepatch\s+enable\s+)[^\s]+z>(Contract\s+value\s+for\s+'resourceToken'\s+changed\s+to\s+).*z(\'resourceToken\': \')[^\']+z(\'contractToken\': \')[^\']+zF(https://contracts.canonical.com/v1/resources/livepatch\?token=)[^\s]+z(\"identityToken\": \")[^\"]+zT(response:\s+http://metadata/computeMetadata/v1/instance/service-accounts.*data: ).*redact_regexsc                 C   s    | }|D ]	}t |d|}q|S )z4Redact known sensitive information from log content.z\g<1><REDACTED>)r   r   )rl   r   Zredacted_logZredact_regexr!   r!   r"   rk     s   rk   installed_pkgsc                 C   sZ   t jtsdS | du rdS ztttd}W n
 ty#   Y dS w t	| 
|dkS )ah  Check if the system needs to be rebooted.

       :param installed_pkgs: If provided, verify if the any packages in
           the list are present on /var/run/reboot-required.pkgs. If that
           param is provided, we will only return true if we have the
           reboot-required marker file and any package in reboot-required.pkgs
           file.
    FNTrn   r   )rI   rH   rq   REBOOT_FILE_CHECK_PATHr   rr   REBOOT_PKGS_FILE_PATHr   FileNotFoundErrorrX   intersection)r   Zreboot_required_pkgsr!   r!   r"   should_reboot  s   r  package_namec                 C   s:   zt dd| g\}}d| |v W S  tjy   Y dS w )Nr}   z-lzii  {} F)r   r   r   r   )r  r   _r!   r!   r"   is_installed  s   r  msg_opsc                 C   sH   | sdS | D ]}t |trt| q|\}}|di |s! dS qdS )ah  Emit messages to the console for user interaction

    :param msg_op: A list of strings or tuples. Any string items are printed.
        Any tuples will contain a callable and a dict of args to pass to the
        callable. Callables are expected to return True on success and
        False upon failure.

    :return: True upon success, False on failure.
    TFNr!   )r*   r'   r   r   )r  Zmsg_opZfunctorr7   r!   r!   r"   handle_message_operations  s   

r  dt_strc                 C   sD   t dd| }t dd|}|dd}t dd|}tj|d	S )
aT  
    Parse a datestring in rfc3339 format. Originally written for compatibility
    with golang's time.MarshalJSON function. Also handles output of pythons
    isoformat datetime method.

    This drops subseconds.

    :param dt_str: a date string in rfc3339 format

    :return: datetime.datetime object of time represented by dt_str
    z(\d{2}:\d{2}:\d{2})\.\d+z\g<1>z(\d{2}:\d{2}:\d{2})$z\g<1>ZZz+00:00z(-|\+)(\d{2}):(\d{2})$z\g<1>\g<2>\g<3>z%Y-%m-%dT%H:%M:%S%z)r   r   replacer+   strptime)r	  Zdt_str_without_subsecondsZdt_str_with_zZdt_str_without_zZdt_str_with_pythonish_tzr!   r!   r"   r:   6  s   	r:   protocolproxytest_urlc                 C   s   |sd S t |st|tj|dd}t| |i}t|}z|| |W S  tj	t
jfyd } z,t  t|dt|}t
tjj|||d W d    n1 sVw   Y  t|d }~ww )NZHEAD)r   reason)r  r  r   )r   r   ZProxyInvalidUrlr   r   r   r   r   socketr   r   ZURLErrorrU   getattrr'   r   r   ZERROR_USING_PROXYr   ZProxyNotWorkingError)r  r  r  r   r   r   rM   r   r!   r!   r"   validate_proxym  s,   



r  messagec                 C   sP   t jjdu sdt jj vr&| dd} | tjd d} | tjd d} | S )z}
    Verify if the system can output unicode characters and if not,
    remove those characters from the message string.
    NzUTF-8u   —-r   rc   )sysr   encodingr   r  r   ZOKGREEN_CHECKZFAIL_X)r  r!   r!   r"   handle_unicode_characters  s   
r  r)   )rc   )r   )T)rc   F)NFNN)NFNNN)r   )br+   r   r   rI   r   r  r   r  rY   rt   
contextlibr   rL   r   	functoolsr   r   Zhttp.clientr   typingr   r   r	   r
   r   r   r   r   r   Zurllibr   r   Zurllib.parser   Zuaclientr   r   r   r   Zuaclient.typesr   r   r   ro   rp   objectri   r   r   ZPROXY_VALIDATION_APT_HTTP_URLZPROXY_VALIDATION_APT_HTTPS_URLZPROXY_VALIDATION_SNAP_HTTP_URLZPROXY_VALIDATION_SNAP_HTTPS_URLZget_event_loggerr   r   r   ZJSONEncoderr(   ZJSONDecoderr3   r'   rG   rN   rU   rb   rj   rw   rE   boolr   r   r   r   r   rr   r~   r   r   r   r   r   r   floatr   r   r   ru   r   r   ZREDACT_SENSITIVE_LOGSrk   r  r  r  r:   r  r  r!   r!   r!   r"   <module>   s>   ,	!

$
) 



!+" 
)

3


@



.)

 7
