Clam Engine provides robust native bindings to the clamav library. It allows you to scan files for viruses in-process, without requiring a running instance of clamd
, or imposing the startup time of the clamscan
command.
Clam Engine requires libclamav
to be present.
- Ubuntu:
apt-get install libclamav-dev clamav-freshclam
- Homebew (OS X):
brew install clamav
Just run npm install clam-engine
. Clam Engine supports Node.js versions 4 through 9. If something doesn't work for you using one of those runtimes, please file a bug.
In order for Clam Engine to work, you need to update the clamav virus signatures by running the freshclam
command. You will need to configure it firsy.
var clam = require('clam-engine');
clam.createEngine(function (err, engine) {
if (err) {
return console.log('Error', err);
}
engine.scanFile('eicar.com', function (err, virus) {
if (err) {
return console.log('Error', err);
}
if (virus) {
return console.log('Virus', virus);
}
console.log('Clean');
});
});
-
Creates and initialises a new engine. The callback is called with
(err, engine)
. -
Property that contains the version of the underlying clamav engine.
-
Propery that indicates the number of signatures loaded.
-
Scans a file for a virus. The callback is called with
(err, virus)
.virus
is null if the file is clean.