This package implements the IFileMalwareScanner
malware scanning interface of
the
@lumieducation/h5p-server
package by calling a ClamAV scanner. ClamAV can be
either installed on the host, called through a UNIX socket or a TCP socket. The
package is a light wrapper around the NPM package
clamscan.
ClamAV's detection rate is really bad. You'd be well advised to find some other antivirus software that you can use that has a higher detection rate. Sadly, this nearly always means you have to use a paid cloud-based scanning service, which might not be an option for you. So if you aren't able to use another antivirus system, using ClamAV probably is still better than nothing.
If you have another anti-virus scanner, you can use the h5p-clamav-scanner
package as a base for implementing the IFileMalwareScanner
interface. We're
interested in pull requests with other implementations!
import ClamAVScanner from '@lumieducation/clamav-scanner';
// There is no public constructor as the initialization is async.
// That's why we have to use an async factory method.
const clamAVScanner = await clamAVScanner.create();
const h5pEditor = new H5PEditor(
// ... regular configuration ...
// Add the scanner to the options parameter
{
malwareScanners: [ clamAVScanner ]
}
);
You can configure the module in code or through environment variables. Environment variables take precedence over configuration in code.
See the clamscan docs for more information about the configuration.
You can specify options in the factory:
const clamAVScanner = await clamAVScanner.create({
clamdscan: {
host: 'clamav-hostname',
port: 3310
}
});
You can also set options by setting these environment variables:
General options:
To use a local clamscan
binary:
To use clamdscan
with UNIX socket or TCP:
The examples in packages/h5p-examples
and packages/h5p-rest-example-server
can be configured to use the ClamAV scanner class. Start the example like this:
CLAMSCAN_ENABLED=true npm start
Note:
CLAMSCAN_ENABLED
environment variable is part of the example code and
won't work if you don't add specific support for it. It triggers the creation of
a ClamAVScanner
instance. You can use the other environment variables to
configure the ClamAVScanner
instance as needed.H5PEditor.saveContentFile
as temporary files, not as in-memory streams.
Temporary file uploads are used by default, in the example (and could be
disabled with the environment variable TEMP_UPLOADS=false). The environment
variable TEMP_UPLOADS is part of the example code and won't work in your custom
implementation, if you don't add explicit support for it.