feat: Add ClamAV container with automatic config wiring for PHP 8.4 and 8.5 - #410
Open
chris-snyder-totara wants to merge 1 commit into
Open
chris-snyder-totara wants to merge 1 commit into
chris-snyder-totara wants to merge 1 commit into
Conversation
codyfinegan
reviewed
Aug 25, 2026
chris-snyder-totara
force-pushed
the
407-clamav-support
branch
from
August 25, 2026 04:13
96815ae to
58ae857
Compare
chris-snyder-totara
force-pushed
the
407-clamav-support
branch
from
August 26, 2026 05:01
58ae857 to
c5b0dac
Compare
Author
|
Rebased on master. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adding ClamAV support to docker-dev so that we can test antivirus on Totara file uploads.
Testing Instructions
1. Check out this pull request
2. Get the images
The clamav container is the stock upstream image, so it is simply pulled. The PHP images are ours though, and they now contain
clamdscan:After the patch is released, an ordinary upgrade just needs a pull instead:
3. Start it, from your site directory
Signatures are baked into the image, so there is no large download. Wait for the healthcheck to go green — expect
(healthy), usually under a minute:docker ps --filter name=totara_clamav --format '{{.Names}} {{.Status}}'4. Confirm the plumbing
texec php sh -c 'ls -l /run/clamav/clamd.sock; clamdscan --ping 1'Expect a socket listing and
PONG. Ifclamdscanis missing here, your PHP image is stale — redo step 1.5. Confirm Totara enabled the plugin
Run from your site's
server/directory:texec php php -r 'define("CLI_SCRIPT",true); require "config.php"; echo "antivirus active: ", var_export(\core\antivirus\manager::get_antivirus("clamav")->is_configured(), true), "\n";'Expect
antivirus active: true.6. Confirm it actually blocks a virus
This writes the EICAR test file (the industry-standard harmless AV test string, not real malware) and runs it through Totara's own scan path:
texec php php -r 'define("CLI_SCRIPT",true); require "config.php"; $f=sys_get_temp_dir()."/eicar.txt"; file_put_contents($f, base64_decode("WDVPIVAlQEFQWzRcUFpYNTQoUF4pN0NDKTd9JEVJQ0FSLVNUQU5EQVJELUFOVElWSVJVUy1URVNULUZJTEUhJEgrSCo=")); try { \core\antivirus\manager::scan_file($f,"eicar.txt",true); echo "FAIL: virus not detected\n"; } catch (\core\antivirus\scanner_exception $e) { echo "PASS: virus detected and blocked\n"; } @unlink($f);'Expect
PASS: virus detected and blocked.Then repeat through the UI: save that EICAR string as a
.txtfile on your host and upload it via any file picker. The upload should be rejected with a virus warning. This is the step that proves real web uploads are covered, since those land in the container's/tmprather than the shared dataroot.7. Confirm it stays out of the way when off
Reload a page and re-run step 4 — expect
false, and uploads to behave exactly as before. Also worth spot-checking a PHP 8.3 site while clamav is running: it should also reportfalse, since the socket is only mounted on 8.4/8.5.Known behaviours, not bugs
tdown clamavleaves the container asExited (137). The upstream image does not forwardSIGTERMto clamd, so docker kills it. Harmless — and because it also means clamd never removes its socket file,config-after.phpprobes for a live listener rather than trusting the file to be gone.config-after.phpby design.Checklist
bin/directory run correctly on both MacOS and WSLtbuild container && tup container)config.phpare compatible with our oldest supported Totara version, our newest Totara version, and Moodle