NineSec Team Shell
Server IP : 184.107.3.203  /  Your IP : 216.73.216.51
Web Server : Apache
System : Linux dedicated2.avenfashion.com.ph 4.18.0-553.40.1.el8_10.x86_64 #1 SMP Mon Feb 10 12:11:18 EST 2025 x86_64
User : adminteladeoro ( 1015)
PHP Version : 8.2.28
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /usr/lib/python3.6/site-packages/sos/report/plugins/__pycache__/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : //usr/lib/python3.6/site-packages/sos/report/plugins/__pycache__/jars.cpython-36.pyc
3

~�g��@s^ddlZddlZddlZddlZddlZddlmZddlmZm	Z	m
Z
Gdd�dee	�ZdS)�N)�partial)�Plugin�RedHatPlugin�	PluginOptc@s^eZdZdZdZdZeddedd�edd	d
d�gZdZ	dZ
dd�Zdd�Zdd�Z
dd�ZdS)�Jarsz1Collect information about available Java archives�jars�javazappend-locations�z,colon-delimited list of additional JAR paths)�defaultZval_type�desczall-known-locationsFzscan all known paths)r
r�/usr/share/java�
/usr/lib/java�/opt�
/usr/local�/var/libcCsdgi}g}ttj�}|jd�r.|ttj�7}|jd�}|rJ||jd�7}xT|D]L}xFtj|�D]8\}}}x,|D]$}	|j||	�}
|j	|
�rp|j
|
�qpWq`WqPWxB|D]:}|j|�}|j|�}
|s�|
r�||
|d�}|dj
|�q�Wt
j|dd
d	�}|j|d
dd�dS)Nrzall-known-locationszappend-locations�:)�path�sha1�maven_id��,�: )�indentZ
separatorsz	jars.jsonT)Zplug_dir)rr)�listr�
jar_locationsZ
get_option�extra_jar_locations�split�os�walkZ	path_join�is_jar�append�get_maven_id�
get_jar_id�json�dumpsZadd_string_as_file)�self�resultsZ	jar_pathsZ	locationsZuser_locations�location�dirpath�_�	filenames�filenamer�jar_pathr�jar_id�recordZresults_str�r/�/usr/lib/python3.6/jars.py�setup1s0








z
Jars.setupcCs�tjj|�r�tj|�r�y*tj|��}d|j�kr4dSWdQRXWn>ttjfk
r~}z|j	d|�d|���WYdd}~XnXdS)z�Check whether given file is a JAR file.

        JARs are ZIP files which usually include a manifest
        at the canonical location 'META-INF/MANIFEST.MF'.
        zMETA-INF/MANIFEST.MFTNzCould not determine if z is a JAR: F)
rr�isfile�zipfileZ
is_zipfile�ZipFile�namelist�IOErrorZ
BadZipfile�	_log_info)r%r�file�errr/r/r0rTs$zJars.is_jarc
 si}y�tj|���}tjd���fdd�|j�D�}t|�dkrBdS|j|d��v}xn|j�D]b}|j�}|j	d�s\y6|j
d�\}}|jd	�j�}|jd	�j�}|||<Wq\tk
r�dSXq\WWdQRXWdQRXWn:t
k
�r}	z|jd
|�d|	���WYdd}	~	XnX|S)z�Extract Maven coordinates from a given JAR file, if possible.

        JARs build by Maven (most popular Java build system) contain
        'pom.properties' file. We can extract Maven coordinates
         from there.
        z*META-INF/maven/[^/]+/[^/]+/pom.properties$csg|]}�j|�r|�qSr/)�match)�.0�x)�rgxr/r0�
<listcomp>psz%Jars.get_maven_id.<locals>.<listcomp>�Nr�#�=�utf8z)Could not extract Maven coordinates from z: )r3r4�re�compiler5�len�open�	readlines�strip�
startswithr�decode�
ValueErrorr6r7)
r%r,Zpropsr8�resultZprops_f�line�key�valuer9r/)r=r0r!es,

"$zJars.get_maven_idcCs�d}yRt|dd��4}tj�}x$tt|jd�d�D]}|j|�q0WWdQRX|j�}Wn8tk
r�}z|j	d|�d|���WYdd}~XnX|S)	zHCompute JAR id.

        Returns sha1 hash of a given JAR file.
        r	�rb)�modei�NzCould not compute JAR id for z: )
rF�hashlibr�iterr�read�updateZ	hexdigestr6r7)r%r,r-r8ZdigestZbufr9r/r/r0r"�s(zJars.get_jar_idN)r)rr
)rrr)�__name__�
__module__�__qualname__Z
short_descZplugin_nameZprofilesr�strZoption_listrrr1rr!r"r/r/r/r0rs 
#r)rSr#rrCr3�	functoolsrZsos.report.pluginsrrrrr/r/r/r0�<module>s

NineSec Team - 2022