hNdZddlZddlZddlmZddlmZddlmZm Z m Z ddlm Z m Z Gddej ZGd d ej ZGd d ej Zd Zedkr edSdS)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 . Copyright © 2019 Cloud Linux Software Inc. This software is also available under ImunifyAV commercial license, see N)HashCalculator)DB)PatchDependenciesMatcherVersionsMatcher HashesMatcher)all_possible_relative_pathsdir_traverse_generatorceZdZdZddZdS)ExistingDirActionzJ Check that directory exists and turn its path into absolute path Nctj|st|dt ||jtj|dS)Nz dir does not exist)ospathisdir ValueErrorsetattrdestabspathselfparser namespacevalues option_strings R/opt/imunify360/venv/lib/python3.11/site-packages/imav/patchman/fs_scanner/main.py__call__zExistingDirAction.__call__-sWw}}V$$ =;;;<< < 49bgoof&=&=>>>>>N__name__ __module__ __qualname____doc__rrrr r (s2??????rr ceZdZdZddZdS)ReadableFileActionz0 Check that file exists and is readable Nctj|st|dtj|tjst|dt ||j|dS)Nz does not existz is not readable)r risfileraccessR_OKrrrs rrzReadableFileAction.__call__8svw~~f%% 977788 8y)) :88899 9 49f-----rrrr#rrr%r%3s2......rr%ceZdZdZddZdS)WritableFilePathActionz* Check that file path is writable Nctj|pd}tj|tjst d|dt ||j|dS)N.z Directory z is not writable)r rdirnamer(W_OKrrr)rrrrrdir_names rrzWritableFilePathAction.__call__Ese7??6**1cy27++ FD(DDDEE E 49f-----rrrr#rrr+r+@s2......rr+c &tj}|dttd|dttd|dttd|dtt d |d d tt d d |dttj dd| }t|j }t|j}t|j}t!|j}t%|j5}t)|jD]j}t-||jD]R}|||||} |||||} |||||} | r| r| rnSk ddddS#1swxYwYdS)Nversion_identifiersz%Path to file with version_identifiers)typeactionhelp patch_depsz$Path to file with patch_dependencieshasheszPath to file with hashes target_dirzPath to target dirz--outputz-ozPath to output sqlite db fileT)r3r4r5requiredz --algorithmmd5zHashing algorithm)r3choicesdefaultr5)argparseArgumentParser add_argumentstrr%r r+rHASHING_ALGORITHMSkeys parse_argsrr2rr6 algorithmrr7routputr r8rmatch_and_save) argparserargsversions_matcher deps_matcherhash_calculatorhashes_matcherdb file_path relative_pathversion_matched deps_matchedhashes_matcheds rmainrSLs'))I  ! 4   ! 3   ! '    !   % ,  16688     ! !D&t'?@@+DO<!>}b/""#|E s8BHH  H __main__)r"r=r imav.patchman.fs_scanner.utilsrimav.patchman.fs_scanner.dbr imav.patchman.fs_scanner.matcherrrrrr Actionr r%r+rSrr#rrrYs\. 999999******  ???????? . . . . . . . . . . . . .X_ . . .@@@F zDFFFFFr