h[ 6dZddlmZGddZdZdS)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 ) HashesMatcherceZdZdZdS)DummyDBcNg|_Gdd}|||_dS)NceZdZdZdZdS)$DummyDB.__init__..DummyTablec||_dSN)outer)selfr s ]/opt/imunify360/venv/lib/python3.11/site-packages/imav/patchman/fs_scanner/test_fs_scanner.py__init__z-DummyDB.__init__..DummyTable.__init__s " cD|jj|dSr )r insertedappend)r rows r buffered_insertz4DummyDB.__init__..DummyTable.buffered_insert!s! #**3/////rN)__name__ __module__ __qualname__rrrr DummyTablers2 # # # 0 0 0 0 0rr)rhashes_matches)r rs r rzDummyDB.__init__sK  0 0 0 0 0 0 0 0)j..rN)rrrrrrr rrs# / / / / /rrc d}|dz }|||dz d|dz dG fdd}tt|}t}|t d||}|t d||}|t|d z d ||}|t d||} |d usJ|d usJ|d usJ| d usJt |jd ksJ|jd t dd dd fksJ|jdt dd ddfksJdS)Nz1:1000:deadbeef:0 2:2000:goodhash1:0 2:2001:goodhash2:2 7:3000:deadbeef2:0 8:4000:deadbeef3:0 2:2002:goodhash3:1 2:2002:goodhash3:1 hashesz file1.txtdata1z file2.txtdata2ceZdZdfd ZdS)Dtest_hashes_matcher_filters_and_matches..DummyHashCalculatorFc\|tkrdS|tkrdSdS)N goodhash1 goodhash3nope)str)r pathapply_normalizationfile1file2s r calc_hashzNtest_hashes_matcher_filters_and_matches..DummyHashCalculator.calc_hash:s4s5zz!!"{s5zz!!"{6rN)F)rrrr*)r(r)sr DummyHashCalculatorr 9s8         rr+z file3.txtTFrr"ir#i) write_textrr%rmatch_and_savelenr) tmp_pathhashes_content hashes_filer+matcherdbmatched1matched2matched3matched4r(r)s @@r 'test_hashes_matcher_filters_and_matchesr:'s= X%K>*** { "E W { "E WC ,,--G B%% E K%8%8%:%:H%% E K%8%8%:%:H%% H{ "##["6I6I6K6KH%% E K%8%8%:%:H t     t     u     u     r{  q ;q>c%jj+q$B B B B B ;q>c%jj+q$B B B B B B BrN)__doc__ imav.patchman.fs_scanner.matcherrrr:rrr r=si*;::::: / / / / / / / /0C0C0C0C0Cr