-
Notifications
You must be signed in to change notification settings - Fork 42
AWS S3: Handle Illegal Headers in Copy Part #1246
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
base: main
Are you sure you want to change the base?
Conversation
| .withCustomHeaders( | ||
| Map( | ||
| requestPayerHeader -> requestPayerHeaderValue, | ||
| storgeClassHeader -> storageClassHeaderValue, |
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 adds the header that is valid for creating the multipart copy request, but is not valid for the put requests
Docs list all valid headers here
I realize that there is also the storage class header value, but it also doesn't include all valid header values which is why I'm adding it this way. Additionally looking at the code it appears the behavior would be the same.
| .withHeader(sseCSourceAlgorithmHeader, new EqualToPattern(sseCSourceAlgorithmHeaderValue)) | ||
| .withHeader(sseCSourceKeyHeader, new EqualToPattern(sseCSourceKeyHeaderValue)) | ||
| .withHeader(requestPayerHeader, new EqualToPattern(requestPayerHeaderValue))) | ||
| .withHeader(requestPayerHeader, new EqualToPattern(requestPayerHeaderValue)) |
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 is showing the correct outcome, but with the change in S3Stream.scala we remove the valid header of requestPayerHeaderValue. Without it we get illegal storageClassHeader
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 test now passes with the proposed change
|
@mdedetrich / @pjfanning - I made this draft PR to demonstrate the problem in order to discuss the path forward for fixing this problem. I'm going to look to see if I can create an integration test tomorrow. I'm thinking that we have an allow list of all correct headers and filter out all the headers that start with the I say starts with The main con here is that if AWS introduces new headers in the future this would require an update. Alternatively we may wish to simply remove Open to alternative suggestions if there are any |
I would say, if we do have an allowlist it should be provided in as configuration in @pjfanning @raboof thoughts? |
|
Sorry, I don't think I understand s3 well enough to have a meaningful opinion here |
|
I have no strong opinion about being proactive about headers. It seems to introduce its own risks. If we do introduce a new config, avoid any name that uses colour based naming, eg white or black. |
|
@mdedetrich / @pjfanning - Do I need to worry about source/binary compat? Not sure I can add the configuration handling without breaking compatibility on some level Additionally I assume I should be handling the headers the same way for all header S3Request types and not just CopyPart? |
@Luka-J9 it's ok to break binary compatibility on main branch as it is targeted at a 2.0.0 release. Just add a mima-filters file. You'll find examples in the src code already ( |
So I am not sure how this change would be binary or even source breaking, it should be just internal behaviour without needing to change and function/method signatures. We already have a mima check that will verify if there is a binary breaking change. Regarding adding the configuration setting, this is fine as long as its released in a version with a bumped minor version. |
| @InternalApi private[s3] case object HeadObject extends S3Request | ||
| @InternalApi private[s3] case object GetObject extends S3Request { | ||
|
|
||
| override def allowedHeaders: Set[String] = Set( |
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'll add links to where in the docs I sourced this from
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'll also double check these when I move this out of draft
| bucket: String, | ||
| method: HttpMethod, | ||
| httpRequest: (HttpMethod, S3Settings) => HttpRequest, | ||
| headers: Seq[HttpHeader], |
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.
Oddly it seems this was unused
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 I noticed this as well, if you want to fix this I would prefer to put it in a separate PR so we don't mix this together (its easier to bisect/revert changes if they are in their own PR's/commits)
|
I've updated the PR with something more concrete in terms of implementation. I still need to add tests and docs, but wanted to get this out there for some early feedback about the strategy. If the approach is good I can add tests and move this out of draft for a more detailed and formal review |
|
@mdedetrich / @pjfanning - turns out the only errors when running If the general structure is okay - I'll write tests in the next day or two, just would like a rough 👍 before investing more time into this approach |
Currently this is a minimal change to demonstrate the issue so that the strategy can be discussed before addressed.
fixes #1245