-
Notifications
You must be signed in to change notification settings - Fork 74
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
s3_bucket_name
: add length validation
#554
s3_bucket_name
: add length validation
#554
Conversation
rules/aws_s3_bucket_name_length.go
Outdated
} | ||
|
||
bucketNameMinLength := 3 | ||
bucketNameMaxLength := 63 |
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.
Can you avoid hardcoding this and find somewhere to reference it? AWS has a lot of schemas for their API that should specify this somewhere...
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.
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.
Yeah, it seems rather bad to hardcode, but I also haven't found somewhere to reference it from.
Seems like this could be added to the existing |
rules/aws_s3_bucket_name_length.go
Outdated
if len(name) < bucketNameMinLength || len(name) > bucketNameMaxLength { | ||
runner.EmitIssue( | ||
r, | ||
fmt.Sprintf(`Bucket name "%s" length must be within %d - %d character range`, name, bucketNameMinLength, bucketNameMaxLength), |
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.
fmt.Sprintf(`Bucket name "%s" length must be within %d - %d character range`, name, bucketNameMinLength, bucketNameMaxLength), | |
fmt.Sprintf("Bucket name %q must be between %d and %d characters", name, bucketNameMinLength, bucketNameMaxLength), |
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.
Nice. I've just commited it through rebasing.
I thought about it and I think it's probably the right thing to do; however, for what I've seen, the |
Right, so:
That would need to become optional
Then this can happen |
86f199a
to
1ff7feb
Compare
Yeah, that's right. I was hoping your feedback on this matter, if you agreed on using the same rule. I will work on it, then. |
1ff7feb
to
21b745f
Compare
2f6f2ed
to
86a8e3e
Compare
86a8e3e
to
c205007
Compare
Seems all right. Have you found anything about the min and max numbers from the API? Also, your opinion on this. The bucket name length should throw an Error severity, but that was not the case for the regex and prefix checks. |
Thanks, will review and respond within the next 1-2 weeks (traveling) |
We could work with this, maybe: Or: If you search it like this, a lot of them reference the min max bucket name size. Companies such as MinIO have this hardcoded: https://github.com/minio/minio-go/blob/v7.0.63/pkg/s3utils/utils.go#L356-L361 |
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.
Thanks for your patience!
s3_bucket_name
: add length validation
From this discussion.