403Webshell
Server IP : 198.38.94.13  /  Your IP : 216.73.217.33
Web Server : Apache
System : Linux d4744.dxb1.stableserver.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64
User : revivere ( 1140)
PHP Version : 8.2.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/saltstack/salt/lib/python3.10/site-packages/salt/beacons/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/saltstack/salt/lib/python3.10/site-packages/salt/beacons/__pycache__/cert_info.cpython-310.pyc
o

;j/"�@s�dZddlZddlmZddlZddlZz
ddlmZdZWne	y)dZYnwe�
e�ZdZ
dZd	d
�Zdd�Zd
d�Zdd�ZdS)z�
Beacon to monitor certificate expiration dates from files on the filesystem.

.. versionadded:: 3000

:maintainer: <devops@eitr.tech>
:maturity: new
:depends: OpenSSL
�N)�datetime)�cryptoTF�-Z	cert_infocCs2zddlm}Wn
tyt|�YSwt||j�r2|jr!dnd}|jdur0|�d|j��}|St||j|j	f�r�g}|D]P}t||j
�rQ|�d|j���q?t||j
�ra|�d|j���q?t||j�rq|�d	|j���q?t||j�r�|�d
|j���q?|�t|�j�d|j���q?d�|�St|�S)
aF
    Render a ``cryptography.x509`` extension value in the OpenSSL-style
    short form that pyOpenSSL's ``str(X509Extension)`` produced (for
    example "CA:FALSE" or "DNS:foo, IP:1.2.3.4"). Only handles the
    common extensions the cert_info beacon callers historically saw;
    falls back to ``str(value)`` otherwise.
    r)�x509zCA:TRUEzCA:FALSENz
, pathlen:zDNS:zIP:zemail:zURI:�:z, )Zcryptographyr�ImportError�str�
isinstanceZBasicConstraints�caZpath_lengthZSubjectAlternativeNameZIssuerAlternativeNameZDNSName�append�valueZ	IPAddressZ
RFC822NameZUniformResourceIdentifier�type�__name__�join)rZ_x509�out�parts�name�r�J/opt/saltstack/salt/lib/python3.10/site-packages/salt/beacons/cert_info.py�_format_extension_values0�

rcCs&tdurd}t�dt|�d|fStS)NFzOpenSSL library is missing.zUnable to load %s beacon: %s)�HAS_OPENSSL�log�error�__virtualname__)�err_msgrrr�__virtual__Fs
rcCs,t|t�sdStjj�|�}d|vrdSdS)z+
    Validate the beacon configuration
    )Fz2Configuration for cert_info beacon must be a list.�files)Fz=Configuration for cert_info beacon must contain files option.)TzValid beacon configuration)r	�list�salt�utils�beacons�list_to_dict)�configrrr�validateOs
r#cCsg}g}tj}tjj�|�}|�dt�}|�dg�D�]_}|}t|t	�rPzt
t|��}||�d|�}WntyM}z
t
�d||�WYd}~qd}~ww|}z"tjj�|��}	t�tj|	���}
Wd�n1slwYWnt|fy�}z
t
�d||�WYd}~qd}~wwt�|
��jdd�d�}|t��j}t
�d||�|d	ks�||k�rzt
�d
||�g}
t|
d�r�td	|
���D]}|
�|
� |��!�jdd�t"|
� |��d��q�n4z|
�#�}|j$D]}|
�|j%j&t'|j(�d��q�Wnt)�y}z
t
�d
||�WYd}~nd}~ww|�|d�*dd�|
�+��,�D��dd�|
�+��,�D�|
��jdd�|�-d�|
�.�jdd�t�|
�.�jdd�d��-d�|
�/�|
�0�jdd�d�*dd�|
�1��,�D��dd�|
�1��,�D�|
�2�|
|
�3�d��q|�r�|�d|i�|S)a�
    Monitor the certificate files on the minion.

    Specify a notification threshold in days and only emit a beacon if any certificates are
    expiring within that timeframe or if `notify_days` equals `-1` (always report information).
    The default notification threshold is 45 days and can be overridden at the beacon level and
    at an individual certificate level.

    .. code-block:: yaml

        beacons:
          cert_info:
            - files:
                - /etc/pki/tls/certs/mycert.pem
                - /etc/pki/tls/certs/yourcert.pem:
                    notify_days: 15
                - /etc/pki/tls/certs/ourcert.pem
            - notify_days: 45
            - interval: 86400

    �notify_daysrz"Unable to load certificate %s (%s)N�UTF-8��encodingz
%Y%m%d%H%M%SZz"Certificate %s expires in %s days.rzECertificate %s triggered beacon due to %s day notification threshold.�
get_extension)Zext_nameZext_dataz*Unable to enumerate extensions for %s (%s)�,cS�0g|]}d�|djdd�|djdd���qS�z{}="{}"rr%r&���format�decode��.0�trrr�
<listcomp>�����zbeacon.<locals>.<listcomp>cS�"i|]
\}}|�d�|�d��qS�r%�r/�r1�k�vrrr�
<dictcomp>����zbeacon.<locals>.<dictcomp>z%Y-%m-%d %H:%M:%SZcSr*r+r-r0rrrr3�r4cSr5r6r7r8rrrr;�r<)�	cert_pathZissuerZissuer_dictZnotAfter_rawZnotAfterZ
notBefore_rawZ	notBeforeZ
serial_numberZsignature_algorithm�subjectZsubject_dict�version�
extensions�has_expired�certificates)4r�Errorrrr r!�get�DEFAULT_NOTIFY_DAYSr	�dict�next�iter�
StopIterationrrrZfopenZload_certificateZFILETYPE_PEM�read�OSErrorr�strptimeZget_notAfterr/�today�days�debug�hasattr�rangeZget_extension_countrr(Zget_short_namerZto_cryptographyr@�oid�_namerr�	ExceptionrZ
get_issuerZget_components�strftimeZ
get_notBeforeZget_serial_numberZget_signature_algorithmZget_subjectZget_versionrA)r"�retrBZCryptoErrorZglobal_notify_daysr=r$Znext_cert_path�excZfp_�certZ	cert_dateZ	date_diffr@�extZcrypto_certrrr�beaconas�
���������
����

������
��	
���
��	
����-rZ)�__doc__�loggingrZsalt.utils.beaconsrZsalt.utils.filesZOpenSSLrrr�	getLoggerrrrErrrr#rZrrrr�<module>s$
�
'	

Youez - 2016 - github.com/yon3zu
LinuXploit