Review of the scan-scope change (measured on ClamAV 1.4.6 in this image):
- clamscan exits 1, not 2, when one listed file is infected and another
cannot be read: only the summary says "Total errors: 1". A mode-000
webshell next to any detected file went unscanned and the run passed
(privd accepted the attestation, require_scan_scope=true included).
Now: a summary with Total errors > 0, or no summary at all, fails the run.
- Every hit line must name an EXACT entry of the scan list (the last ": "
ends the path; signature names never contain one); anything else fails
the run instead of being skipped.
- The list itself is checked before clamscan sees it: each entry a plain
absolute path below the extract, <= 1022 bytes, no control character,
and exactly files_scanned entries.
- A hit that cannot be moved to quarantine fails the run (it used to log a
WARN and leave the infected file in the tree to be imported). Duplicate
hits (a link target listed twice) are one action.
- Tests: names with ': ' + ' FOUND', leading '-', \n, \r, >= 1023 bytes;
rogue hit, Total errors, no summary, unquarantinable hit, list longer
than files_scanned, entry outside the extract (red on the old script);
image-scope-test.sh runs a mode-000 file next to EICAR end to end.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
- Dockerfile: multi-stage Go build of whp-scan-scope (CGO off, stdlib only) from a PINNED
commit of the WHP repo (ARG WHP_COMMIT, currently the merge of WHP #331; bump it to the merge
of the 2000 MiB limit PR before publishing an image meant to enforce it). Private repo: the
BuildKit secret whp_token in CI; --build-context whp-src=<checkout> for local builds.
- scan-files.php: whp-scan-scope -> /tmp/scan.list + stats, then clamscan --file-list with
--max-filesize=2000M --max-scansize=4000M --max-scantime=0 --alert-exceeds-max=yes --tempdir on
the disk scratch. A missing/failing tool, clamscan exit >= 2 or 0 loaded signatures is FATAL
(no fall back to an unscoped scan). Writes the attestation (the tool's stats + engine_version,
signature_db_version, signatures_loaded, clamscan_exit).
- entrypoint.sh: passes --attestation/--scratch, removes the scratch, embeds the attestation as
report.json "scan" (objects kept as objects).
- Tests: tests/run-tests.sh (stub clamscan, real tool, fail-closed cases), tests/build-scope-tree.sh
(polyglot, web-root symlink, docroot under tmp, handler dir, uploads, EICAR, sparse 2001 MiB mp4),
tests/image-scope-test.sh (end to end on the built image; CI runs it).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6