Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clamscan

Package Overview
Dependencies
Maintainers
2
Versions
62
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.

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
60K
decreased by-62.29%
Maintainers
2
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 21 Sep 2021

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