Commit graph

62 commits

Author SHA1 Message Date
Micah Snyder
005cbf5a37 Record names of extracted files
A way is needed to record scanned file names for two purposes:

1. File names (and extensions) must be stored in the json metadata
properties recorded when using the --gen-json clamscan option. Future
work may use this to compare file extensions with detected file types.

2. File names are useful when interpretting tmp directory output when
using the --leave-temps option.

This commit enables file name retention for later use by storing file
names in the fmap header structure, if a file name exists.

To store the names in fmaps, an optional name argument has been added to
any internal scan API's that create fmaps and every call to these APIs
has been modified to pass a file name or NULL if a file name is not
required.  The zip and gpt parsers required some modification to record
file names.  The NSIS and XAR parsers fail to collect file names at all
and will require future work to support file name extraction.

Also:

- Added recursive extraction to the tmp directory when the
  --leave-temps option is enabled.  When not enabled, the tmp directory
  structure remains flat so as to prevent the likelihood of exceeding
  MAX_PATH.  The current tmp directory is stored in the scan context.

- Made the cli_scanfile() internal API non-static and added it to
  scanners.h so it would be accessible outside of scanners.c in order to
  remove code duplication within libmspack.c.

- Added function comments to scanners.h and matcher.h

- Converted a TDB-type macros and LSIG-type macros to enums for improved
  type safey.

- Converted more return status variables from `int` to `cl_error_t` for
  improved type safety, and corrected ooxml file typing functions so
  they use `cli_file_t` exclusively rather than mixing types with
  `cl_error_t`.

- Restructured the magic_scandesc() function to use goto's for error
  handling and removed the early_ret_from_magicscan() macro and
  magic_scandesc_cleanup() function.  This makes the code easier to
  read and made it easier to add the recursive tmp directory cleanup to
  magic_scandesc().

- Corrected zip, egg, rar filename extraction issues.

- Removed use of extra sub-directory layer for zip, egg, and rar file
  extraction.  For Zip, this also involved changing the extracted
  filenames to be randomly generated rather than using the "zip.###"
  file name scheme.
2020-06-03 10:39:18 -04:00
Micah Snyder (micasnyd)
485d8dec67 Check test support for check 0.13
Tests in libcheck 0.13 must have {} between START_TEST and END_TEST
else it will not compile.

Also replaced all deprecated "fail_" macros with "ck_" macros.
E.g. fail_unless() becomes ck_assert_msg()

The checks_common.h header file provided a couple of macros to
support versions older than 0.9.3.  As these older versions are
no longer relevant, I've removed those compatibility macros
entirely.
2020-01-15 08:14:23 -08:00
Micah Snyder
206dbaefe8 Update copyright dates for 2020 2020-01-03 15:44:07 -05:00
Micah Snyder
52cddcbcfd Updating and cleaning up copyright notices. 2019-10-02 16:08:18 -04:00
Micah Snyder
72fd33c8b2 clang-format'd using new .clang-format rules. 2019-10-02 16:08:16 -04:00
Micah Snyder
d7979d4ff7 Restructured scan options flags from a single bitflag field to a structure containing multiple bitflag fields. This also required adding a new function to the bytecode API to get scan options a la carte, and modifying the existing function to hand back scan options in the old/deprecated uint32_t bitflag format. Re-generated bytecode iface header files.
Updated libclamav documentation detailing new scan options structure.
Renamed references to 'algorithmic' detection to 'heuristic' detection. Renaming references to 'properties' to 'collect metadata'.
Renamed references to 'scan all' to 'scan all match'.
Renamed a couple of 'Hueristic.*' signature names as 'Heuristics.*' signatures (plural) to match majority of other heuristics.
2018-12-02 23:06:59 -05:00
Mickey Sola
46a35abe56 mass update of copyright headers 2015-09-17 13:41:26 -04:00
Shawn Webb
60d8d2c352 Move all the crypto API to clamav.h 2014-07-01 19:38:01 -04:00
Shawn Webb
b2e7c931d0 Use OpenSSL for hashing. 2014-02-08 00:31:12 -05:00
Steve Morgan
54402320c0 Add bytecode performance statistics 2012-12-05 15:48:52 -08:00
Steve Morgan
03b99d0311 fix compiler warning 2012-10-19 09:39:06 -07:00
Steve Morgan
6ad45a2931 add initial allscan/allmatch mode to libclamav, clamd, clamdscan, and clamscan with unit tests 2012-10-18 14:12:58 -07:00
Török Edvin
62ee12b2f8 unit tests for new fmap scan API 2011-06-14 22:35:03 +03:00
Török Edvin
5007986ffd Fix build on Etch (bb #2399). 2011-01-20 10:03:55 +02:00
Török Edvin
73489b8b4c s/glibc 2.2/glibc 2.3/ for pthread_barrier. 2010-11-23 16:38:15 +02:00
Török Edvin
314c415b02 Restrict usage of pthread_barrier even more.
Don't want to add a configure test for it now...
2010-11-23 13:31:47 +02:00
Török Edvin
e3a9786792 Only use pthread_barrier* on Linux.
Looks like Solaris and Mac OS X didn't hear of barriers :(
2010-11-04 23:01:22 +02:00
Török Edvin
71a5cb434e Fix build error. 2010-11-04 22:13:35 +02:00
Török Edvin
a7cf187a0c Make cl_load thread safe (bb #2333).
Parallel cl_load() crash (bb #2333).
Reason is twofold:
 - cache.c had 2 'static' global variables, thus trying to initialize same cache
 from multiple threads
  - bytecode2llvm.cpp: something in LLVM 2.7 is crashing when loading in
  parallel

Fix is to drop the 'static' on the variable (cache is per engine already).
This also fixes a potential memory leak in clamd!

The other part of the fix is to turn on the mutex around bytecode compilation
always. We don't call cl_load in parallel, so this doesn't affect clamd, but
some may need to call cl_load in parallel.
2010-11-04 21:53:03 +02:00
Török Edvin
47cee5042d fix unit test for JIT test mode. 2010-10-18 11:08:14 +03:00
Török Edvin
540fc128a0 freshclam is using private symbol that changed proto (bb #2187).
Change name to prevent crash with 0.96.1 freshclam and 0.96.2 libclamav.
You'll get a missing symbol error.
2010-08-11 14:26:10 +03:00
Török Edvin
213dfdff06 run 1 unit-test at least in test mode (bb #2151).
Also allow running test mode if JIT is not available, still checking
for failed startup.cbc execution.
2010-08-02 19:00:12 +03:00
Török Edvin
d049a2f72b Make bytecode tests use testmode if they want.
None uses it yet.
2010-07-29 14:07:00 +03:00
Török Edvin
927d054838 Add engine param to bytecode, and remove dconf from _init. 2010-07-29 13:48:18 +03:00
Török Edvin
1ab57a63c7 Add bytecode.cvd load test. 2010-05-14 17:19:26 +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
aadccfd1c8 Fix valgrind warnings. 2010-05-13 23:35:47 +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
e4a0f2c94f fix compiler warnings (bb #1872, bb #1934, bb #1935) 2010-04-13 16:19:47 +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
e407d32d04 Increase timeout of testcase itself. 2010-03-30 11:10:58 +03:00
Török Edvin
ce288463e2 Increase bytecode timeout for non-timeout tests. 2010-03-30 00:04:38 +03:00
Török Edvin
fa82ce037a Separate bytecode tests into jit and interpreter.
This makes it easier to see which one has a problem, and also reduces the
runtime of individual tests.
2010-03-29 12:09:07 +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
0d9b99f43e Fix bswap.cbc in interpreter mode. 2010-03-28 23:49:25 +03:00
Török Edvin
041bc64aab Increase timeout in unit test (bb #1899). 2010-03-26 16:50:30 +02: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
74f5816c58 Interpreter fixes for accessing 'ctx'.
This allow all cbcs in unit_tests/input to pass.
Not yet working on bytecode.cvd though.
2010-03-23 21:47:57 +02:00
Török Edvin
bdd9aeaeeb Use a watchdog thread. Also make timeout be ms instead of us. 2010-03-23 16:33:41 +02:00
Török Edvin
b63681a52b Introduce BytecodeTimeout. 2010-03-22 17:16:07 +02:00
Török Edvin
c42033313a disable this test for now. 2010-03-22 12:49:16 +02:00
Török Edvin
6eeadbfeda dconf for bytecode. 2010-02-15 17:32:41 +02:00
Török Edvin
c0afc51729 Don't use C++ comments in C code. 2010-01-27 12:07:08 +02:00
Tomasz Kojm
de351ee1bc libclamav: handle digitally signed .info files 2010-01-25 13:28:19 +01:00
Török Edvin
ed4a336e2c More build fixes. 2009-12-11 21:44:22 +02:00