Cisco-Talos / clamav

ClamAV - Documentation is here: https://docs.clamav.net

Home Page:https://www.clamav.net/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

clamav 1.3.1 seven tests fail

Elielsilverio opened this issue · comments

I download and build clamav 1.3.1 with success, but on run ctest, failed

/postfix/clamav-1.3.1/build # ctest
Test project /postfix/clamav-1.3.1/build
Start 1: libclamav
1/11 Test #1: libclamav ........................***Failed 13.73 sec
Start 2: libclamav_valgrind
2/11 Test #2: libclamav_valgrind ...............***Failed 160.04 sec
Start 3: libclamav_rust
3/11 Test #3: libclamav_rust ................... Passed 10.24 sec
Start 4: clamscan
4/11 Test #4: clamscan .........................***Failed 11.04 sec
Start 5: clamscan_valgrind
5/11 Test #5: clamscan_valgrind ................***Failed 339.20 sec
Start 6: clamd
6/11 Test #6: clamd ............................***Failed 26.24 sec
Start 7: clamd_valgrind
7/11 Test #7: clamd_valgrind ...................***Failed 93.12 sec
Start 8: freshclam
8/11 Test #8: freshclam ........................ Passed 2.50 sec
Start 9: freshclam_valgrind
9/11 Test #9: freshclam_valgrind ...............***Failed 61.37 sec
Start 10: sigtool
10/11 Test #10: sigtool .......................... Passed 1.06 sec
Start 11: sigtool_valgrind
11/11 Test #11: sigtool_valgrind ................. Passed 30.54 sec

36% tests passed, 7 tests failed out of 11

Total Test time (real) = 749.09 sec

The following tests FAILED:
1 - libclamav (Failed)
2 - libclamav_valgrind (Failed)
4 - clamscan (Failed)
5 - clamscan_valgrind (Failed)
6 - clamd (Failed)
7 - clamd_valgrind (Failed)
9 - freshclam_valgrind (Failed)
Errors while running CTest
Output from these tests are in: /postfix/clamav-1.3.1/build/Testing/Temporary/LastTest.log
Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.

/postfix/clamav-1.3.1/unit_tests/libclamav_test.py:47: AssertionError
----------------------------- Captured stdout call -----------------------------

INFO: libclamav unit tests
INFO: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[DEBUG]: Run command: /postfix/clamav-1.3.1/build/unit_tests/check_clamav
[DEBUG]: Exit code: 1
[DEBUG]: stdout: Using default test timeout; alter by setting 'T' env var (in seconds)
Running suite(s): cl_suite
cli
jsnorm
str
regex
disasm
unique
matchers
htmlnorm
bytecode
98%: Checks: 1221, Failures: 24, Errors: 0
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:216:F:cl_scan_api:test_cl_scandesc:13: cl_scandesc failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v3.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:216:F:cl_scan_api:test_cl_scandesc:30: cl_scandesc failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v2.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:243:F:cl_scan_api:test_cl_scandesc_allscan:13: cl_scandesc_allscan failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v3.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:243:F:cl_scan_api:test_cl_scandesc_allscan:30: cl_scandesc_allscan failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v2.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:271:F:cl_scan_api:test_cl_scanfile:13: cl_scanfile failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v3.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:271:F:cl_scan_api:test_cl_scanfile:30: cl_scanfile failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v2.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:298:F:cl_scan_api:test_cl_scanfile_allscan:13: cl_scanfile_allscan failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v3.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:298:F:cl_scan_api:test_cl_scanfile_allscan:30: cl_scanfile_allscan failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v2.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:379:F:cl_scan_api:test_cl_scandesc_callback:13: cl_scanfile failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v3.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:379:F:cl_scan_api:test_cl_scandesc_callback:30: cl_scanfile failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v2.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:407:F:cl_scan_api:test_cl_scandesc_callback_allscan:13: cl_scanfile_allscan failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v3.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:407:F:cl_scan_api:test_cl_scandesc_callback_allscan:30: cl_scanfile_allscan failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v2.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:325:F:cl_scan_api:test_cl_scanfile_callback:13: cl_scanfile_cb failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v3.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:325:F:cl_scan_api:test_cl_scanfile_callback:30: cl_scanfile_cb failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v2.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:353:F:cl_scan_api:test_cl_scanfile_callback_allscan:13: cl_scanfile_cb_allscan failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v3.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:353:F:cl_scan_api:test_cl_scanfile_callback_allscan:30: cl_scanfile_cb_allscan failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v2.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:676:F:cl_scan_api:test_cl_scanmap_callback_handle:13: cl_scanmap_callback failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v3.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:676:F:cl_scan_api:test_cl_scanmap_callback_handle:30: cl_scanmap_callback failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v2.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:708:F:cl_scan_api:test_cl_scanmap_callback_handle_allscan:13: cl_scanmap_callback allscan failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v3.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:708:F:cl_scan_api:test_cl_scanmap_callback_handle_allscan:30: cl_scanmap_callback allscan failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v2.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:745:F:cl_scan_api:test_cl_scanmap_callback_mem:13: cl_scanmap_callback failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v3.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:745:F:cl_scan_api:test_cl_scanmap_callback_mem:30: cl_scanmap_callback failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v2.rar: No viruses detected

Clamav 1.3.1 built from sources all tests passed successfully.

the Clamav 1.3.0 built from sources all tests passed successfully, but 1.3,1 failed

Can you post the commands used to build?
Did you change anything related to .rar support?

mkdir build
cd build
cmake ..
-D CMAKE_INSTALL_PREFIX=/usr
-D CMAKE_INSTALL_LIBDIR=lib
-D APP_CONFIG_DIRECTORY=/etc/clamav
-D DATABASE_DIRECTORY=/var/lib/clamav
cmake --build .
ctest

We haven't changed anything RAR related in the 1.3.1 release.

I have a vague memory of tests failing in some situation with the same RAR support issue... but I don't recall the cause or solution. It... might be some sort of conflict between the version you're testing with an installed version of ClamAV... That shouldn't happen but... maybe?

Start testing: Apr 18 16:24 -03

1/11 Testing: libclamav
1/11 Test: libclamav
Command: "/root/.local/bin/pytest" "-v" "libclamav_test.py"
Directory: /postfix/clamav-1.3.1/unit_tests
"libclamav" start time: Apr 18 16:24 -03
Output:

============================= test session starts ==============================
platform linux -- Python 3.6.12, pytest-6.2.5, py-1.10.0, pluggy-1.0.0 -- /usr/bin/python3
cachedir: .pytest_cache
metadata: {'Python': '3.6.12', 'Platform': 'Linux-5.3.18-lp152.106-default-x86_64-with-glibc2.3.4', 'Packages': {'pytest': '6.2.5', 'py': '1.10.0', 'pluggy': '1.0.0'}, 'Plugins': {'datadir': '1.3.1', 'metadata': '1.8.0'}, 'JAVA_HOME': '/usr/lib64/jvm/jre-11-openjdk'}
rootdir: /postfix/clamav-1.3.1/unit_tests
plugins: datadir-1.3.1, metadata-1.8.0
collecting ... collected 1 item

libclamav_test.py::TC::test_libclamav_00_unit_test FAILED [100%]

=================================== FAILURES ===================================
________________________ TC.test_libclamav_00_unit_test ________________________

self = <libclamav_test.TC testMethod=test_libclamav_00_unit_test>

def test_libclamav_00_unit_test(self):
    self.step_name('libclamav unit tests')

    # If no valgrind, valgrind nad valgrind args are empty strings
    command = '{valgrind} {valgrind_args} {check_clamav}'.format(
        valgrind=TC.valgrind, valgrind_args=TC.valgrind_args, check_clamav=TC.check_clamav
    )
    output = self.execute_command(command)
  assert output.ec == 0  # success

E AssertionError: assert 1 == 0
E +1
E -0

/postfix/clamav-1.3.1/unit_tests/libclamav_test.py:47: AssertionError
----------------------------- Captured stdout call -----------------------------

INFO: libclamav unit tests
INFO: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[DEBUG]: Run command: /postfix/clamav-1.3.1/build/unit_tests/check_clamav
[DEBUG]: Exit code: 1
[DEBUG]: stdout: Using default test timeout; alter by setting 'T' env var (in seconds)
Running suite(s): cl_suite
cli
jsnorm
str
regex
disasm
unique
matchers
htmlnorm
bytecode
98%: Checks: 1221, Failures: 24, Errors: 0
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:216:F:cl_scan_api:test_cl_scandesc:13: cl_scandesc failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v3.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:216:F:cl_scan_api:test_cl_scandesc:30: cl_scandesc failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v2.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:243:F:cl_scan_api:test_cl_scandesc_allscan:13: cl_scandesc_allscan failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v3.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:243:F:cl_scan_api:test_cl_scandesc_allscan:30: cl_scandesc_allscan failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v2.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:271:F:cl_scan_api:test_cl_scanfile:13: cl_scanfile failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v3.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:271:F:cl_scan_api:test_cl_scanfile:30: cl_scanfile failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v2.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:298:F:cl_scan_api:test_cl_scanfile_allscan:13: cl_scanfile_allscan failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v3.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:298:F:cl_scan_api:test_cl_scanfile_allscan:30: cl_scanfile_allscan failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v2.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:379:F:cl_scan_api:test_cl_scandesc_callback:13: cl_scanfile failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v3.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:379:F:cl_scan_api:test_cl_scandesc_callback:30: cl_scanfile failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v2.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:407:F:cl_scan_api:test_cl_scandesc_callback_allscan:13: cl_scanfile_allscan failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v3.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:407:F:cl_scan_api:test_cl_scandesc_callback_allscan:30: cl_scanfile_allscan failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v2.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:325:F:cl_scan_api:test_cl_scanfile_callback:13: cl_scanfile_cb failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v3.rar: No viruses detected
/postfix/clamav-1.3.1/unit_tests/check_clamav.c:325:F:cl_scan_api:test_cl_scanfile_callback:30: cl_scanfile_cb failed for /postfix/clamav-1.3.1/build/unit_tests/input/clamav_hdb_scanfiles/clam-v2.rar: No viruses detected

I tested with your build commands:

mkdir build
cd build
cmake .. \
-D CMAKE_INSTALL_PREFIX=/usr \
-D CMAKE_INSTALL_LIBDIR=lib \
-D APP_CONFIG_DIRECTORY=/etc/clamav \
-D DATABASE_DIRECTORY=/var/lib/clamav
cmake --build .
ctest

but I had to add

-D ENABLE_MILTER=OFF

because I don't use milter (I have no experience with clamav-milter) and everything is OK.
Below is the result:

Test project /tmp/clamav-1.3.1/build
Start 1: libclamav
1/11 Test #1: libclamav ........................ Passed 17.94 sec
Start 2: libclamav_valgrind
2/11 Test #2: libclamav_valgrind ............... Passed 252.00 sec
Start 3: libclamav_rust
3/11 Test #3: libclamav_rust ................... Passed 24.44 sec
Start 4: clamscan
4/11 Test #4: clamscan ......................... Passed 0.31 sec
Start 5: clamscan_valgrind
5/11 Test #5: clamscan_valgrind ................ Passed 0.31 sec
Start 6: clamd
6/11 Test #6: clamd ............................ Passed 24.16 sec
Start 7: clamd_valgrind
7/11 Test #7: clamd_valgrind ................... Passed 130.63 sec
Start 8: freshclam
8/11 Test #8: freshclam ........................ Passed 41.77 sec
Start 9: freshclam_valgrind
9/11 Test #9: freshclam_valgrind ............... Passed 88.78 sec
Start 10: sigtool
10/11 Test #10: sigtool .......................... Passed 0.67 sec
Start 11: sigtool_valgrind
11/11 Test #11: sigtool_valgrind ................. Passed 26.13 sec
100% tests passed, 0 tests failed out of 11
Total Test time (real) = 607.16 sec

You could try building by adding this option to check if this is not where the problem occurs.

-D ENABLE_MILTER=OFF Failed

36% tests passed, 7 tests failed out of 11

Total Test time (real) = 800.85 sec

The following tests FAILED:
1 - libclamav (Failed)
2 - libclamav_valgrind (Failed)
4 - clamscan (Failed)
5 - clamscan_valgrind (Failed)
6 - clamd (Failed)
7 - clamd_valgrind (Failed)
9 - freshclam_valgrind (Failed)

It remains for next week, maybe we have to dig in the logs.

If you say that all the commands run until ctest are OK without error, @micahsnyder may be right in his post, there may be some kind of conflict between version 1.3.1 and the existing installed version 1.3.0. It shouldn't happen, but you can test the build on another system without any previously installed Clamav version.
I'm using the prefix install option:
-D CMAKE_INSTALL_PREFIX:PATH=/opt/clamav
and therefore I cannot reproduce your situation.
If the ctest fails in this case as well, then the result of the previous commands should be checked.

Try adding ENABLE_STATIC_LIB=ON and ENABLE_SHARED_LIB=OFF to build parameters...

commented

I tried adding ENABLE_STATIC_LIB=ON and ENABLE_SHARED_LIB=OFF to build parameters and it worked almost fine

/postfix/clamav-1.3.1/build
Start 1: libclamav
1/11 Test #1: libclamav ........................ Passed 14.25 sec
Start 2: libclamav_valgrind
2/11 Test #2: libclamav_valgrind ............... Passed 156.27 sec
Start 3: libclamav_rust
3/11 Test #3: libclamav_rust ................... Passed 10.85 sec
Start 4: clamscan
4/11 Test #4: clamscan ......................... Passed 11.46 sec
Start 5: clamscan_valgrind
5/11 Test #5: clamscan_valgrind ................ Passed 343.05 sec
Start 6: clamd
6/11 Test #6: clamd ............................ Passed 27.56 sec
Start 7: clamd_valgrind
7/11 Test #7: clamd_valgrind ...................***Failed 94.04 sec
Start 8: freshclam
8/11 Test #8: freshclam ........................ Passed 2.45 sec
Start 9: freshclam_valgrind
9/11 Test #9: freshclam_valgrind ...............***Failed 52.45 sec
Start 10: sigtool
10/11 Test #10: sigtool .......................... Passed 1.06 sec
Start 11: sigtool_valgrind
11/11 Test #11: sigtool_valgrind ................. Passed 25.62 sec

82% tests passed, 2 tests failed out of 11

Total Test time (real) = 739.07 sec

The following tests FAILED:
7 - clamd_valgrind (Failed)
9 - freshclam_valgrind (Failed)
Errors while running CTest
Output from these tests are in: /postfix/clamav-1.3.1/build/Testing/Temporary/LastTest.log
Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.

I have the same problem with failing some tests in Version 1.3.1. No problems in 1.3.0.

git bisect identifies commit 09c559a504adc11d67af735fa1ddba8eea93ed20 as the cause. It is the one line fix for CID 432801. If I remove this commit, all checks passes without problems.

Compiled and tested on Debian 11.9 using Rust 1.77.2.

cmake .. \
    -D CMAKE_INSTALL_PREFIX="$HOME/server" \
    -D CMAKE_INSTALL_SBINDIR="$HOME/server/bin" \
    -D ENABLE_CLAMONACC="OFF" \
    -D ENABLE_SYSTEMD="OFF" \
    -D ENABLE_MILTER="OFF"

If target install directory is empty, the checks passes. If there is version 1.3.0 installed already, they fail. This is a bit unexpected.

@heiko3 Nice work tracking it down.

It looks like we accidentally changed the ABI for libclamunrar_iface.so by modifying the size of the unrar metadata structure in libclamunrar_iface/unrar_iface.h
in 09c559a.

My guess is that the tests are failing because the libclamav initialization for the tests is trying to load the old libclamunrar_iface.so instead of the new one and that's causing problems.

I'm not sure what we can do about it other than say, "sorry, we will try to not do that again."

If you remove the old version, the tests should pass. Or else just go for the install and trust that it will work okay despite the failed tests right now.

If you remove the old version, the tests should pass.

This is where prefix install helps when building from sources.

Thank you for the explanation.

I installed despite the failed tests and then ran the tests again to make sure they went through. That gives a better feeling and it worked.

load the old libclamunrar_iface.so instead of the new one

I think this is the actual error and shouldn't happen. It ultimately means that the tests don't check the new version of the library at all. This should be fixed if possible.

Funny story... apparently I left a comment in our code describing this problem 4 years ago:

clamav/libclamav/others.c

Lines 200 to 202 in 2552cfd

* Known issue: If an older clamav version is already installed, the clamav
* unit tests using this function will load the older library version from
* the install path first.

Looking at it now, I would think that fixing this would be as simple as checking for libclamunrar_face in LD_LIBRARY_PATH before trying with SEARCH_LIBDIR. 🤔