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

Error if bucket name contains scheme #20

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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.

main.go Outdated Show resolved Hide resolved
Co-authored-by: Samantha <[email protected]>
main.go Outdated Show resolved Hide resolved
@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 beautifulentropy and a team September 6, 2023 21:26
@@ -469,6 +469,11 @@ func main() {
*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.

3 participants