# mod\_clamav

Source: https://zotonic.com/docs/1477/mod_clamav

URI: https://zotonic.com/id/1477

Language: en



Uses `clamd` to scan all uploaded files for viruses.

The scanning happens after the mime type and access control is checked, but before the sanitization. If a file is infected then the error `infected` will be returned. The admin will display a growl message telling that the file was infected.

Clamd has a maximum size for checks, above that size the error `sizelimit` will be returned.

Configure in the `zotonic.config` file where `clamd` is listening.

The following configs are available:

`clamav_ip`

Address of `clamd`, default to `"127.0.0.1"`. Set to `socket` to connect only to the Unix domain socket configured by `clamav_socket`, or set it to an absolute socket path to connect only to that socket. Socket-only connections never fall back to TCP.

`clamav_port`

Port of `clamd`, default to `3310`

`clamav_socket`

Unix domain socket path of `clamd`, default to `/run/clamav/clamd.ctl`. When `clamav_ip` is a network address, the module tries this socket first and falls back to `clamav_ip` and `clamav_port`. Set to `false` or an empty string to use TCP only. When `clamav_ip` is `socket`, this is the exclusive socket path. The Zotonic process must have permission to connect to it. The path must match `LocalSocket` in `clamd.conf`.

`clamav_max_size`

The **StreamMaxLength** of `clamd`, default to `26214400` (25M)

`clamav_reject_msoffice_external_links`

Reject Microsoft Office documents containing `externalLinks` information. If the Zotonic config is set to `false` then rejection can be forced by setting the site’s config key `mod_clamav.reject_msoffice_external_links` to `1`. Defaults to `true`.

All clamav results are logged, any infected files or other errors are logged to the error.log.

Every hour the module checks if it can reach `clamd` using the configured settings. It will log an error if `clamd` can’t be reached, and an info message if it can be reached.

The admin dashboard also checks connectivity asynchronously on each page load. If ClamAV cannot be reached, it displays a warning that file uploads are blocked until the scanner is available again.

Accepted Events
---------------

This module handles the following notifier callbacks:

- `observe_media_upload_preprocess`: Check the uploaded file with clamav using `z_acl:user`.
- `observe_tick_1h`: Periodic ping of clamav using the configured socket or TCP endpoint.

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/1477?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/1477?language=en>)
