@oneteam/clamav
This is a nodejs network only client for clamav daemon using the INSTREAM command.
We have been using clamscan
with much success until file sizes started to get above 600MB at which point clamscan
starts to timeout. This module goes back to basic and only supports network operation (clamd doesn't need to be installed locally, it needs to be available on the network though).
To scan a file:
const { scanFile } = require("@oneteam/clamav");
//clamd must be available at 127.0.0.1/3310
const result = await scanFile("myFilePath");
// result.path: "myFilePath"
// result.status: "FOUND"
// result.virus: "Virus Name"
//or
// result.status: "OK" => all good
//or
// result.status: "ERROR" => something went wrong
To scan a stream (eg before saving a file):
const { ClamdNetworkSocket } = require("@oneteam/clamav");
const address = "127.0.0.1"; // your clamd server address
const port = "3310"; // your clamd port number
const cd = new ClamdNetworkSocket(address, port);
const myStream = ...;
const result = await cd.instream("stream name", myStream);
// result.path: "stream name"
// result.status: "FOUND"
// result.virus: "Virus Name"
//or
// result.status: "OK" => all good
//or
// result.status: "ERROR" => something went wrong
clamavCLI
-
node clamavCLI.js
print the help -
node clamavCLI.js samples
run the scan on samples in parallel -
node clamavCLI.js eicar
create and run the scan on eicar file -
node clamavCLI.js path/to/my/file
this will scanpath/to/my/file
Developers
To get started, make sure docker is installed.
This is setup to work on unix like systems, but mostly to get started, once you have generated the samples file, no need for that anymore.
-
./makeSamples.sh
to generate the samples -
npm run clamav
this will start the docker daemon with clamav using the provided config on first run the virus database will get downloaded -
npm run clamdtop
once the docker daemon is started, this will provide a view on the clamav instance best viewed on80x24
console -
npm test
run tests -
npm run test:watch
run tests continuously -
npm run test:log
run tests with continuously debug logs -
npm run test:samples
run a scan on the samples in parallel