Commit graph

35 commits

Author SHA1 Message Date
Micah Snyder
9b9999d778 Rename core scanning functions
Many of the core scanning functions' names no longer represent their
specific purpose or arguments. This commit aims to make the names more
intuitive. Names are now prefixed with "magic" if they involve
file-typing and file-type parsing. In addition, each function now
includes the type of input being scanned whether its "desc", "fmap", or
"buff". Some of the APIs also now specify "type" to indicate that a type
other than "ANY" may be passed in to select the type rather than use
file type magic for type recognition.

| current name              | new name                          |
| ------------------------- | --------------------------------- |
| magic_scandesc()          | cli_magic_scan()                  |
| cli_magic_scandesc_type() | <delete>                          |
| cli_magic_scandesc()      | cli_magic_scan_desc()             |
| cli_base_scandesc()       | cli_magic_scan_desc_type()        |
| cli_partition_scandesc()  | <delete>                          |
| cli_map_scandesc()        | magic_scan_nested_fmap_type()     |
| cli_map_scan()            | cli_magic_scan_nested_fmap_type() |
| cli_mem_scandesc()        | cli_magic_scan_buff()             |
| cli_scanbuff()            | cli_scan_buff()                   |
| cli_scandesc()            | cli_scan_desc()                   |
| cli_fmap_scandesc()       | cli_scan_fmap()                   |
| cli_scanfile()            | cli_magic_scan_file()             |
| cli_scandir()             | cli_magic_scan_dir()              |
| cli_filetype2()           | cli_determine_fmap_type()         |
| cli_filetype()            | cli_compare_ftm_file()            |
| cli_partitiontype()       | cli_compare_ftm_partition()       |
| cli_scanraw()             | scanraw()                         |
2020-06-03 11:00:40 -04:00
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
206dbaefe8 Update copyright dates for 2020 2020-01-03 15:44:07 -05:00
Micah Snyder
4524c398f3 Argument and return types for fmap_readn(), cli_writen(), cli_readn() converted to use size_t instead of int. 2019-10-02 16:08:25 -04:00
Micah Snyder
52cddcbcfd Updating and cleaning up copyright notices. 2019-10-02 16:08:18 -04:00
Micah Snyder
b3e82e5e61 Replacing libclamav/cltypes.h with clamav-types.h.in, which generates a header clamav-types.h that we install alongside clamav.h. 2019-10-02 16:08:17 -04:00
Micah Snyder
72fd33c8b2 clang-format'd using new .clang-format rules. 2019-10-02 16:08:16 -04:00
Micah Snyder
d39cb6581f Updating libclamunrar from legacy C implementation to modern unrar 5.6.5. API changes and supporting changes included to pass the filepath of the scanned file into libclamav through the cli_ctx structure, required by the unrar library to open archives. The filename argument may be optional for the scandesc scanning variant, but libclamav will make a best effort to identify the filename from the file descriptor if it was not provided. In addition, included the ability to prefix temp file and directory names with file basenames. 2018-12-02 23:06:59 -05:00
Steven Morgan
1f85811128 bb11452 - endianess correction for swf files on sparc - patch supplied by Jim Morris. 2015-12-11 19:55:16 -05:00
Mickey Sola
46a35abe56 mass update of copyright headers 2015-09-17 13:41:26 -04:00
Kevin Lin
2f9c1bd25d cid 12148 - fix printf type mismatch in msxml parsing debug 2015-08-19 11:14:52 -04:00
Kevin Lin
015d05bd89 cid 12154 - fix error state for reading LZMA compressed flash 2015-08-19 11:14:51 -04:00
Kevin Lin
7c05ec73ee SWF: tabs => spaces (whitespace changes only) 2015-05-01 15:47:13 -04:00
Kevin Lin
207cf18e39 bb#11306 - fixes for LZMA decompression in flash files 2015-05-01 15:23:07 -04:00
Kevin Lin
d3530d45ce bb#11306 - LZMA decompression support for flash files 2015-04-28 17:28:23 -04:00
Shawn Webb
cf3138e1d2 bb11160 - Plug a few memory leaks 2014-11-04 18:38:34 -05:00
Shawn Webb
126fd1ee8d bb#11072: In case of SWF decompression error, scan data if any data was decompressed. 2014-08-19 13:16:42 -04:00
Shawn Webb
cd94be7a52 Silence a bunch of compiler warnings in libclamav 2014-07-10 18:11:49 -04:00
Shawn Webb
60d8d2c352 Move all the crypto API to clamav.h 2014-07-01 19:38:01 -04:00
David Raynor
d260468a97 swf: limit tag walk to debug mode 2014-05-23 11:54:02 -04:00
David Raynor
f98726bd8c swf: fix bb #10087, FrameSize handling for larger frames 2014-05-23 11:45:49 -04:00
Shawn Webb
b2e7c931d0 Use OpenSSL for hashing. 2014-02-08 00:31:12 -05:00
David Raynor
9354e51399 swf: log message down-leveling 2013-12-24 11:50:25 -05:00
David Raynor
60e36cd653 bb #6712: safer SWF tag length handling 2013-02-04 16:32:50 -05:00
David Raynor
4db9cda58a bb #5324: strip down Flash file handling, decompress compressed Flash files 2013-01-15 15:42:31 -05: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
87f763991b Introduce cli_map_scandesc to scan a portion of the existing file
And switch CPIO, MACHO, and SWF to use it.

Now they no longer need to dump a tempfile and remap.
To investigate if it is possible to do this with TAR.
2011-06-17 23:08:47 +03:00
Tomasz Kojm
7362a9cfa4 respect AlgorithmicDetection 2011-04-18 19:06:43 +02:00
Tomasz Kojm
db2138d857 swf: error handling 2011-04-15 12:39:45 +02:00
Tomasz Kojm
094f8555db fix virus names 2011-04-06 15:57:00 +02:00
Tomasz Kojm
1fb9e80cfe do more checks 2011-04-06 15:53:28 +02:00
Tomasz Kojm
b44fb658ba libclamav: add basic JPEG validator 2011-04-05 16:33:38 +02:00
Tomasz Kojm
8df46b3231 scan metadata 2011-03-31 19:08:23 +02:00
Tomasz Kojm
35b242b95d libclamav/swf.c: scan images and binary blobs 2011-03-30 16:02:41 +02:00
Tomasz Kojm
44a3e21aae libclamav: add skeleton code for SWF parser
libclamav/others.h: bump f-level
2011-03-28 20:25:40 +02:00