-
Notifications
You must be signed in to change notification settings - Fork 4
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
Error if bucket name contains scheme #20
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Samantha <[email protected]>
@@ -469,6 +469,11 @@ func main() { | |||
*s3prefix = *logURL | |||
} | |||
|
|||
_, err := url.ParseRequestURI(*s3bucket) |
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.
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?
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 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.
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.