Commit graph

55 commits

Author SHA1 Message Date
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
e01ba94e36 bb12506: Fix phishing/heuristic alert verbosity
Some detections, like phishing, are considered heuristic alerts because
they match based on behavior more than on content.  A subset of these
are considered "potentially unwanted" (low-severity).  These
low-severity alerts include:
- phishing
- PDFs with obfuscated object names
- bytecode signature alerts that start with "BC.Heuristics"

The concept is that unless you enable "heuristic precedence" (a method
of lowing the threshold to immediateley alert on low-severity
detections), the scan should continue after a match in case a higher
severity match is found.  Only at the end will it print the low-severity
match if nothing else was found.

The current implementation is buggy though. Scanning of archives does
not correctly bail out for the entire archive if one email contains a
phishing link.  Instead, it sets the "heuristic found"  flag then and
alerts for every subsequent file in the archive because it doesn't know
if the heuristic was found in an embedded file or the target file.
Because it's just a heuristic and the status is "clean", it keeps
scanning.

This patch corrects the behavior by checking if a low-severity alerts
were found at the end of scanning the target file, instead of at the end
of each embedded file.

Additionally, this patch fixes an in issue with phishing alerts wherein
heuristic precedence mode did not cause a scan to stop after the first
alert.

The above changes required restructuring to create an fmap inside of
cl_scandesc_callback() so that scan_common() could be modified to
require an fmap and set up so that the current *ctx->fmap pointer is
never NULL when scan_common() evaluates match results.

Also fixed a couple minor bugs in the phishing unit tests and cleaned up
the test code for improved legitibility and type safety.
2020-06-03 17:20:35 -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
53e3045bf4 Return code checking corrections to regex suffix code. 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
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
Steven Morgan
cbf5017a7d bb11805 fix multiple results. Refactor false positive and heuristic precedence logic. 2017-04-18 12:07:06 -04:00
Steven Morgan
1f1bf36b8e Add 'virus found' callback. Refactor scan-all API. 2015-10-01 17:47:37 -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
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
e7dfb05678 Fix valgrind tests.
Need to parse the correct valgrind.log when running multiple tests in parallel.
2010-09-28 13:46:33 +03:00
aCaB
ed89689350 Revert "Revert "fix make check""
This reverts commit 776c201952.
2010-08-13 00:54:07 +02:00
aCaB
776c201952 Revert "fix make check"
This reverts commit b4d33ebcf7.
2010-08-11 14:21:47 +02:00
aCaB
b4d33ebcf7 fix make check 2010-08-11 12:44:14 +02:00
Török Edvin
7da37b9648 Don't phishcheck email addresses (bb #2067).
To avoid false positives.
2010-07-26 13:16:51 +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
5b74e89a35 enable prefiltering, and add to dconf.
Also downgrade some warnings to debug messages.
2010-02-15 17:32:41 +02:00
Török Edvin
2bc065d467 add support for (?i). Now regular expressions that begin with (?i) will be case
insensitive. (bb #1584, #1598).

git-svn: trunk@5067
2009-05-15 11:53:22 +00:00
Török Edvin
a3d029b938 make use of hostkey prefix entries
git-svn: trunk@4929
2009-03-11 20:06:35 +00:00
Török Edvin
9f11978c28 add more ifdefs for old check version.
git-svn: trunk@4924
2009-03-10 18:53:38 +00:00
Török Edvin
31ea989c4c fix unit-test
git-svn: trunk@4914
2009-03-09 11:23:12 +00:00
Török Edvin
4b52f390e5 fix make check. Buildbot didn't detect compile failure in make check.
git-svn: trunk@4902
2009-03-06 09:09:06 +00:00
Török Edvin
d4e1cb474f fix match with root regex (bb #1421).
git-svn: trunk@4848
2009-02-23 12:35:45 +00:00
Török Edvin
a1c9ad2cf3 fix distcheck.
git-svn: trunk@4836
2009-02-19 08:50:04 +00:00
Török Edvin
7e32c99e10 improve URL handling
git-svn: trunk@4831
2009-02-18 20:27:25 +00:00
Török Edvin
4e46d65d39 use sha256 instead of md5 in phishcheck.
move sha256 to libclamav.
add more tests.

git-svn: trunk@4822
2009-02-18 14:54:16 +00:00
Tomasz Kojm
47d40feb7a libclamav: use LibTomMath by Tom St Denis instead of libgmp for multiple precision integer arithmetic (bb#1366)
git-svn: trunk@4650
2009-01-26 19:47:02 +00:00
Tomasz Kojm
b8fe70b3a3 libclamav: drop options parameter in cl_engine_new(); replace cl_engine_dup() with cl_engine_addref()
git-svn: trunk@4398
2008-11-13 15:55:35 +00:00
Tomasz Kojm
55cd3168fa s/CL_DB_STDOPT/CL_ENGINE_DEFAULT
git-svn: trunk@4388
2008-11-12 18:07:04 +00:00
Török Edvin
15adbc849a update unit tests to new API.
Initialization order changed, make sure stats_tls_key is initialized.

git-svn: trunk@4387
2008-11-12 18:02:33 +00: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
7866b37c6b mpool debugging
s/USE_MEMPOOL/USE_MPOOL/

git-svn: trunk@4329
2008-11-04 10:40:24 +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
d5d06eccaa support building with older versions of check
git-svn: trunk@4289
2008-10-22 17:27:44 +00:00
Török Edvin
dc36f0d70c strip spaces from URL before checking that it is a URL
git-svn: trunk@4215
2008-10-01 09:56:54 +00:00
Török Edvin
7d4b5f164a use clistrdup/free instead of blobs (bb #828)
git-svn: trunk@4203
2008-09-23 20:52:33 +00:00
Török Edvin
3baee5029c convert a checked fixture into an unchecked fixture,
it is sufficient if that setup code is run once, this speeds up the tests.
fix some helgrind warnings
(the phishcheck struct is going to be freed anyway, so writing
something to it doesn't help anyway)

git-svn: trunk@4180
2008-09-16 10:32:20 +00:00
Török Edvin
15d67313c4 allow 'make check' to work even if check is not installed
by skipping checks that require it. (bb #1157)
if configure is not able to find check, you can use
--with-libcheck-prefix, instead of CHECK_CFLAGS and
CHECK_LIBS.
remove accidental AC_DEFINE GETHOSTBYNAME_R_6 from last commit.

git-svn: trunk@4172
2008-09-11 11:02:12 +00:00
aCaB
61b295f494 spam if lcheck is too old
git-svn: trunk@4121
2008-08-20 12:55:42 +00:00
aCaB
99f74adcc1 check for check
git-svn: trunk@4098
2008-08-10 16:19:01 +00:00
Török Edvin
dfc0c031cb if there is a version.h.static use that instead of output from svnversion
Makefile portability fixes
fix assert failure
add lcov to top level makefile
cleanup after lcov when you run make clean (bb #1112)
fix parsing of [^.] character class
fix parsing of [r-t]
fix handling of @ for URL hashes
fix handling of &# inside URLs
drop some dead code
more unit tests for str
portability fixes

git-svn: trunk@4078
2008-08-04 12:44:16 +00:00
Török Edvin
e6f14011ef fix crash in SO_search when len == 1
also skip matching too short strings (they won't match anyway)

git-svn: trunk@4067
2008-08-03 14:09:35 +00:00
Török Edvin
1126559f77 flag for U: lines, format is one of:
U:MD5
U1:MD5
U2:MD5

add unit test for md5 url match

git-svn: trunk@4053
2008-08-01 14:50:22 +00:00
Török Edvin
2b9e5d2971 drop a redundant check from phishcheck.
enable debug output in unit tests, they are dumped to
unit_tests/test-stderr.log.


git-svn: trunk@4028
2008-07-29 17:19:07 +00:00
Török Edvin
888973ccc9 more tests
git-svn: trunk@4026
2008-07-29 16:45:21 +00:00
Török Edvin
a2d14e06b9 add more unit-tests
fix matching bugs in regex_list


git-svn: trunk@4020
2008-07-29 15:37:23 +00:00