🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

nestjs-clamscan

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nestjs-clamscan

Clamscan for NestJS

1.0.1
latest
Source
npm
Version published
Weekly downloads
167
-73.53%
Maintainers
1
Weekly downloads
 
Created
Source

Nestjs-clamscan

NPM

npm version total downloads of badging badging's License star github.com/YounGoat/nodejs.badging

A ClamAV client on nest.js

The library uses TCP socket communicate with clamd (ClamAV daemon) through some commands

Clamd protocol is explained here: http://linux.die.net/man/8/clamd

Run the Docker ClamAV daemon

$ docker run --name clamav -d -p 3310:3310 quay.io/ukhomeofficedigital/clamav:latest

Installation

$ npm install nestjs-clamscan

Usage

Intialize Module

import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { ClamscanModule, ClamScanOptions } from 'nestjs-clamscan';

const options: ClamScanOptions = {
  host: process.env.HOST || '127.0.0.1',
  port: Number(process.env.PORT) || 3310,
}

@Module({
  imports: [ClamscanModule.forRoot(options)],
  controllers: [AppController]
})
export class AppModule {}

Intialize Service

import { Controller, Get } from '@nestjs/common';
import { ClamScanService } from 'nestjs-clamscan';

@Controller()
export class AppController {
  constructor(
    private readonly clamScanService: ClamScanService
  ) {
  }

  @Get()
  getVersion(): Promise<string> {
    return this.clamScanService.version();
  }

  @Get('/scan-infected')
  async scanInfected(): Promise<boolean> {
    return this.clamScanService.scanFile(__dirname + '/files/test.virus.txt');
  }

  @Get('/scan-safe')
  async scanSafe(): Promise<boolean> {
    return this.clamScanService.scanFile(__dirname + '/files/test.safe.txt');
  }

  @Get('/scan-directory')
  async scanDirectory(): Promise<ClamScanDirectoryResult> {
    return this.clamScanService.scanDirectory(__dirname + '/files', {
      timeout: 5000,
      chunkSize: 64 * 1024,
      scanningFile: 10,
      detail: true,
      cont: true
    });
  }
}

Keywords

ClamAV

FAQs

Package last updated on 22 Dec 2019

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