Trying to specify binary path for clamAV

1.5k Views Asked by At

I am trying to use clamscan on my windows 10 pro machine in NodeJS. Clamscan is installed to

C:\Program Files\ClamAV

I have this code..

const NodeClam = require('clamscan');  

const ClamScan = new NodeClam().init({   
    scan_recursively: false,
    clamdscan: {                
        path: 'C:\Program Files\ClamAV\clamscan.exe',
        local_fallback: true,
        config_file: 'C:\Program Files\ClamAV\clamd.conf'
    },
});


async function scanFile(filePath) {
    try {
        const clamscan = await ClamScan;
        const { is_infected, viruses } = await clamscan.scan_file(filePath);

        if (is_infected) {
            console.log(`The file is INFECTED with ${viruses}`);
            throw new Error('ERR_FILE_SCAN_INFECTED');
        } else {
            return 'CLEAN';
        }
    } catch (err) {
        throw new Error(err);
    }
  }


  function start() {
    return scanFile('/dodgyfile.rtf');
  }
  
  // Call start
  (async() => {    

    try{
    await start();
    }
    catch(err){
        console.log("error: ",err);
    }    
    
  })();

I get the error.. No valid & active virus scanning binaries are active and available and no host/socket option provided!

All the config examples online seem to be for the linux path..

Does anyone have experience of using this on windows? Thanks

1

There are 1 best solutions below

0
On

I had the same problem myself. The problem here is in the path of the file itself, the space in \Program Files causes the error.

I didn't find any quick fix so I decided to use the portable version for Win64 of ClamAV that can be downloaded on their website under the Win64 section.

Extracting the content in a folder with a path without any spaces solved the problem for me.