diff --git a/common.py b/common.py index bb953fca..a762c080 100644 --- a/common.py +++ b/common.py @@ -43,6 +43,7 @@ AV_DEFINITION_FILE_PREFIXES = ["main", "daily", "bytecode"] AV_DEFINITION_FILE_SUFFIXES = ["cld", "cvd"] +AV_SKIP_CLEAN_OBJECTS = int(os.getenv("AV_SKIP_CLEAN_OBJECTS", "0")) SNS_ENDPOINT = os.getenv("SNS_ENDPOINT", None) S3_ENDPOINT = os.getenv("S3_ENDPOINT", None) LAMBDA_ENDPOINT = os.getenv("LAMBDA_ENDPOINT", None) diff --git a/scan.py b/scan.py index a28a6e34..518db682 100644 --- a/scan.py +++ b/scan.py @@ -37,6 +37,7 @@ from common import AV_STATUS_SNS_PUBLISH_CLEAN from common import AV_STATUS_SNS_PUBLISH_INFECTED from common import AV_TIMESTAMP_METADATA +from common import AV_SKIP_CLEAN_OBJECTS from common import SNS_ENDPOINT from common import S3_ENDPOINT from common import create_dir @@ -211,6 +212,13 @@ def lambda_handler(event, context): print("Script starting at %s\n" % (start_time)) s3_object = event_object(event, event_source=EVENT_SOURCE) + if ( + AV_SKIP_CLEAN_OBJECTS + and s3_object.metadata.get(AV_STATUS_METADATA, None) == AV_STATUS_CLEAN + ): + print("Object is clean, skipping...") + return + if str_to_bool(AV_PROCESS_ORIGINAL_VERSION_ONLY): verify_s3_object_version(s3, s3_object)