-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Libbeat] Security - fetch IMDSv2 token for add_cloud_metadata suppor… #28285
[Libbeat] Security - fetch IMDSv2 token for add_cloud_metadata suppor… #28285
Conversation
This pull request does not have a backport label. Could you fix it @aspacca? 🙏
NOTE: |
Pinging @elastic/integrations (Team:Integrations) |
This pull request does not have a backport label. Could you fix it @aspacca? 🙏
NOTE: |
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
💚 Flaky test reportTests succeeded. 🤖 GitHub commentsTo re-run your PR in the CI, just comment with:
|
This pull request is now in conflicts. Could you fix it? 🙏
|
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.
Overall looks good to me, just several small comments.
const ec2InstanceIMDSv2TokenValueHeader = "X-aws-ec2-metadata-token" | ||
const ec2InstanceIMDSv2TokenTTLHeader = "X-aws-ec2-metadata-token-ttl-seconds" | ||
const ec2InstanceIMDSv2TokenTTLValue = "21600" | ||
const ec2InstanceIMDSv2TokenURI = "/latest/api/token" |
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.
const ec2InstanceIMDSv2TokenURI = "/latest/api/token" | |
const ( | |
ec2InstanceIdentityURI = "/2014-02-25/dynamic/instance-identity/document" | |
ec2InstanceIMDSv2TokenURI = "/latest/api/token" | |
ec2InstanceIMDSv2TokenTTLHeader = "X-aws-ec2-metadata-token-ttl-seconds" | |
ec2InstanceIMDSv2TokenTTLValue = "21600" | |
ec2InstanceIMDSv2TokenURI = "/latest/api/token" | |
) |
"net/http" | ||
|
||
"github.com/elastic/beats/v7/libbeat/logp" | ||
|
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.
remove the empty space
|
||
tlsConfig, err := tlscommon.LoadTLSConfig(config.TLS) | ||
if err != nil { | ||
logger.Warnf("error while getting IMDSv2 token: %s. No token in the metadata request will be used.", err) |
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.
logger.Warnf("error while getting IMDSv2 token: %s. No token in the metadata request will be used.", err) | |
logger.Warnf("error when load TLS config for getting IMDSv2 token: %s. No token in the metadata request will be used.", err) |
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.
All the warning log messages are the same in the function. What do you think about adding more detail in the warning messages?
elastic#28285) * [Libbeat] Security - fetch IMDSv2 token for add_cloud_metadata support on aws
…t on aws
Enanchment
What does this PR do?
Fetches IMDSv2 token in
add_cloud_metadata
processor for AWS and send it with the proper header to the identity url requestWhy is it important?
It adds support for IMDSv2 on AWS enforcing security standard
Checklist
- [ ] I have made corresponding changes to the documentation- [ ] I have made corresponding change to the default configuration files- [ ] I have added tests that prove my fix is effective or that my feature worksCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Author's Checklist
How to test this PR locally
Run any beat built from this adding
add_cloud_metadata
processor an an EC2 instance with only IMDSv2 enabled and ensure that metadata request doesn't fail with a 401Related issues
Closes #22101
Use cases
Screenshots
Logs