Socket
Socket
Sign inDemoInstall

clamscan

Package Overview
Dependencies
Maintainers
3
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clamscan

Use Node JS to scan files on your server with ClamAV's clamscan/clamdscan binary or via TCP to a remote server or local UNIX Domain socket. This is especially useful for scanning uploaded files provided by un-trusted sources.


Version published
Weekly downloads
120K
increased by10.96%
Maintainers
3
Weekly downloads
 
Created

What is clamscan?

The clamscan npm package is a Node.js wrapper for the ClamAV antivirus software. It allows you to scan files, directories, and streams for viruses and malware using ClamAV's powerful scanning capabilities.

What are clamscan's main functionalities?

Scan a file

This feature allows you to scan a specific file for viruses. The code initializes the clamscan instance and scans the specified file, returning whether the file is infected and the names of any detected viruses.

const NodeClam = require('clamscan');
const clamscan = new NodeClam().init();

clamscan.then(async clamscan => {
  const { isInfected, file, viruses } = await clamscan.scanFile('/path/to/file');
  if (isInfected) {
    console.log(`The file ${file} is infected with ${viruses}`);
  } else {
    console.log(`The file ${file} is clean.`);
  }
}).catch(err => {
  console.error(`Error initializing ClamScan: ${err}`);
});

Scan a directory

This feature allows you to scan an entire directory for viruses. The code initializes the clamscan instance and scans the specified directory, returning whether any files are infected and listing the infected files and detected viruses.

const NodeClam = require('clamscan');
const clamscan = new NodeClam().init();

clamscan.then(async clamscan => {
  const { isInfected, goodFiles, badFiles, viruses } = await clamscan.scanDir('/path/to/directory');
  if (isInfected) {
    console.log(`The directory contains infected files: ${badFiles}`);
  } else {
    console.log(`All files in the directory are clean.`);
  }
}).catch(err => {
  console.error(`Error initializing ClamScan: ${err}`);
});

Scan a stream

This feature allows you to scan a stream for viruses. The code initializes the clamscan instance and scans the provided stream, returning whether the stream is infected and the names of any detected viruses.

const NodeClam = require('clamscan');
const fs = require('fs');
const clamscan = new NodeClam().init();

clamscan.then(async clamscan => {
  const stream = fs.createReadStream('/path/to/file');
  const { isInfected, viruses } = await clamscan.scanStream(stream);
  if (isInfected) {
    console.log(`The stream is infected with ${viruses}`);
  } else {
    console.log(`The stream is clean.`);
  }
}).catch(err => {
  console.error(`Error initializing ClamScan: ${err}`);
});

Other packages similar to clamscan

Keywords

FAQs

Package last updated on 22 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc