Serverless architecture to virus scan objects in Amazon S3.
Project description
cdk-serverless-clamscan
Language | cdk-serverless-clamscan | monocdk-serverless-clamscan |
---|---|---|
Python | ||
TypeScript |
- If your project uses cdk version 1.x.x use
cdk-serverless-clamscan
^1.0.0 - If your project uses cdk version 2.x.x use
cdk-serverless-clamscan
^2.0.0 - If your project uses monocdk use
monocdk-serverless-clamscan
^1.0.0
An aws-cdk construct that uses ClamAV® to scan objects in Amazon S3 for viruses. The construct provides a flexible interface for a system to act based on the results of a ClamAV virus scan.
Pre-Requisites
Docker: The ClamAV Lambda functions utilizes a container image that is built locally using docker bundling
Examples
This project uses projen and thus all the constructs follow language specific standards and naming patterns. For more information on how to translate the following examples into your desired language read the CDK guide on Translating TypeScript AWS CDK code to other languages
Example 1. (Default destinations with rule target)
typescript
import { RuleTargetInput } from '@aws-cdk/aws-events';
import { SnsTopic } from '@aws-cdk/aws-events-targets';
import { Bucket } from '@aws-cdk/aws-s3';
import { Topic } from '@aws-cdk/aws-sns';
import { Construct, Stack, StackProps } from '@aws-cdk/core';
import { ServerlessClamscan } from 'cdk-serverless-clamscan';
export class CdkTestStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const bucket_1 = new Bucket(this, 'rBucket1');
const bucket_2 = new Bucket(this, 'rBucket2');
const bucketList = [bucket_1, bucket_2];
const sc = new ServerlessClamscan(this, 'rClamscan', {
buckets: bucketList,
});
const bucket_3 = new Bucket(this, 'rBucket3');
sc.addSourceBucket(bucket_3);
const infectedTopic = new Topic(this, 'rInfectedTopic');
sc.infectedRule?.addTarget(
new SnsTopic(infectedTopic, {
message: RuleTargetInput.fromEventPath(
'$.detail.responsePayload.message',
),
}),
);
}
}
python
from aws_cdk import (
core as core,
aws_events as events,
aws_events_targets as events_targets,
aws_s3 as s3,
aws_sns as sns
)
from cdk_serverless_clamscan import ServerlessClamscan
class CdkTestStack(core.Stack):
def __init__(self, scope: core.Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
bucket_1 = s3.Bucket(self, "rBucket1")
bucket_2 = s3.Bucket(self, "rBucket2")
bucketList = [ bucket_1, bucket_2 ]
sc = ServerlessClamscan(self, "rClamScan",
buckets=bucketList,
)
bucket_3 = s3.Bucket(self, "rBucket3")
sc.add_source_bucket(bucket_3)
infected_topic = sns.Topic(self, "rInfectedTopic")
if sc.infected_rule != None:
sc.infected_rule.add_target(
events_targets.SnsTopic(
infected_topic,
message=events.RuleTargetInput.from_event_path('$.detail.responsePayload.message'),
)
)
Example 2. (Bring your own destinations)
typescript
import {
SqsDestination,
EventBridgeDestination,
} from '@aws-cdk/aws-lambda-destinations';
import { Bucket } from '@aws-cdk/aws-s3';
import { Queue } from '@aws-cdk/aws-sqs';
import { Construct, Stack, StackProps } from '@aws-cdk/core';
import { ServerlessClamscan } from 'cdk-serverless-clamscan';
export class CdkTestStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const bucket_1 = new Bucket(this, 'rBucket1');
const bucket_2 = new Bucket(this, 'rBucket2');
const bucketList = [bucket_1, bucket_2];
const queue = new Queue(this, 'rQueue');
const sc = new ServerlessClamscan(this, 'default', {
buckets: bucketList,
onResult: new EventBridgeDestination(),
onError: new SqsDestination(queue),
});
const bucket_3 = new Bucket(this, 'rBucket3');
sc.addSourceBucket(bucket_3);
}
}
python
from aws_cdk import (
core as core,
aws_lambda_destinations as lambda_destinations,
aws_s3 as s3,
aws_sqs as sqs
)
from cdk_serverless_clamscan import ServerlessClamscan
class CdkTestStack(core.Stack):
def __init__(self, scope: core.Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
bucket_1 = s3.Bucket(self, "rBucket1")
bucket_2 = s3.Bucket(self, "rBucket2")
bucketList = [ bucket_1, bucket_2 ]
queue = sqs.Queue(self, "rQueue")
sc = ServerlessClamscan(self, "rClamScan",
buckets=bucketList,
on_result=lambda_destinations.EventBridgeDestination(),
on_error=lambda_destinations.SqsDestination(queue),
)
bucket_3 = s3.Bucket(self, "rBucket3")
sc.add_source_bucket(bucket_3)
Operation and Maintenance
When ClamAV publishes updates to the scanner you will see “Your ClamAV installation is OUTDATED” in your scan results. While the construct creates a system to keep the database definitions up to date, you must update the scanner to detect all the latest Viruses.
Update the docker images of the Lambda functions with the latest version of ClamAV by re-running cdk deploy
.
API Reference
See API.md.
Contributing
See CONTRIBUTING for more information.
License
This project is licensed under the Apache-2.0 License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file monocdk-serverless-clamscan-1.2.18.tar.gz
.
File metadata
- Download URL: monocdk-serverless-clamscan-1.2.18.tar.gz
- Upload date:
- Size: 155.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13748f2c61e88415a277978ebcc42fe282722af69744a284869bbf59d59083d8 |
|
MD5 | 4b4fde3db086e3dfa7468d797e606eb2 |
|
BLAKE2b-256 | 51912fe4d74f5691be65c45bf2f72cc855048473ab4d844dc499ae151a5231d5 |
File details
Details for the file monocdk_serverless_clamscan-1.2.18-py3-none-any.whl
.
File metadata
- Download URL: monocdk_serverless_clamscan-1.2.18-py3-none-any.whl
- Upload date:
- Size: 154.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7103fff6bc18679a495b5f3ce653e0c40d203874e600fc7f57928e260e739717 |
|
MD5 | 18c5663c8aad54fb5998debedf684baa |
|
BLAKE2b-256 | cf021fb9e42c1611eddc90b3035ab08e7f7726ca139fa91c2b853d9af9838c5d |