K6hdZddlZddlZddlmZddlmZddlmZm Z ddlm Z m Z Gddej Z Gd 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)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 r isfileraccessR_OKrrrs rrzReadableFileAction.__call__7svw~~f%% 977788 8y)) :88899 9 49f-----rrrr"rrr$r$2s2......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 r dirnamer'W_OKrrr)rrrrrdir_names rrzWritableFilePathAction.__call__Dse7??6**1cy27++ FD(DDDEE E 49f-----rrrr"rrr*r*?s2......rr*c tj}|dttd|dttd|dtt d|dd tt d d |d ttj dd| }t|j }t|j}t|j}t!|j5}t%|jD]P}t)||jD]8}|||||}|||||} |r| rn9Q ddddS#1swxYwYdS)Nversion_identifiersz%Path to file with version_identifiers)typeactionhelp patch_depsz$Path to file with patch_dependencies target_dirzPath to target dirz--outputz-ozPath to output sqlite db fileT)r2r3r4requiredz --algorithmmd5zHashing algorithm)r2choicesdefaultr4)argparseArgumentParser add_argumentstrr$r r*rHASHING_ALGORITHMSkeys parse_argsrr1rr5 algorithmroutputrr6rmatch_and_save) argparserargsversions_matcher deps_matcherhash_calculatordb file_path relative_pathversion_matched deps_matcheds rmainrOKsD'))I  ! 4   ! 3    !   % ,  16688     ! !D&t'?@@+DO<rUsO. 999999****** ???????? . . . . . . . . . . . . .X_ . . .777t zDFFFFFr