Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flag to skip clean objects #11

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down