Commit Graph

72 Commits

Author SHA1 Message Date
Alexander Sulfrian
c5c3b7558e CMake: Fix race condition with parallel builds
If running multiple parallel processes of "xor_testfile.py" there was a
race condition between checking for the existence of the directory and
creating it. Now this is handled as a dependency in CMake.
2021-09-27 13:03:24 -07:00
Micah Snyder
4b400b9b1e Test: Verify that pdf bytecode hooks execute 2021-07-19 14:47:25 -07:00
Micah Snyder
b406e7e4d6 Add feature test for XLS image (JPG & PNG) extraction
Added a test to verify that clamscan can extract images from an XLS
document. The document has 2 images: a PNG and JPEG version of the
clamav demon/logo. The test requires the json metadata feature to verify
that the MD5 of the images are correct.

No other image formats were tested because despite the format allegedly
supporting other imate formats, Excel converts TIFF, BMP, and GIF images
to PNG files when you insert them.
2021-07-17 10:39:27 -07:00
Micah Snyder
201e1b12a7 XOR test files; clean up tests directory
The split test files are flagged by some AV's because they look like
broken executables. Instead of splitting the test files to prevent
detections, we should encrypt them. This commit replaces the "reassemble
testfiles" script with a basic "XOR testfiles" script that can be used
to encrypt or decrypt test files. This commit also of course then
replaces all the split files with xor'ed files.

The test and unit_tests directories were a bit of a mess, so I
reorganized them all into unit_tests with all of the test files placed
under "unit_tests/input" using subdirectories for different types of files.
2021-07-17 10:39:27 -07:00
Andrew
319bfb51a5 Fix several coverity warnings
290424 Missing break in switch - In hash_match: Missing break
statement between cases in switch statement

290414 Resource leak - In cli_scanishield_msi: Leak of memory or
pointers to system resources. Memory leak in a fail case

288197 Resource leak - In decrypt_any: Leak of memory or pointers
to system resources. Memory leak in a fail case

290426 Resource leak - In cli_magic_scan: Leak of memory or pointers
to system resources. Leaked a file prefix when running with
--save-temps

192923 Resource leak - In cli_scanrar: Leak of memory or pointers to
system resources. Leaked a file descriptor if a virus was found in
a RAR file comment

225146 Resource leak - In cli_scanegg: Leak of memory or pointers
to system resources. Leaked a file descriptor if unable to write
a comment file to disk

290425 Resource leak - In scan_common: Leak of memory or pointers
to system resources. Memory leaks in various fail cases.

Also changes cli_scanrar to write out the file comment only if
--leave-temps is specified and scan the buffer (like what is done
in cli_scanegg) instead of writing the file out, scanning that,
and then deleting the file if --leave-temps is not specified.

The unit tests stopped working when correcting an issue with a
switch statement that determined what type of signature had matched
on a Google SafeBrowsing GDB rule. Looking into the unit tests, it
looks like the code had always assumed that the test cases would be
detected by a malware test rule in unit_tests/input/daily.gdb, but
now some of the tests get matched on the phishing test rule.
I updated the test logic to be more clear, and added tests for both
cases now.

Fix some memory leaks in libclamav/scanners.c
2020-07-15 08:39:32 -07:00
Micah Snyder (micasnyd)
9c58ba7bd7 Update to clamav-devel to synchronize with the clamav-bytecode-compiler project. 2019-10-02 16:08:24 -04:00
Török Edvin
d5f7afdded testcase for cl_scan APIs
(partially ported from fmapify branch)
2011-06-15 12:22:27 +03:00
Török Edvin
1ab57a63c7 Add bytecode.cvd load test. 2010-05-14 17:19:26 +03:00
Török Edvin
7c394b5a9d Update these tests. 2010-05-14 11:19:09 +03:00
Török Edvin
8a06c645ad Fix unit test. 2010-05-14 11:04:04 +03:00
Török Edvin
3d2808c218 bytecode: update unit tests for improved arithmetic test. 2010-05-14 10:41:50 +03:00
Török Edvin
fc01c6476f Fix interpreter. 2010-05-13 23:25:11 +03:00
Török Edvin
a969167b6c Add new bytecode API unit tests. 2010-05-13 22:44:29 +03:00
Török Edvin
08d7e5f07d Restore the previous cbc testfiles. 2010-05-12 23:56:12 +03:00
Török Edvin
7a7365efe9 0.96.1 new APIs (cli_map etc.) 2010-05-12 23:51:20 +03:00
Török Edvin
d772904022 Fix matchwithread.cbc
ImageBase is little-endian, need to use conversion
function to access it.
2010-04-02 13:13:17 +03:00
Török Edvin
1bef6a803d Update pdf.cbc. 2010-03-30 00:04:38 +03:00
Török Edvin
1678ef9e43 Fix inflate.cbc for the interpreter. 2010-03-29 11:38:52 +03:00
Török Edvin
e439954b51 Fix valgrind warnings. 2010-03-24 17:37:23 +02:00
Török Edvin
778df8c22f Fix more leaks. 2010-03-24 17:08:20 +02:00
Török Edvin
6ea339aeab Fix bswap. 2010-03-24 15:27:15 +02:00
Török Edvin
48fc8b9852 Leak testcase. 2010-03-24 14:14:33 +02:00
Török Edvin
b26d43809a Add matchwithread.cbc to unit tests. 2010-03-24 12:46:34 +02:00
Török Edvin
b63681a52b Introduce BytecodeTimeout. 2010-03-22 17:16:07 +02:00
Török Edvin
353dafc9c4 Update unit tests. 2010-03-22 11:18:28 +02:00
Török Edvin
b56bea54d3 New API for buffer fill. 2010-03-22 11:18:28 +02:00
Török Edvin
1e30496d2a runtime checks verifier. 2010-02-15 17:32:41 +02:00
Török Edvin
0eb864b461 update unit tests. 2010-02-15 17:32:41 +02:00
Török Edvin
236fb13647 New pointer handling rules. 2010-02-15 17:32:40 +02:00
Török Edvin
2d45ef0616 Support for malloc in bytecode. Fix crash with mismatched api/flevel versions. 2010-01-20 20:04:01 +02:00
Török Edvin
9463f9fd90 Stack protector support. 2009-12-18 14:17:50 +02:00
Török Edvin
688799d126 yc_bytecode is able to unpack a file now! 2009-12-17 17:40:35 +02:00
Török Edvin
482e97dbb2 Support for bytecode lines >8k.
Size is specified on first line (which must be <8k).
2009-12-11 16:05:38 +02:00
Török Edvin
284ffd21f2 Add support for null constant. 2009-12-09 15:15:35 +02:00
Török Edvin
65c740d7d8 Add support for tracing (if bytecode compiled with support).
TODO: global id 0 is now a null pointer, need to adjust rest of conversion code
accordingly.
2009-12-08 23:02:49 +02:00
Török Edvin
aee2f72436 Fix compiler version check for C++: autoconf needs [] to be escaped.
Also sync unit tests with compiler.
2009-12-07 19:10:51 +02:00
Török Edvin
3ae0a76d03 Support for scanning files created by bytecode. 2009-12-02 17:30:17 +02:00
Török Edvin
322a0ea653 Fix bytecode load bugs. Make loading more robust: print error message instead of
crashing.
Able to load and dry-run yc_bytecode.o1.cbc now.
2009-11-26 17:29:59 +02:00
Török Edvin
b8656613c0 Doxygenize API headers. 2009-11-26 17:29:58 +02:00
Török Edvin
250d92c533 Sync with compiler. 2009-11-06 16:34:46 +02:00
Török Edvin
f564b09e9a More WiP. 2009-10-06 17:43:58 +03:00
Török Edvin
ec41017bba WiP 2009-10-06 17:32:38 +03:00
Török Edvin
88815fd801 Sync with compiler. 2009-09-30 13:41:02 +03:00
Török Edvin
d38d6dadef Logical signature hook for bytecode. 2009-09-22 11:04:33 +03:00
Török Edvin
dcee45cce2 Update to latest bytecode format. 2009-09-21 18:48:43 +03:00
Török Edvin
1a486dca3b Add hidden ctx param to APIcalls. 2009-09-04 12:09:17 +03:00
Török Edvin
e6d1fe78ea Apicall0 suppport for JIT. 2009-09-02 18:53:29 +03:00
Török Edvin
479fa7135c Fix type checking. 2009-09-02 17:44:18 +03:00
Török Edvin
6b67ec6ee7 Handle runtime errors with setjmp/longjmp, using a thread-local jmpbuf to make
it threadsafe.
2009-08-28 13:26:33 +03:00
Török Edvin
3b33bd6830 Minimal LLVM codegen. 2009-08-27 18:12:39 +03:00