Code Monkey home page Code Monkey logo

clamscan-docker's Introduction

clamscan-docker

Docker Pulls clamscan-docker ci

Dockerization of ClamAV and specifically clamscan command used to scan periodicaly a specific folder for detecting trojans, viruses, malware & other malicious threats. If something bad is detected, an email is sent.

demo.mp4

Parameters

  • SCAN_AT_STARTUP: if 1, then start with a scan when the container is created (default is 1)
  • FRESHCLAM_AT_STARTUP: if 1, then update the virus database when the container startup (default is 1)
  • SCAN_ONLY_NEW_FILES: if 1, then the scan will scan a first time the whole FOLDER_TO_SCAN content, and the next time (see CRON_CLAMSCAN) it will only scan the new files found. Thanks to this feature, the process will be lighter (less CPU usage) especially when there is lot and lot of files in FOLDER_TO_SCAN (default is 1)
  • FOLDER_TO_SCAN: this is the folder to scan with clamscan (default is /folder-to-scan/)
  • CRON_CLAMSCAN: crontab parameters to run the clamscan command which is used to scan the FOLDER_TO_SCAN (default is */5 * * * * - it means each 5 minutes)
  • CRON_FRESHCLAM: crontab parameters to run the freshclam command which is used to update virus databases (default is 0 * * * * * - it means each hours)
  • ALERT_MAILTO: email address to send the alerts to (empty value as default so nothing is sent as)
  • ALERT_SUBJECT: email subject for sending alerts to (Alert from clamscan ! is the default value)
  • SMTP_TLS: to enable TLS, set the value to on (default is off)
  • SMTP_HOST: host or ip of the smtp server used to send the alerts (default is 127.0.0.1)
  • SMTP_PORT: port of the smtp server used to send the alerts (default is 25)
  • SMTP_USER: smtp server login (empty value as default)
  • SMTP_PASSWORD: smtp server password (empty value as default)

Usage

Here is a basic usecase. You have a folder (/var/www/html/uploads/) where anonymous users can upload attachment thanks to a web form. You want to be sure there is no malicious uploaded files. So you decide to deploy clamscan-docker to scan this folder each 15 minutes and to be alerted to [email protected] if a virus is uploaded. Here is the docker commande you will run:

docker run -d --name myclamavcontainer \
  -v /var/www/html/uploads/:/folder-to-scan/ \
  -e SCAN_AT_STARTUP="1"
  -e CRON_CLAMSCAN="*/15 * * * *" \
  -e ALERT_SUBJECT="Alert from clamscan !" \
  -e ALERT_MAILTO="[email protected]" \
  -e SMTP_HOST="smtp.mydomain.fr" \
  -e SMTP_PORT="25" \
  abesesr/clamscan-docker:1.4.7

Developement

Debugging and testing

Firstly, download a virus and put it into ./volumes/folder-to-scan/:

cd ./clamscan-docker/
mkdir -p volumes/folder-to-scan/ && cd volumes/folder-to-scan/ 
curl -L "https://github.com/ytisf/theZoo/blob/dd88d539de6c91e39483848fa0bd2fe859009c3e/malware/Binaries/Win32.LuckyCat/Win32.LuckyCat.zip?raw=true" > ./Win32.LuckyCat.zip
unzip -P infected ./Win32.LuckyCat.zip 

Then run the docker-compose.yml to scan the volumes/folder-to-scan/ folder:

cd ./clamscan-docker/
docker-compose up

Then, open your browser at http://127.0.0.1:8025/ to look at the alert mail sent at the fake email [email protected]

Generating a new version

To generate a new version you have to:

  1. Identify the version you want to create (the version should respect semver (X.X.X) and should not already exist)
  2. Go the github action in charge of creating a new release: https://github.com/abes-esr/clamscan-docker/actions/workflows/create-release.yml
  3. Clic on "Run workflow" on the right, indicate the version, and validate: image
  4. Validate and wait for the build, ci

See also

clamscan-docker's People

Contributors

kerphi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clamscan-docker's Issues

add FRESHCLAM_AT_STARTUP parameter

  • if FRESHCLAM_AT_STARTUP=1 then when the container starts, a freshclam should be launched
  • if FRESHCLAM_AT_STARTUP=0 then when the container starts, freshclam will not be launched and it will wait for the crontab to run it (each hours)

Question - SCAN_ONLY_NEW_FILES and BIG BIG folder

Hello,

First of all, thank you for this inspiring open-source project.

I'm wondering about a concept in your project.
If I understand correctly, you rsync the folder to be scanned to a temporary folder within the docker container. Is this the case?

If so, does that mean that your server needs to have double the disk space? that's unmanageable with large folders, isn't it?

Thanks for the clarification!

CLAMSCAN_OPTIONS: make possible to customize clamscan parameters

Change the default parameters to: --recursive=yes --allmatch=yes --remove=no --suppress-ok-results

Then add a parameter CLAMSCAN_OPTIONS making possible to customize clamscan command.

As a result we should have:

clamscan --recursive=yes --allmatch=yes --remove=no --suppress-ok-results  /folder-to-scan/

SCAN_ONLY_NEW_FILES

SCAN_ONLY_NEW_FILES could be true by default. Then the scan will scan a first time the whole FOLDER_TO_SCAN content, and the next time (CRON_CLAMSCAN) it will only scan the new files found.

Thanks to this feature, the process will be lighter (less CPU usage) especially when there is lot and lot of files in FOLDER_TO_SCAN.

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.