Code Monkey home page Code Monkey logo

aws-s3-virusscan's Introduction

S3 VirusScan

Antivirus for S3 buckets. You can connect as many buckets as you like by using S3 Event Notifications

Features

  • Uses ClamAV to scan newly added files on S3 buckets
  • Automatically updates ClamAV db every 3 hours
  • Scale EC2 instance workers to distribute workload

How does it work

A picture is worth a thousand words:

Architecture

  1. S3 VirusScan uses a SQS queue to decouple scan jobs from the ClamAV workers. Each S3 bucket can fire events to that SQS queue in case of new objects. This feature of S3 is called S3 Event Notifications.
  2. The SQS queue is consumed by a fleet of EC2 instances running in an Auto Scaling Group. If the number of outstanding scan jobs reaches a treshold a new ClamAV worker is automatically added. If the queue is mostly empty workers are removed.
  3. The ClamAV workers run a simple ruby script that executes the clamscan command. In the background the virus db is updated every three hours.
  4. If clamscan finds a virus the file is directly deleted (you can configure that) and a SNS notification is published.

Installation

Create a CloudFormation stack based on template.json.

Configure the buckets you want to connect to S3 VirusScan as shown in the next figure:

Configure Event Notifications

Make sure you select the -ScanQueue- NOT the -ScanQueueDLQ-!

If you like to receive emails if a virus was found you must subscribe to the SNS topic as shown in the next two figures:

Subscribe Topic: Step 1

Subscribe Topic: Step 2

You will receive a confirmation email.

Test

Create a EICAR Standard Anti-Virus Test File with the following content:

X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*

and upload that file to your S3 bucket.

TODO

  • Support versioned S3 buckets
  • An initial scan may also be useful. This could be implemented with a Lambda function that pushes every key to SQS.

aws-s3-virusscan's People

Contributors

againer avatar andreaswittig avatar cmilam87 avatar michaelwittig avatar rpeterson avatar

Watchers

 avatar  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.