Commit graph

19 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
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
Török Edvin
32f7e1d77b fmapfiy screnc 2011-06-13 12:03:26 +03:00
Török Edvin
d659015bb6 Unit-tests need to call cl_init, otherwise mkdir can fail randomly. 2009-10-26 19:01:56 +02:00
Török Edvin
5e5aa2f240 Fix tests. 2009-10-10 09:46:39 +03:00
aCaB
49cc1e3c35 s/struct F_MAP/fmap_t/ 2009-10-02 18:09:31 +02:00
aCaB
084d19aa8c (some) html to fmap 2009-08-31 06:16:12 +02:00
Török Edvin
e53ef4464b Fix unit-test failure on Solaris. 2009-07-31 15:30:47 +03:00
Török Edvin
08402afa4c fix more compiler warnings (bb #273)
git-svn: trunk@4353
2008-11-07 18:49:47 +00:00
Török Edvin
563582a1ec fix unit tests when mpool is activated
git-svn: trunk@4323
2008-11-03 19:26:57 +00:00
Török Edvin
d9282b9765 properly null-terminate buffer (bb #1223)
git-svn: trunk@4252
2008-10-11 13:56:29 +00:00
Török Edvin
6a53bbdf9a JS normalizer fixes (bb #1155)
git-svn: trunk@4202
2008-09-23 20:52:27 +00:00
Török Edvin
1279faf61e add htmlnorm unit tests and fix jsnorm space normalization
git-svn: trunk@4201
2008-09-23 20:52:22 +00:00