Skip to content

Commit

Permalink
Merge pull request #67 from Sivakumar3695/cloud_trail_digest_issue_fix
Browse files Browse the repository at this point in the history
Issue with CloudTrail digest fixed
  • Loading branch information
jcsobrino authored Feb 2, 2024
2 parents 67f1869 + d54671e commit d90c26b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ functions:
LICENSE_KEY: ${env:LICENSE_KEY}
LOG_TYPE: ${env:LOG_TYPE}
DEBUG_ENABLED: ${env:DEBUG_ENABLED}
S3_CLOUDTRAIL_LOG_PATTERN: ${env:S3_CLOUDTRAIL_LOG_PATTERN}
S3_CLOUD_TRAIL_LOG_PATTERN: ${env:S3_CLOUD_TRAIL_LOG_PATTERN}
S3_IGNORE_PATTERN: ${env:S3_IGNORE_PATTERN}
BATCH_SIZE_FACTOR: ${env:BATCH_SIZE_FACTOR}
ADDITIONAL_ATTRIBUTES: ${env:ADDITIONAL_ATTRIBUTES}
Expand Down
11 changes: 10 additions & 1 deletion src/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,16 @@ def _isCloudTrail(key=None, regex_pattern=None):
"""
if not regex_pattern:
regex_pattern = _get_optional_env(
"S3_CLOUDTRAIL_LOG_PATTERN", ".*CloudTrail.*\.json.gz$")
"S3_CLOUD_TRAIL_LOG_PATTERN", ".*_CloudTrail_.*\.json.gz$")

return bool(re.search(regex_pattern, key))

def _isCloudTrailDigest(key=None):
"""
This functions checks whether this log file is a CloudTrail-Digest based on regex pattern.
"""
return bool(re.search(".*_CloudTrail-Digest_.*\.json.gz$", key))

def _convert_float(s):
try:
f = float(s)
Expand Down Expand Up @@ -284,6 +290,9 @@ async def _fetch_data_from_s3(bucket, key, context):
"s3_key": key
}
log_file_url = "s3://{}/{}".format(bucket, key)
if _isCloudTrailDigest(key):
# CloudTrail-Digest will not have any logs in it. Hence, no need to continue further
return
async with aiohttp.ClientSession() as session:
log_batches = []
batch_request = []
Expand Down

0 comments on commit d90c26b

Please sign in to comment.