Skip to main content

Serverless architecture to virus scan objects in Amazon S3.

Project description

cdk-serverless-clamscan

cdk

PyPI version npm version

monocdk

PyPI version npm version

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.

Overview

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

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
from aws_cdk.aws_events import RuleTargetInput
from aws_cdk.aws_events_targets import SnsTopic
from aws_cdk.aws_s3 import Bucket
from aws_cdk.aws_sns import Topic
from aws_cdk.core import Construct, Stack, StackProps
from cdk_serverless_clamscan import ServerlessClamscan

class CdkTestStack(Stack):
    def __init__(self, scope, id, *, description=None, env=None, stackName=None, tags=None, synthesizer=None, terminationProtection=None, analyticsReporting=None):
        super().__init__(scope, id, description=description, env=env, stackName=stackName, tags=tags, synthesizer=synthesizer, terminationProtection=terminationProtection, analyticsReporting=analyticsReporting)

        bucket_1 = Bucket(self, "rBucket1")
        bucket_2 = Bucket(self, "rBucket2")
        bucket_list = [bucket_1, bucket_2]
        sc = ServerlessClamscan(self, "rClamscan",
            buckets=bucket_list
        )
        bucket_3 = Bucket(self, "rBucket3")
        sc.add_source_bucket(bucket_3)
        infected_topic = Topic(self, "rInfectedTopic")
        sc.infected_rule.add_target(
            SnsTopic(infected_topic,
                message=RuleTargetInput.from_event_path("$.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

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
from aws_cdk.aws_lambda_destinations import SqsDestination, EventBridgeDestination
from aws_cdk.aws_s3 import Bucket
from aws_cdk.aws_sqs import Queue
from aws_cdk.core import Construct, Stack, StackProps
from cdk_serverless_clamscan import ServerlessClamscan

class CdkTestStack(Stack):
    def __init__(self, scope, id, *, description=None, env=None, stackName=None, tags=None, synthesizer=None, terminationProtection=None, analyticsReporting=None):
        super().__init__(scope, id, description=description, env=env, stackName=stackName, tags=tags, synthesizer=synthesizer, terminationProtection=terminationProtection, analyticsReporting=analyticsReporting)

        bucket_1 = Bucket(self, "rBucket1")
        bucket_2 = Bucket(self, "rBucket2")
        bucket_list = [bucket_1, bucket_2]
        queue = Queue(self, "rQueue")
        sc = ServerlessClamscan(self, "default",
            buckets=bucket_list,
            on_result=EventBridgeDestination(),
            on_error=SqsDestination(queue)
        )
        bucket_3 = Bucket(self, "rBucket3")
        sc.add_source_bucket(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

cdk-serverless-clamscan-0.0.49.tar.gz (142.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cdk_serverless_clamscan-0.0.49-py3-none-any.whl (141.4 kB view details)

Uploaded Python 3

File details

Details for the file cdk-serverless-clamscan-0.0.49.tar.gz.

File metadata

  • Download URL: cdk-serverless-clamscan-0.0.49.tar.gz
  • Upload date:
  • Size: 142.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.10

File hashes

Hashes for cdk-serverless-clamscan-0.0.49.tar.gz
Algorithm Hash digest
SHA256 796d0ca4bec3ad82e55c662651fb4431b3fb493c641e82e3cac2e1cf0331f1f3
MD5 f73b167fc56c718fee1944c34565d442
BLAKE2b-256 929f601c7bd107e7854c7531744f36a366a5aeaf9fe8d3d93fb5f6418a1af791

See more details on using hashes here.

File details

Details for the file cdk_serverless_clamscan-0.0.49-py3-none-any.whl.

File metadata

  • Download URL: cdk_serverless_clamscan-0.0.49-py3-none-any.whl
  • Upload date:
  • Size: 141.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.10

File hashes

Hashes for cdk_serverless_clamscan-0.0.49-py3-none-any.whl
Algorithm Hash digest
SHA256 ec4dddb84a0a9aa0e37daf5932b2229e8e7545d5ee05cc4cda30cee557f0674b
MD5 9f10e824fffc4ebfc0dd7c39c9ba6d2b
BLAKE2b-256 71581b8728f3995a52a9695971180d5d96ae29899288d82405056586fdfad9bb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page