o
    ҷhB                     @  sz  d dl mZ ddlmZmZ d dlmZ d dlZd dlZddl	m
Z
 G dd deZG d	d
 d
ejZG dd dejZeG dd dZG dd dejZeG dd dZeG dd dZeG dd dZeG dd dZG dd dejZd6ddZd6dd Zd7d#d$Zd8d(d)Zd9d+d,Zed-eG d.d/ d/Zed0eG d1d2 d2Zed3eG d4d5 d5ZdS ):    )annotations   )event_classT_JSON_DICT)	dataclassN)networkc                      s8   e Zd ZdZdddZedddZ fd	d
Z  ZS )CertificateIdz+
    An internal certificate ID value.
    returnintc                 C  s   | S N selfr   r   b/var/www/html/venv/lib/python3.10/site-packages/selenium/webdriver/common/devtools/v85/security.pyto_json   s   zCertificateId.to_jsonjsonc                 C     | |S r   r   clsr   r   r   r   	from_json      zCertificateId.from_jsonc                   s   d t  S )NzCertificateId({}))formatsuper__repr__r   	__class__r   r   r      s   zCertificateId.__repr__)r	   r
   )r   r
   r	   r   )	__name__
__module____qualname____doc__r   classmethodr   r   __classcell__r   r   r   r   r      s    
r   c                   @  s0   e Zd ZdZdZdZdZdd Zedd Z	d	S )
MixedContentTypez
    A description of mixed content (HTTP resources on HTTPS pages), as defined by
    https://www.w3.org/TR/mixed-content/#categories
    	blockablezoptionally-blockablenonec                 C     | j S r   valuer   r   r   r   r   '      zMixedContentType.to_jsonc                 C  r   r   r   r   r   r   r   r   *   r   zMixedContentType.from_jsonN)
r   r   r   r   	BLOCKABLEOPTIONALLY_BLOCKABLENONEr   r    r   r   r   r   r   r"      s    r"   c                   @  s<   e Zd ZdZdZdZdZdZdZdZ	dd	 Z
ed
d ZdS )SecurityStatez3
    The security level of a page or resource.
    unknownneutralinsecuresecureinfozinsecure-brokenc                 C  r%   r   r&   r   r   r   r   r   :   r(   zSecurityState.to_jsonc                 C  r   r   r   r   r   r   r   r   =   r   zSecurityState.from_jsonN)r   r   r   r   UNKNOWNNEUTRALINSECURESECUREINFOINSECURE_BROKENr   r    r   r   r   r   r   r,   /   s    r,   c                   @  s   e Zd ZU dZded< ded< ded< ded< ded< ded	< d
ed< d
ed< ded< ded< ded< ded< ded< ded< ded< dZded< dZded< dZded< dd Ze	dd Z
dS )CertificateSecurityStatezC
    Details about the security state of the page certificate.
    strprotocolkey_exchangeciphertyping.List[str]certificatesubject_nameissuerznetwork.TimeSinceEpoch
valid_fromvalid_toboolcertificate_has_weak_signaturecertificate_has_sha1_signature
modern_sslobsolete_ssl_protocolobsolete_ssl_key_exchangeobsolete_ssl_cipherobsolete_ssl_signatureNtyping.Optional[str]key_exchange_groupmaccertificate_network_errorc                 C  s   t  }| j|d< | j|d< | j|d< dd | jD |d< | j|d< | j|d< | j |d	< | j	 |d
< | j
|d< | j|d< | j|d< | j|d< | j|d< | j|d< | j|d< | jd ura| j|d< | jd urk| j|d< | jd uru| j|d< |S )Nr:   keyExchanger<   c                 S     g | ]}|qS r   r   .0ir   r   r   
<listcomp>       z4CertificateSecurityState.to_json.<locals>.<listcomp>r>   subjectNamer@   	validFromvalidTocertificateHasWeakSignaturecertificateHasSha1Signature	modernSSLobsoleteSslProtocolobsoleteSslKeyExchangeobsoleteSslCipherobsoleteSslSignaturekeyExchangeGrouprM   certificateNetworkError)dictr:   r;   r<   r>   r?   r@   rA   r   rB   rD   rE   rF   rG   rH   rI   rJ   rL   rM   rN   r   r   r   r   r   r   }   s.   

















z CertificateSecurityState.to_jsonc                 C  s<  | d"i dt |d dt |d dt |d ddd |d D dt |d	 d
t |d
 dtj|d dtj|d dt|d dt|d dt|d dt|d dt|d dt|d dt|d dd|v r~t |d nd dd|v rt |d nd d d!|v rt |d! S d S )#Nr:   r;   rO   r<   r>   c                 S     g | ]}t |qS r   r9   rQ   r   r   r   rT          z6CertificateSecurityState.from_json.<locals>.<listcomp>r?   rV   r@   rA   rW   rB   rX   rD   rY   rE   rZ   rF   r[   rG   r\   rH   r]   rI   r^   rJ   r_   rL   r`   rM   rN   ra   r   )r9   r   TimeSinceEpochr   rC   r   r   r   r   r      sR   	
z"CertificateSecurityState.from_json)r   r   r   r   __annotations__rL   rM   rN   r   r    r   r   r   r   r   r8   B   s.   
 r8   c                   @  s(   e Zd ZdZdZdd Zedd ZdS )SafetyTipStatusbadReputation	lookalikec                 C  r%   r   r&   r   r   r   r   r      r(   zSafetyTipStatus.to_jsonc                 C  r   r   r   r   r   r   r   r      r   zSafetyTipStatus.from_jsonN)r   r   r   BAD_REPUTATION	LOOKALIKEr   r    r   r   r   r   r   ri      s    ri   c                   @  s6   e Zd ZU ded< dZded< dd Zedd	 ZdS )
SafetyTipInfori   safety_tip_statusNrK   safe_urlc                 C  s,   t  }| j |d< | jd ur| j|d< |S )NsafetyTipStatussafeUrl)rb   ro   r   rp   rc   r   r   r   r      s
   

zSafetyTipInfo.to_jsonc                 C  s.   | t |d d|v rt|d dS d dS )Nrq   rr   )ro   rp   )ri   r   r9   r   r   r   r   r      s   zSafetyTipInfo.from_json)r   r   r   rh   rp   r   r    r   r   r   r   r   rn      s   
 rn   c                   @  sN   e Zd ZU dZded< ded< dZded< dZd	ed
< dd Zedd Z	dS )VisibleSecurityStatez4
    Security state information about the page.
    r,   security_stater=   security_state_issue_idsNz)typing.Optional[CertificateSecurityState]certificate_security_stateztyping.Optional[SafetyTipInfo]safety_tip_infoc                 C  s\   t  }| j |d< dd | jD |d< | jd ur | j |d< | jd ur,| j |d< |S )NsecurityStatec                 S  rP   r   r   rQ   r   r   r   rT      rU   z0VisibleSecurityState.to_json.<locals>.<listcomp>securityStateIssueIdscertificateSecurityStatesafetyTipInfo)rb   rt   r   ru   rv   rw   rc   r   r   r   r      s   

zVisibleSecurityState.to_jsonc                 C  sX   | t |d dd |d D d|v rt|d nd d|v r(t|d dS d dS )Nrx   c                 S  rd   r   re   rQ   r   r   r   rT      rf   z2VisibleSecurityState.from_json.<locals>.<listcomp>ry   rz   r{   )rt   ru   rv   rw   )r,   r   r8   rn   r   r   r   r   r      s   zVisibleSecurityState.from_json)
r   r   r   r   rh   rv   rw   r   r    r   r   r   r   r   rs      s   
 
rs   c                   @  sb   e Zd ZU dZded< ded< ded< ded< ded	< d
ed< dZded< dd Zedd ZdS )SecurityStateExplanationzI
    An explanation of an factor contributing to the security state.
    r,   rt   r9   titlesummarydescriptionr"   mixed_content_typer=   r>   Nz!typing.Optional[typing.List[str]]recommendationsc                 C  sv   t  }| j |d< | j|d< | j|d< | j|d< | j |d< dd | jD |d< | jd ur9d	d | jD |d
< |S )Nrx   r}   r~   r   mixedContentTypec                 S  rP   r   r   rQ   r   r   r   rT     rU   z4SecurityStateExplanation.to_json.<locals>.<listcomp>r>   c                 S  rP   r   r   rQ   r   r   r   rT     rU   r   )	rb   rt   r   r}   r~   r   r   r>   r   rc   r   r   r   r     s   



z SecurityStateExplanation.to_jsonc              
   C  sn   | t |d t|d t|d t|d t|d dd |d D d	|v r3d
d |d	 D dS d dS )Nrx   r}   r~   r   r   c                 S  rd   r   re   rQ   r   r   r   rT   $  rf   z6SecurityStateExplanation.from_json.<locals>.<listcomp>r>   r   c                 S  rd   r   re   rQ   r   r   r   rT   %  rf   )rt   r}   r~   r   r   r>   r   )r,   r   r9   r"   r   r   r   r   r     s   


z"SecurityStateExplanation.from_json)	r   r   r   r   rh   r   r   r    r   r   r   r   r   r|      s   
 r|   c                   @  s^   e Zd ZU dZded< ded< ded< ded< ded< ded	< ded
< dd Zedd ZdS )InsecureContentStatusz9
    Information about insecure content on the page.
    rC   ran_mixed_contentdisplayed_mixed_contentcontained_mixed_formran_content_with_cert_errors"displayed_content_with_cert_errorsr,   ran_insecure_content_style displayed_insecure_content_stylec                 C  sX   t  }| j|d< | j|d< | j|d< | j|d< | j|d< | j |d< | j |d< |S )NranMixedContentdisplayedMixedContentcontainedMixedFormranContentWithCertErrorsdisplayedContentWithCertErrorsranInsecureContentStyledisplayedInsecureContentStyle)	rb   r   r   r   r   r   r   r   r   rc   r   r   r   r   C  s   




zInsecureContentStatus.to_jsonc                 C  sR   | t |d t |d t |d t |d t |d t|d t|d dS )	Nr   r   r   r   r   r   r   )r   r   r   r   r   r   r   )rC   r,   r   r   r   r   r   r   N  s   




zInsecureContentStatus.from_jsonN)r   r   r   r   rh   r   r    r   r   r   r   r   r   )  s   
 r   c                   @  s,   e Zd ZdZdZdZdd Zedd ZdS )	CertificateErrorActionz
    The action to take when a certificate error occurs. continue will continue processing the
    request and cancel will cancel the request.
    continuecancelc                 C  r%   r   r&   r   r   r   r   r   c  r(   zCertificateErrorAction.to_jsonc                 C  r   r   r   r   r   r   r   r   f  r   z CertificateErrorAction.from_jsonN)	r   r   r   r   CONTINUECANCELr   r    r   r   r   r   r   r   [  s    r   r	   0typing.Generator[T_JSON_DICT, T_JSON_DICT, None]c                  c      ddi} | V }dS )z3
    Disables tracking security state changes.
    methodzSecurity.disableNr   cmd_dictr   r   r   r   disablek     
r   c                  c  r   )z2
    Enables tracking security state changes.
    r   zSecurity.enableNr   r   r   r   r   enableu  r   r   ignorerC   c                 c  $    t  }| |d< d|d}|V }dS )z
    Enable/disable whether all certificate errors should be ignored.

    **EXPERIMENTAL**

    :param ignore: If true, all certificate errors will be ignored.
    r   z#Security.setIgnoreCertificateErrorsr   paramsNrb   )r   r   r   r   r   r   r   set_ignore_certificate_errors  s   

r   event_idr
   actionc                 c  s0    t  }| |d< | |d< d|d}|V }dS )z
    Handles a certificate error that fired a certificateError event.

    :param event_id: The ID of the event.
    :param action: The action to take on the certificate error.
    eventIdr   zSecurity.handleCertificateErrorr   N)rb   r   )r   r   r   r   r   r   r   r   handle_certificate_error  s   

r   overridec                 c  r   )a  
    Enable/disable overriding certificate errors. If enabled, all certificate error events need to
    be handled by the DevTools client and should be answered with ``handleCertificateError`` commands.

    :param override: If true, certificate errors will be overridden.
    r   z%Security.setOverrideCertificateErrorsr   Nr   )r   r   r   r   r   r   r   set_override_certificate_errors  s   	
r   zSecurity.certificateErrorc                   @  s8   e Zd ZU dZded< ded< ded< edd
dZdS )CertificateErroraL  
    There is a certificate error. If overriding certificate errors is enabled, then it should be
    handled with the ``handleCertificateError`` command. Note: this event does not fire if the
    certificate error has been allowed internally. Only one client per target should override
    certificate errors at the same time.
    r
   r   r9   
error_typerequest_urlr   r   r	   c                 C  s&   | t |d t|d t|d dS )Nr   	errorType
requestURL)r   r   r   )r
   r9   r   r   r   r   r     s
   


zCertificateError.from_jsonN)r   r   r	   r   r   r   r   r   rh   r    r   r   r   r   r   r     s   
 r   z$Security.visibleSecurityStateChangedc                   @  s(   e Zd ZU dZded< ed
ddZd	S )VisibleSecurityStateChangedzG
    **EXPERIMENTAL**

    The security state of the page changed.
    rs   visible_security_stater   r   r	   c                 C  s   | t |d dS )NvisibleSecurityState)r   )rs   r   r   r   r   r   r     s   z%VisibleSecurityStateChanged.from_jsonN)r   r   r	   r   r   r   r   r   r   r     s
   
 r   zSecurity.securityStateChangedc                   @  sH   e Zd ZU dZded< ded< ded< ded	< d
ed< edddZdS )SecurityStateChangedz1
    The security state of the page changed.
    r,   rt   rC   scheme_is_cryptographicz%typing.List[SecurityStateExplanation]explanationsr   insecure_content_statusrK   r~   r   r   r	   c                 C  sT   | t |d t|d dd |d D t|d d|v r&t|d dS d dS )	Nrx   schemeIsCryptographicc                 S  s   g | ]}t |qS r   )r|   r   rQ   r   r   r   rT     s    z2SecurityStateChanged.from_json.<locals>.<listcomp>r   insecureContentStatusr~   )rt   r   r   r   r~   )r,   r   rC   r   r9   r   r   r   r   r     s   
zSecurityStateChanged.from_jsonN)r   r   r	   r   r   r   r   r   r   r     s   
 r   )r	   r   )r   rC   r	   r   )r   r
   r   r   r	   r   )r   rC   r	   r   )
__future__r   utilr   r   dataclassesr   enumtyping r   r
   r   Enumr"   r,   r8   ri   rn   rs   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>   sF   k$21






