Skip to content
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

backend/s3: prevent keys containing double slashes #33869

Merged
merged 1 commit into from
Sep 12, 2023

Conversation

jar-b
Copy link
Member

@jar-b jar-b commented Sep 11, 2023

With the AWS Go SDK V2, URI cleaning of S3 object URLs is no longer done by default. As such, key values containing double slashes (//) could introduce situations where an existing statefile cannot be read. This additional validation step disallows keys containing double slashes to prevent this.

Prevention of leading and trailing slashes (also potential failure points with AWS Go SDK v2) is already done via the validateStringS3Path validator.

% TF_ACC=1 go test ./internal/backend/remote-state/s3/...
ok      github.com/hashicorp/terraform/internal/backend/remote-state/s3 122.148

Relates #33687
Relates hashicorp/terraform-provider-aws#33358 (changes to URI cleaning discovered during SDK upgrade of this resource in the AWS Provider)

Target Release

1.6.x

Draft CHANGELOG entry

N/A - validation change only.

@jar-b jar-b requested a review from a team as a code owner September 11, 2023 18:39
@jar-b jar-b added backend/s3 enhancement 1.6-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged labels Sep 11, 2023
Copy link
Contributor

@gdavison gdavison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 🚀

@jar-b jar-b merged commit 1b9b41b into main Sep 12, 2023
4 checks passed
@jar-b jar-b deleted the s3/key-double-slash-validation branch September 12, 2023 13:40
@github-actions
Copy link
Contributor

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1.6-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged backend/s3 enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants