Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scripts/virus-scan
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ LocalSocket ${runtime_dir}/clamd.sock
FixStaleSocket yes
DatabaseDirectory ${database_dir}
Foreground yes
LogClean yes
PidFile ${runtime_dir}/clamd.pid
ExcludePath (^|/)\.composer-cache(/|$)
ExcludePath (^|/)node_modules_cache(/|$)
Expand Down Expand Up @@ -108,7 +109,7 @@ scanned_files="$(
awk '
/: OK$/ || / FOUND$/ { count++ }
END { print count + 0 }
' "${scan_report}"
' "${clamd_log}"
)"

awk -v scanned_files="${scanned_files}" '
Expand Down
23 changes: 20 additions & 3 deletions tests/test-virus-scan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,24 @@ done

cp "${config_file}" "${TEST_STATE}/clamd.conf"
printf '%s\n' "$$" > "${TEST_STATE}/clamd.pid"

case "${FAKE_SCAN_EXIT:-0}" in
0)
printf '%s\n' \
"${TEST_STATE}/work/clean-one.php: OK" \
"${TEST_STATE}/work/clean-two.php: OK"
;;
1)
printf '%s\n' \
"${TEST_STATE}/work/clean.php: OK" \
"${TEST_STATE}/work/infected.php: Eicar-Test-Signature FOUND"
;;
2)
printf '%s\n' \
"${TEST_STATE}/work/unreadable.php: Permission denied. ERROR"
;;
esac

trap 'touch "${TEST_STATE}/clamd.stopped"; exit 0' TERM INT
while :; do
sleep 0.05
Expand All @@ -106,16 +124,14 @@ done
case "${FAKE_SCAN_EXIT:-0}" in
0)
printf '%s\n' \
"${TEST_STATE}/work/clean-one.php: OK" \
"${TEST_STATE}/work/clean-two.php: OK" \
"${TEST_STATE}/work: OK" \
'' \
'----------- SCAN SUMMARY -----------' \
'Infected files: 0' \
'Time: 0.010 sec (0 m 0 s)'
;;
1)
printf '%s\n' \
"${TEST_STATE}/work/clean.php: OK" \
"${TEST_STATE}/work/infected.php: Eicar-Test-Signature FOUND" \
'' \
'----------- SCAN SUMMARY -----------' \
Expand Down Expand Up @@ -180,6 +196,7 @@ run_scan_case() {
run_scan_case clean 0 success 0
assert_file_contains "${TEST_DIR}/clean/clamdscan.calls" '--multiscan' 'clean scan requests multiscan'
assert_file_not_contains "${TEST_DIR}/clean/clamdscan.calls" '--infected' 'clean scan captures clean results for counting'
assert_file_contains "${TEST_DIR}/clean/clamd.conf" '^LogClean yes$' 'clean file results are enabled in the private daemon log'
assert_file_contains "${TEST_DIR}/clean/clamd.conf" 'ExcludePath .*\\.composer-cache' 'composer cache exclusion is configured for clamd'
assert_file_contains "${TEST_DIR}/clean/clamd.conf" 'ExcludePath .*node_modules_cache' 'node modules cache exclusion is configured for clamd'
assert_file_contains "${TEST_DIR}/clean/output" 'Scanned files: 2' 'clean scan reports the scanned file count'
Expand Down
Loading