-
Notifications
You must be signed in to change notification settings - Fork 464
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
[AWS] Add the Security Hub data streams #3553
Conversation
💚 CLA has been signed |
faf7157
to
25b0896
Compare
Pinging @elastic/security-external-integrations (Team:Security-External Integrations) |
🌐 Coverage report
|
It seems like one panel on the dashboard is using a non-existing field name (maybe it got renamed): Also, is there a special reason most of the "event distribution" charts are pies, but some of them are bar charts? As there are a lot of similar panels and the dashboard gets pretty long, would it make sense to split it up into multiple dashboards and link it up via a markdown visualization so the user can "select" the charts they are interested in instead of scrolling through a long dashboard? This really depends on how it's meant to be used though. |
value_type: json | ||
- set: | ||
target: header.Authorization | ||
value: '[[(sprintf "AWS4-HMAC-SHA256 Credential={{access_key_id}}/%s/{{aws_region}}/securityhub/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}}")) "securityhub")) "aws4_request")) "AWS4-HMAC-SHA256\n" (formatDate (now) "20060102T150405Z") "\n" (sprintf "%s/%s\n" (formatDate (now) "20060102") "{{aws_region}}/securityhub/aws4_request") (hash "sha256" "POST\n" "/findings\n" "\n" "host:securityhub.{{aws_region}}.amazonaws.com\n" (sprintf "x-amz-date:%s\n\n" (formatDate (now) "20060102T150405Z")) "host;x-amz-date\n" (hash "sha256" (sprintf `%s` .body)))))]]' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are multiple calls to now
in here that need to match the already set X-Amz-Date
header down to the second. This is a race condition. Instead of calling formatDate now "20060102T150405Z"
twice, can you replace that with an access to the header value? Like (index .header "X-Amz-Date")
assuming the header map is available in this context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marc-gr @P1llus Have you come across this type of issue before? I was thinking it would useful to have a "now"-like function that returns the same time for all invocations within the context of a given request. This would allow all "now"s used in a request to be the same.
Or another option would to provide a generic scratch pad where you can store the current time once and then reference it later. A similar concept is used in consul-template https://github.com/hashicorp/consul-template/blob/main/docs/templating-language.md#scratch. The idea would be like
request.transforms:
- set:
target: scratch.RequestTime
value: '[[ now ]]'
- set:
target: header.X-Amz-Date
value: '[[formatDate (.scratch.RequestTime) "20060102T150405Z"]]'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not fully fix the problem but it does reduce the number of now
invocations to one (credit to @efd6). You can declare variable in the template then use the variable instead of calling now
. Like [[$now := now]]
then replace the now
calls with $now
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have any documentation for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming by "this" you mean declaring variables in templates, then you can look at https://pkg.go.dev/text/template#hdr-Variables. Variable declarations in templates is something built in to Go text/template.
@@ -1,7 +1,7 @@ | |||
format_version: 1.0.0 | |||
name: aws | |||
title: AWS | |||
version: 1.16.6 | |||
version: 1.17.0 | |||
license: basic | |||
description: Collect logs and metrics from Amazon Web Services with Elastic Agent. | |||
type: integration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving this comment here because it's close to the kibana.version
. What are the Agent version requirements? Are there newly introduced httpjson template functions required for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes newly introduced httpjson template functions is required for this. So we have mentioned it in Readme that 8.4.0 version will be required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this did not happen.
target: header.Authorization | ||
- set: | ||
target: header.Authorization | ||
value: '[[(sprintf "AWS4-HMAC-SHA256 Credential={{access_key_id}}/%s/{{aws_region}}/securityhub/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}}")) "securityhub")) "aws4_request")) "AWS4-HMAC-SHA256\n" (formatDate (now) "20060102T150405Z") "\n" (sprintf "%s/%s\n" (formatDate (now) "20060102") "{{aws_region}}/securityhub/aws4_request") (hash "sha256" "POST\n" "/findings\n" "\n" "host:securityhub.{{aws_region}}.amazonaws.com\n" (sprintf "x-amz-date:%s\n\n" (formatDate (now) "20060102T150405Z")) "host;x-amz-date\n" (hash "sha256" (sprintf `%s` .body)))))]]' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reviewers, I formatted this for to help make sense of it.
[[
(sprintf
"AWS4-HMAC-SHA256 Credential={{access_key_id}}/%s/{{aws_region}}/securityhub/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}}"
)
)
"securityhub"
)
)
"aws4_request"
)
)
"AWS4-HMAC-SHA256\n"
(formatDate
now
"20060102T150405Z"
)
"\n"
(sprintf
"%s/%s\n"
(formatDate
now
"20060102"
)
"{{aws_region}}/securityhub/aws4_request"
)
(hash
"sha256"
"POST\n"
"/findings\n"
"\n"
"host:securityhub.{{aws_region}}.amazonaws.com\n"
(sprintf
"x-amz-date:%s\n\n"
(formatDate
now
"20060102T150405Z"
)
)
"host;x-amz-date\n"
(hash
"sha256"
(sprintf
"%s"
.body
)
)
)
)
)
]]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs a system test so that we can test indexing. With only pipeline tests we can't catch various mapping issues.
packages/aws/data_stream/securityhub_findings/agent/stream/httpjson.yml.hbs
Outdated
Show resolved
Hide resolved
packages/aws/data_stream/securityhub_insights/elasticsearch/ingest_pipeline/default.yml
Show resolved
Hide resolved
...a_stream/securityhub_findings/_dev/test/pipeline/test-securityhub-findings.log-expected.json
Outdated
Show resolved
Hide resolved
packages/aws/data_stream/securityhub_findings/elasticsearch/ingest_pipeline/default.yml
Outdated
Show resolved
Hide resolved
packages/aws/data_stream/securityhub_findings/sample_event.json
Outdated
Show resolved
Hide resolved
/test |
@andrewkroh We are facing below issue when we are updating version to 8.3.0 So can we do the changes in Redshift data stream? |
Let's back out the 8.3.0 ECS change and handle the upgrade separately as to not mix the redshift updates with the security hub additions. |
/test |
9a28dd2
to
eb06e5b
Compare
@elastic/obs-cloud-monitoring, can you please take a look at this PR? As a codeowner for aws you are a required reviewer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me
What does this PR do?
Checklist
changelog.yml
file.How to test this PR locally
Screenshots