-
Notifications
You must be signed in to change notification settings - Fork 69
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
Fix/disable IMDSv1 #2174
Fix/disable IMDSv1 #2174
Conversation
Signed-off-by: Akendo <akendo@akendo.eu> We need to provide for access to the metadata service a token now. Hence, try to fetch one token *before* making the test in a subshell. Not a clean solution, but one that should work. Solves: Security-2
Signed-off-by: Akendo <akendo@akendo.eu>
@@ -5,7 +5,9 @@ | |||
def test_metadata_connection(client, non_azure, non_ali, non_chroot, non_kvm): | |||
metadata_host = "169.254.169.254" | |||
(exit_code, output, error) = client.execute_command( | |||
f"wget --timeout 5 http://{metadata_host}" | |||
f"wget --timeout 5 \ | |||
--header=\"X-aws-ec2-metadata-token: $(curl -sqX PUT 'http://{metadata_host}/latest/api/token' -H 'X-aws-ec2-metadata-token-ttl-seconds: 21600')\" \ |
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.
From the perspective of readability, i would prefer not to get this token value in a subshell command.
Any reason against splitting this into two? Might make it more readable and more easy to debug in case of failure. Also this can include an assertion on the expected return value of the api/token
endpoint.
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.
Approving, I have limited context on this change. If the comment provided on the subshell is useful, feel free to change this and merge then, otherwise ignore it and just merge.
Signed-off-by: Akendo <akendo@akendo.eu>
Signed-off-by: Akendo <akendo@akendo.eu>
@Akendo Thanks for taking care. Porting it to |
What this PR does / why we need it:
We have to disable the IMDSv1. The test will fail without a token. So we request a token from IMDSv2 and provide it for our current test case.