OwlCyberSecurity - MANAGER
Edit File: main.cpython-311.pyc
� E�\hN � �� � d Z ddlZddlZddlmZ ddlmZ ddlmZm Z m Z ddlmZmZ G d� dej � � Z G d � d ej � � Z G d� dej � � Zd � Zedk r e� � dS dS )u This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. Copyright © 2019 Cloud Linux Software Inc. This software is also available under ImunifyAV commercial license, see <https://www.imunify360.com/legal/eula> � N)�HashCalculator)�DB)�PatchDependenciesMatcher�VersionsMatcher� HashesMatcher)�all_possible_relative_paths�dir_traverse_generatorc � � e Zd ZdZdd�ZdS )�ExistingDirActionzJ Check that directory exists and turn its path into absolute path Nc �� � t j � |� � st |� d�� � �t || j t j � |� � � � d S )Nz dir does not exist)�os�path�isdir� ValueError�setattr�dest�abspath��self�parser� namespace�values� option_strings �R/opt/imunify360/venv/lib/python3.11/site-packages/imav/patchman/fs_scanner/main.py�__call__zExistingDirAction.__call__- sW � ��w�}�}�V�$�$� =���;�;�;�<�<�<�� �4�9�b�g�o�o�f�&=�&=�>�>�>�>�>� �N��__name__� __module__�__qualname__�__doc__r � r r r r ( s2 � � � � � �� �?� ?� ?� ?� ?� ?r r c � � e Zd ZdZdd�ZdS )�ReadableFileActionz0 Check that file exists and is readable Nc � � t j � |� � st |� d�� � �t j |t j � � st |� d�� � �t || j |� � d S )Nz does not existz is not readable)r r �isfiler �access�R_OKr r r s r r zReadableFileAction.__call__8 sv � ��w�~�~�f�%�%� 9���7�7�7�8�8�8��y����)�)� :���8�8�8�9�9�9�� �4�9�f�-�-�-�-�-r r r r# r r r% r% 3 s2 � � � � � �� �.� .� .� .� .� .r r% c � � e Zd ZdZdd�ZdS )�WritableFilePathActionz* Check that file path is writable Nc �� � t j � |� � pd}t j |t j � � st d|� d�� � �t || j |� � d S )N�.z Directory z is not writable)r r �dirnamer( �W_OKr r r )r r r r r �dir_names r r zWritableFilePathAction.__call__E se � ��7�?�?�6�*�*�1�c���y��2�7�+�+� F��D�(�D�D�D�E�E�E�� �4�9�f�-�-�-�-�-r r r r# r r r+ r+ @ s2 � � � � � �� �.� .� .� .� .� .r r+ c �& � t j � � } | � dt t d�� � | � dt t d�� � | � dt t d�� � | � dt t d �� � | � d dt t dd �� � | � dt t j � � � dd�� � | � � � }t |j � � }t |j � � }t |j � � }t! |j � � }t% |j � � 5 }t) |j � � D ]j}t- ||j � � D ]R}|� ||||� � } |� ||||� � } |� ||||� � }| r| r|r n�S�k d d d � � d S # 1 swxY w Y d S )N�version_identifiersz%Path to file with version_identifiers)�type�action�help� patch_depsz$Path to file with patch_dependencies�hasheszPath to file with hashes� target_dirzPath to target dirz--outputz-ozPath to output sqlite db fileT)r3 r4 r5 �requiredz--algorithm�md5zHashing algorithm)r3 �choices�defaultr5 )�argparse�ArgumentParser�add_argument�strr% r r+ r �HASHING_ALGORITHMS�keys� parse_argsr r2 r r6 � algorithmr r7 r �outputr r8 r �match_and_save)� argparser�args�versions_matcher�deps_matcher�hash_calculator�hashes_matcher�db� file_path� relative_path�version_matched�deps_matched�hashes_matcheds r �mainrS L s� � ��'�)�)�I� ���� �!� 4� � � � � ���� �!� 3� � � � � ���� �!� '� � � � � ���� � � !� � � � � ����� �%� ,�� � � � � ���� ��1�6�6�8�8�� � � � � � ���!�!�D�&�t�'?�@�@��+�D�O�<�<�L�$�T�^�4�4�O�"�4�;�/�/�N� �D�K��� �B�/���@�@� � �I�!<��4�?�"� "� � � � #3�"A�"A��}�b�/�#� #�� ,�:�:��}�b�/� � �� "0�!>�!>��}�b�/�"� "�� #� �|� �� ��E��� �� � � � � � � � � � � ���� � � � � � s �8B H�H � H �__main__)r"