clamscan
clamscan copied to clipboard
NodeClamError: There was an issue scanning the path specified!
When I run clamscan in the command line, it is able to scan the files in the location. But when I run the below code and pass a file to scan, its failing
const NodeClam = require('clamscan');
const ClamScan = new NodeClam().init({
clamscan: {
path: '/usr/local/bin/clamscan'
},
clamdscan: {
path: "/usr/local/bin/clamdscan"
}
});
ClamScan.then(async clamscan => {
try {
const pathForFile = __dirname + '/file2.pdf';
const { path, isInfected, goodFiles, badFiles, viruses } = await clamscan.scanDir(pathForFile);
} catch (err) {
console.log({ err })
}
}).catch(err => {
console.log({ err })
});
Below is the complete error I received
{
e: NodeClamError: Error: Command failed: /usr/local/bin/clamdscan --no-summary --fdpass --multiscan /Users/mac/Assetplus/insurance-health/src/middlewares/file2.pdf
at parseStdout (/Users/mac/Assetplus/insurance-health/node_modules/clamscan/index.js:1574:83)
at /Users/mac/Assetplus/insurance-health/node_modules/clamscan/index.js:1602:91
at ChildProcess.exithandler (node:child_process:410:5)
at ChildProcess.emit (node:events:513:28)
at ChildProcess.emit (node:domain:489:12)
at maybeClose (node:internal/child_process:1100:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5) {
data: { badFiles: [] },
date: 2024-05-14T07:06:26.161Z
}
}
{
err: NodeClamError: There was an issue scanning the path specified!
at /Users/mac/Assetplus/insurance-health/node_modules/clamscan/index.js:2009:33
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
data: {
path: '/Users/mac/Assetplus/insurance-health/src/middlewares/file2.pdf',
err: [NodeClamError]
},
date: 2024-05-14T07:06:26.163Z
}
}
You're running scanDir but passing a single file. Use isInfected, instead, if you want to scan a single file. Or pass the directory you want to scan (ex. /Users/mac/Assetplus/insurance-health/src/middlewares)