ďl 6 d Z ddlmZ G d d Zd ZdS )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
)
HashesMatcherc e Zd Zd ZdS )DummyDBc N g | _ G d d } || | _ d S )Nc e Zd Zd Zd ZdS )$DummyDB.__init__..DummyTablec || _ d S N)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
"
c D | j j | d S r
)r insertedappend)r rows r
buffered_insertz4DummyDB.__init__..DummyTable.buffered_insert! s!
#**3/////r N)__name__
__module____qualname__r r r r
DummyTabler s2
#
#
#
0
0
0
0
0r r )r hashes_matches)r r s r
r zDummyDB.__init__ sK
0 0 0 0 0 0 0 0 )j..r N)r r r r r r r
r r s#
/
/
/
/
/r r c
d}| dz }| | | dz
d | dz d G
fdd }t t | }t }| t
d| | }| t d| | }| t | d z d | | }| t d| | } |d
u sJ |d
u sJ |du sJ | du sJ t |j dk sJ |j d
t
dddd
fk sJ |j d t ddddfk sJ d S )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.txtdata2c e Zd Zd fd ZdS )Dtest_hashes_matcher_filters_and_matches..DummyHashCalculatorFc \ |t k rdS |t k rdS dS )N goodhash1 goodhash3nope)str)r pathapply_normalizationfile1file2s r
calc_hashzNtest_hashes_matcher_filters_and_matches..DummyHashCalculator.calc_hash: s4 s5zz!!"{s5zz!!"{6r N)F)r r r r* )r( r) s r
DummyHashCalculatorr 9 s8 r r+ z file3.txtTF r r" i r# i )
write_textr r% r match_and_savelenr )tmp_pathhashes_contenthashes_filer+ matcherdbmatched1matched2matched3matched4r( r) s @@r
'test_hashes_matcher_filters_and_matchesr: ' s= X%K>***{"E W{"E W C,,--G B%%E
K%8%8%:%: H %%E
K%8%8%:%: H %%H{"##["6I6I6K6K H %%E
K%8%8%:%: H ttuur{q
;q>c%jj+q$BBBBB
;q>c%jj+q$BBBBBBBr N)__doc__ imav.patchman.fs_scanner.matcherr r r: r r r
r= si * ; : : : : :/ / / / / / / /0C 0C 0C 0C 0Cr