GithubHelp home page GithubHelp logo

ishan-marikar / nestjs-clamscan Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kaushiksamanta/nestjs-clamscan

0.0 0.0 0.0 755 KB

Clamscan for Nestjs using clamd (an anti-virus daemon). The daemon listens for incoming connections on Unix and/or TCP socket and scans files or directories on demand.

License: MIT License

TypeScript 100.00%

nestjs-clamscan's Introduction

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
    });
  }
}

nestjs-clamscan's People

Contributors

kaushiksamanta avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.