Skip to content

Commit

Permalink
aws: fix query range calculation for GuardDuty datastream
Browse files Browse the repository at this point in the history
The calculations for findingCriteria.criterion.updatedAt.*Than included
a time truncation with the resolution of an hour. This has the effect
that if there was no successful execution of the last_execution_datetime
template the greaterThan and lessThan values would be equal 1 in
hour/initial_interval times, resulting in spurious requests that
required satisfaction of a null set. The truncation also prevents
progession of the criteria for 1 - (1 in hour/initial_interval) HTTPJSON
periodic request cycles.
  • Loading branch information
efd6 committed Jan 15, 2024
1 parent c91fc59 commit 0d4020e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions packages/aws/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# newer versions go on top
- version: "2.11.3"
changes:
- description: Fix query range calculation for GuardDuty datastream.
type: bugfix
link: https://github.com/elastic/integrations/pull/
- version: "2.11.2"
changes:
- description: Remove hardcoded event.dataset field and use ecs instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ request.transforms:
value_type: json
- set:
target: body.findingCriteria.criterion.updatedAt.greaterThan
value: '[[((parseDate .cursor.last_execution_datetime).Truncate (parseDuration "1h")).UnixMilli]]'
default: '[[((now (parseDuration "-{{initial_interval}}")).Truncate (parseDuration "1h")).UnixMilli]]'
value: '[[((parseDate .cursor.last_execution_datetime)).UnixMilli]]'
default: '[[((now (parseDuration "-{{initial_interval}}"))).UnixMilli]]'
- set:
target: body.findingCriteria.criterion.updatedAt.lessThan
value: '[[((now).Truncate (parseDuration "1h")).UnixMilli]]'
value: '[[((now)).UnixMilli]]'
- set:
target: header.Authorization
value: '[[$now := (now)]][[(sprintf "AWS4-HMAC-SHA256 Credential={{access_key_id}}/%s/{{aws_region}}/guardduty/aws4_request, SignedHeaders=host;x-amz-date, Signature=%s" (formatDate ($now) "20060102") (hmac "sha256" (hexDecode (hmac "sha256" (hexDecode (hmac "sha256" (hexDecode (hmac "sha256" (hexDecode (hmac "sha256" "AWS4{{secret_access_key}}" (formatDate ($now) "20060102"))) "{{aws_region}}")) "guardduty")) "aws4_request")) "AWS4-HMAC-SHA256\n" (formatDate ($now) "20060102T150405Z") "\n" (sprintf "%s/%s\n" (formatDate ($now) "20060102") "{{aws_region}}/guardduty/aws4_request") (hash "sha256" "POST\n" "/detector/{{detector_id}}/findings\n" "\n" "host:guardduty.{{aws_region}}.{{tld}}\n" (sprintf "x-amz-date:%s\n\n" (formatDate ($now) "20060102T150405Z")) "host;x-amz-date\n" (hash "sha256" (sprintf `%s` .body)))))]]'
Expand Down
2 changes: 1 addition & 1 deletion packages/aws/manifest.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
format_version: 3.0.0
name: aws
title: AWS
version: 2.11.2
version: 2.11.3
description: Collect logs and metrics from Amazon Web Services (AWS) with Elastic Agent.
type: integration
categories:
Expand Down

0 comments on commit 0d4020e

Please sign in to comment.