diff --git a/unit_tests/clamscan/lzh_lha_archive_test.py b/unit_tests/clamscan/lzh_lha_archive_test.py new file mode 100644 index 0000000000..7214bef6c0 --- /dev/null +++ b/unit_tests/clamscan/lzh_lha_archive_test.py @@ -0,0 +1,59 @@ +# Copyright (C) 2020-2024 Cisco Systems, Inc. and/or its affiliates. All rights reserved. + +""" +Run clamscan tests. +""" + +import sys + +sys.path.append('../unit_tests') +import testcase + + +class TC(testcase.TestCase): + @classmethod + def setUpClass(cls): + super(TC, cls).setUpClass() + + # Testing with our logo png file. + TC.testfiles = list(TC.path_source.glob('unit_tests/input/other_scanfiles/lha_lzh/*.lzh')) + + @classmethod + def tearDownClass(cls): + super(TC, cls).tearDownClass() + + def setUp(self): + super(TC, self).setUp() + + def tearDown(self): + super(TC, self).tearDown() + self.verify_valgrind_log() + + def test_good_archives(self): + self.step_name('Verify that these LHA archives containing logo.png and cisco-logo.png correctly extract each.') + + (TC.path_tmp / 'good.ldb').write_text( + "logo.png;Engine:150-255,Target:0;0;fuzzy_img#af2ad01ed42993c7#0\n" + "cisco-logo.png;Engine:150-255,Target:0;0;fuzzy_img#9463944473afd82f#0\n" + ) + + testfiles = ' '.join([str(testfile) for testfile in TC.testfiles]) + + command = '{valgrind} {valgrind_args} {clamscan} -d {path_db} {testfiles} --allmatch'.format( + valgrind=TC.valgrind, valgrind_args=TC.valgrind_args, clamscan=TC.clamscan, + path_db=TC.path_tmp / 'good.ldb', + testfiles=testfiles, + ) + output = self.execute_command(command) + + assert output.ec == 1 # virus + assert output.out.count(' logo.png.UNOFFICIAL FOUND') == len(TC.testfiles) + assert output.out.count(' cisco-logo.png.UNOFFICIAL FOUND') == len(TC.testfiles) + + expected_stdout = [ + 'logo.png.UNOFFICIAL FOUND', + ] + unexpected_stdout = [ + 'OK', + ] + self.verify_output(output.out, expected=expected_stdout) diff --git a/unit_tests/input/other_scanfiles/lha_lzh/default.cap.lzh b/unit_tests/input/other_scanfiles/lha_lzh/default.cap.lzh new file mode 100755 index 0000000000..32e704ef65 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/default.cap.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/default.euc.lzh b/unit_tests/input/other_scanfiles/lha_lzh/default.euc.lzh new file mode 100755 index 0000000000..792c854c56 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/default.euc.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/default.lzh b/unit_tests/input/other_scanfiles/lha_lzh/default.lzh new file mode 100755 index 0000000000..ca73b27c86 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/default.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/default.sjis.lzh b/unit_tests/input/other_scanfiles/lha_lzh/default.sjis.lzh new file mode 100755 index 0000000000..ca73b27c86 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/default.sjis.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/default.utf8.lzh b/unit_tests/input/other_scanfiles/lha_lzh/default.utf8.lzh new file mode 100755 index 0000000000..f6f9da3d94 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/default.utf8.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/general.obsolete.lzh b/unit_tests/input/other_scanfiles/lha_lzh/general.obsolete.lzh new file mode 100755 index 0000000000..1fb17133e3 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/general.obsolete.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/lh0.lzh b/unit_tests/input/other_scanfiles/lha_lzh/lh0.lzh new file mode 100755 index 0000000000..13e13a6d26 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/lh0.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/lh1.lzh b/unit_tests/input/other_scanfiles/lha_lzh/lh1.lzh new file mode 100755 index 0000000000..86398dbbf4 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/lh1.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/lh2.lzh b/unit_tests/input/other_scanfiles/lha_lzh/lh2.lzh new file mode 100755 index 0000000000..f3a6076d36 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/lh2.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/lh5.lzh b/unit_tests/input/other_scanfiles/lha_lzh/lh5.lzh new file mode 100755 index 0000000000..ca73b27c86 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/lh5.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/lh6.lzh b/unit_tests/input/other_scanfiles/lha_lzh/lh6.lzh new file mode 100755 index 0000000000..b4b5859a06 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/lh6.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/lh7.lzh b/unit_tests/input/other_scanfiles/lha_lzh/lh7.lzh new file mode 100755 index 0000000000..2f1a3bcab4 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/lh7.lzh differ diff --git a/unit_tests/input/other_scanfiles/lha_lzh/traditional.lzh b/unit_tests/input/other_scanfiles/lha_lzh/traditional.lzh new file mode 100755 index 0000000000..ca73b27c86 Binary files /dev/null and b/unit_tests/input/other_scanfiles/lha_lzh/traditional.lzh differ