Hearth documentation

Virus scan

Hearth sends uploaded files to a ClamAV daemon (clamd) of your own and acts on its verdict. Files never leave your server for the scan.

The ClamAV container

  hearth-clamav:
    image: clamav/clamav:1.4
    restart: unless-stopped
    environment:
      CLAMD_CONF_ConcurrentDatabaseReload: "no"
      CLAMD_CONF_MaxThreads: "4"
      CLAMD_CONF_StreamMaxLength: 2000M
      CLAMD_CONF_MaxFileSize: 2000M
      CLAMD_CONF_MaxScanSize: 2000M
      CLAMD_CONF_AlertExceedsMax: "yes"
      FRESHCLAM_CHECKS: "4"
    volumes:
      - ./data/clamav:/var/lib/clamav
    healthcheck:
      test: ["CMD", "clamdcheck.sh"]
      interval: 30s
      timeout: 40s
      retries: 3
      start_period: 300s
    mem_limit: 5g

The repository's deploy/clamav builds the same image with a small start script that restarts the container when clamd or freshclam stops.

On the Hearth containers:

CLAMAV_ADDRESS: hearth-clamav:3310
CLAMAV_TIMEOUT_SECONDS: "120"
CLAMAV_RETRY_SECONDS: "60"
Setting Default Meaning
CLAMAV_ADDRESS empty (off) clamd's host:port
CLAMAV_TIMEOUT_SECONDS 120 how long clamd may stay silent during one scan, not a limit on the whole file; raise it (to 300, say) for bulk imports of large files
CLAMAV_RETRY_SECONDS 60 before accepting: how long an upload waits for clamd when it does not answer (a reload or restart) before it is refused; 0 refuses at once. Also how long clamd may be silent before admins are told

Choosing the mode

Go to Administration, Virus scan.

Under Scan uploads, choose:

Largest file to scan (100 MB by default) sets the size above which files are not sent to clamd. In every mode, pictures, videos and sound recognised by their content (not their name), and contents scanned before (copies, re-uploads, restored versions) are skipped.

Select Save.

The scanner's state

The page shows the scanner's Status (Answering, or Not answering with what that means for uploads), its Signatures, how long it has been Silent since, the Queue (Waiting, Checking now) and the Contents remembered as already scanned.

When clamd does not answer for longer than CLAMAV_RETRY_SECONDS, administrators see a notice in the web app and a notification, and the metric hearth_virus_scanner_up drops to 0 (Monitoring). In the background mode, files uploaded meanwhile are checked when it answers again.

When the signatures change, contents seen in the last week are scanned again at once, and everything else on a rolling monthly schedule, at low priority.

Viruses found

Viruses found lists each finding with the file's name, its owner, its path and the signature. A finding in an old version of a file says so. For each one:

A file's owner can also delete a marked file from its details in Files.

What people see

In the background mode, people see nothing until a virus is found; then the owner gets a notification and the file carries the mark. Before accepting, an infected upload fails with "The file was refused: it contains a virus", and the file is not stored.