kylefarris / clamscan

A robust ClamAV virus scanning library supporting scanning files, directories, and streams with local sockets, local/remote TCP, and local clamscan/clamdscan binaries (with failover).
MIT License
236 stars 69 forks source link

Error: spawn /usr/bin/clamdscan --no-summary --fdpass --multiscan /usr/src/app/scandir ENOENT #76

Closed mzaidse closed 3 years ago

mzaidse commented 3 years ago

When running clamscan inside clamav docker container (Alpine based), it is giving error.

Steps to reproduce

async function startScan() { try { const clamscan = await new NodeClam().init(); const {good_files, bad_files} = await clamscan.scan_dir(${process.cwd()}/scandir); console.log("🚀 ~ file: app.js ~ startScan ~ good_files", good_files) console.log("🚀 ~ file: app.js ~ startScan ~ bad_files", bad_files) } catch (err) { console.log("🚀 ~ file: app.js ~ startScan ~ err", err) } }

startScan();


## Error

Error: spawn /usr/bin/clamdscan --no-summary --fdpass --multiscan /usr/src/app/scandir ENOENT at parse_stdout (/usr/src/app/node_modules/clamscan/index.js:1221:87) at /usr/src/app/node_modules/clamscan/index.js:1239:37 at exithandler (child_process.js:397:5) at ChildProcess.errorhandler (child_process.js:409:5) at ChildProcess.emit (events.js:400:28) at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12) at onErrorNT (internal/child_process.js:467:16) at processTicksAndRejections (internal/process/task_queues.js:82:21) at emitUnhandledRejectionWarning (internal/process/promises.js:168:15) at processPromiseRejections (internal/process/promises.js:247:11) at processTicksAndRejections (internal/process/task_queues.js:96:32) (node:183) Error: Error: spawn /usr/bin/clamdscan --no-summary --fdpass --multiscan /usr/src/app/scandir ENOENT at parse_stdout (/usr/src/app/node_modules/clamscan/index.js:1221:87) at /usr/src/app/node_modules/clamscan/index.js:1239:37 at exithandler (child_process.js:397:5) at ChildProcess.errorhandler (child_process.js:409:5) at ChildProcess.emit (events.js:400:28) at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12) at onErrorNT (internal/child_process.js:467:16) at processTicksAndRejections (internal/process/task_queues.js:82:21) (node:183) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. at emitDeprecationWarning (internal/process/promises.js:180:11) at processPromiseRejections (internal/process/promises.js:249:13) at processTicksAndRejections (internal/process/task_queues.js:96:32)

kylefarris commented 3 years ago

Try running which clamdscan on your terminal to see what the path to the executable is. If it's not /usr/bin/clamdscan, then you need to specify the correct path when you initialize.

const clamscan = await new NodeClam().init({
    clamdscan: {
        path: `/your/clamdscan/path`
    }
});

The full list of config options can be found here: https://github.com/kylefarris/clamscan#getting-started