New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

pompelmi

Package Overview
Dependencies
Maintainers
1
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pompelmi

ClamAV for humans — scan any file and get back Clean, Malicious, or ScanError. No daemons. No cloud. No native bindings.

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
2.6K
-0.54%
Maintainers
1
Weekly downloads
 
Created
Source

pompelmi logo

pompelmi

ClamAV for humans

npm version license platform zero dependencies

A minimal Node.js wrapper around ClamAV that scans any file and returns a plain string: "Clean", "Malicious", or "ScanError". No daemons. No cloud. No native bindings.

Table of contents

Quickstart

npm install pompelmi
const pompelmi = require('pompelmi');

const result = await pompelmi.scan('/path/to/file.zip');
// "Clean" | "Malicious" | "ScanError"

if (result === 'Malicious') {
  throw new Error('File rejected: malware detected');
}

How it works

  • Validate — pompelmi checks that the argument is a string and that the file exists before spawning anything.
  • Scan — pompelmi spawns clamscan --no-summary <filePath> as a child process and reads the exit code.
  • Map — the exit code is mapped to a result string. Unknown codes and spawn errors reject the Promise.

No stdout parsing. No regex. No surprises.

API

pompelmi.scan(filePath, [options])

pompelmi.scan(filePath: string, options?: { host?: string; port?: number; timeout?: number }): Promise<"Clean" | "Malicious" | "ScanError">
ParameterTypeDescription
filePathstringAbsolute or relative path to the file.
optionsobjectOptional. Omit to use the local clamscan CLI. Pass host / port to scan via a clamd TCP socket instead. See docs/api.md for the full reference.

Resolves to one of:

ResultClamAV exit codeMeaning
"Clean"0No threats found.
"Malicious"1A known virus or malware signature was matched.
"ScanError"2The scan itself failed (I/O error, encrypted archive, permission denied). File status is unknown — treat as untrusted.

Rejects with an Error in these cases:

ConditionError message
filePath is not a stringfilePath must be a string
File does not existFile not found: <path>
clamscan is not in PATHENOENT (from the OS)
ClamAV returns an unknown exit codeUnexpected exit code: N
clamscan process is killed by a signalProcess killed by signal: <SIGNAL>

Example — full error handling:

const pompelmi = require('pompelmi');
const path = require('path');

async function safeScan(filePath) {
  try {
    const result = await pompelmi.scan(path.resolve(filePath));

    if (result === 'ScanError') {
      // The scan could not complete — treat the file as untrusted.
      console.warn('Scan incomplete, rejecting file as precaution.');
      return null;
    }

    return result; // "Clean" or "Malicious"
  } catch (err) {
    console.error('Scan failed:', err.message);
    return null;
  }
}

Docker / remote scanning

If ClamAV runs in a Docker container (or anywhere on the network), pass host and port — everything else stays the same.

const result = await pompelmi.scan('/path/to/upload.zip', {
  host: '127.0.0.1',
  port: 3310,
});

See docs/docker.md for the docker-compose.yml snippet and first-boot notes.

Internal utilities

These modules are not part of the public npm API but are used internally to set up the ClamAV environment on a fresh machine.

ClamAVInstaller()

Installs ClamAV using the platform's native package manager. Skips silently if ClamAV is already installed.

ClamAVInstaller(): Promise<string>
  • Resolves with a status message string on success or skip.
  • Rejects if the install process exits with a non-zero code or if spawning the package manager fails.
PlatformPackage managerCommand
macOSHomebrewbrew install clamav
Linuxapt-getsudo apt-get install -y clamav clamav-daemon
WindowsChocolateychoco install clamav -y

updateClamAVDatabase()

Downloads or updates the ClamAV virus definition database by running freshclam. Skips if main.cvd is already present on disk.

updateClamAVDatabase(): Promise<string>
  • Resolves with a status message string on success or skip.
  • Rejects if freshclam exits with a non-zero code or if spawning fails.
PlatformDatabase path
macOS/usr/local/share/clamav/main.cvd
Linux/var/lib/clamav/main.cvd
WindowsC:\ProgramData\ClamAV\main.cvd

Supported platforms

OSClamAV installDB path checked
macOSbrew install clamav/usr/local/share/clamav/main.cvd
Linuxapt-get install clamav/var/lib/clamav/main.cvd
Windowschoco install clamav -yC:\ProgramData\ClamAV\main.cvd

ClamAV must be installed on the host system. pompelmi does not bundle or download it.

Installing ClamAV manually

# macOS
brew install clamav && freshclam

# Linux (Debian / Ubuntu)
sudo apt-get install -y clamav clamav-daemon && sudo freshclam

# Windows (Chocolatey)
choco install clamav -y

Testing

npm test

The test suite has two parts:

  • Unit tests (test/unit.test.js) — run with Node's built-in test runner. Mock cross-spawn and platform dependencies; no ClamAV installation required.
  • Integration tests (test/scan.test.js) — spawn real clamscan processes against EICAR test files. Skipped automatically if clamscan is not found in PATH.

Contributing

  • Fork the repository at https://github.com/pompelmi/pompelmi.
  • Create a feature branch: git checkout -b feat/your-change.
  • Make your changes and run npm test to verify.
  • Open a pull request against main.

Please read CODE_OF_CONDUCT.md before contributing.

Security

To report a vulnerability, see SECURITY.md.

License

ISC — © pompelmi contributors

Keywords

clamav

FAQs

Package last updated on 12 Apr 2026

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