Skip to content

Conversation

@pgporada
Copy link
Member

@pgporada pgporada commented Sep 6, 2023

Return an error to the operator if the supplied bucket name contains a scheme e.g. s3://bucketname, whatever://bucketname, http://bucketname, etc. The aws-sdk-go s3 service examples show the bucket name without the scheme. This change does not enforce that a bucket is properly named according to the s3 docs nor do I think it should. Instead that work should be left to the aws-sdk-go. This is just a nice ease of use improvement for myself because I didn't know what an appropriate bucket name was.

Co-authored-by: Samantha <[email protected]>
@pgporada pgporada changed the title Strip the s3:// protocol from the bucket name if it was passed in Error if bucket name contains scheme Sep 6, 2023
@pgporada pgporada requested review from a team and beautifulentropy September 6, 2023 21:26
*s3prefix = *logURL
}

_, err := url.ParseRequestURI(*s3bucket)
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the documentation for ParseRequestURI it doesn't seem to say it will reject absolute URIs (starting with a scheme). It actually seems to say the opposite - that it will accept them. Does this definitely work?

Copy link
Member Author

@pgporada pgporada Sep 11, 2023

Choose a reason for hiding this comment

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

From my manual testing, yes it works.

$ go run . -log-url https://oak.ct.letsencrypt.org/2023 -tile-size 256 -s3-bucket s3://whatever
2023/09/11 14:36:11 scheme provided for s3-bucket, but should not be
exit status 1

$ go run . -log-url https://oak.ct.letsencrypt.org/2023 -tile-size 256 -s3-bucket whoops://hasotherscheme
2023/09/11 14:36:34 scheme provided for s3-bucket, but should not be
exit status 1

# As expected, runs ctile instead of erroring out
$ go run . -log-url https://oak.ct.letsencrypt.org/2023 -tile-size 256 -s3-bucket noscheme
^Csignal: interrupt

What I'm ultimately relying on using url.ParseRequestURI is that the call to getScheme returns nil, because if it does there's a good chance that a scheme was found and I can return an error to the ctile user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants