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

fix(webhook) Fix regexp #1176

Closed

Conversation

coffeecupjapan
Copy link

Thank you for reading my PR.

What?

According to kubernete's DNS validation code here, valid way to validate dns name should be

	dnsLabelFormat                 = `[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?`
	dnsSubdomainFormat             = fmt.Sprintf(`^%s(?:\.%s)*$`, dnsLabelFormat, dnsLabelFormat)
	validWindowsUserDomainDNSRegex = regexp.MustCompile(dnsSubdomainFormat)

I wonder we should remove _ / should add ending [a-zA-Z0-9] and more small fixes or not, but in this case I just add heading [a-zA-Z0-9] to prevent

`.somedns.com`
`-somedns.com`
`_somedns.com`

to be matched.

Or we can just imitate original kubernete code may be.

Any suggestions are welcomed. Thanks.

Copy link

netlify bot commented Aug 26, 2024

Deploy Preview for capsule-documentation canceled.

Name Link
🔨 Latest commit 4e3c5f9
🔍 Latest deploy log https://app.netlify.com/sites/capsule-documentation/deploys/66ccb7ebf5d5cb000849b363

@coffeecupjapan coffeecupjapan changed the title Fix regexp fix Fix regexp Aug 26, 2024
@coffeecupjapan coffeecupjapan changed the title fix Fix regexp fix(webhook) Fix regexp Aug 26, 2024
@prometherion
Copy link
Member

Hey @coffeecupjapan, thanks for your contribution, I really appreciate it!

In regard to regex, we don't have proper unit tests and your suggested regex could be potentially broken, as shown here for .somedns.com/clastix/capsule:v1.0.0.

This is definitely an edge case since it's broken: it would be great if we could have a regex that compiles only with a valid fully qualified container reference.

@coffeecupjapan
Copy link
Author

coffeecupjapan commented Aug 30, 2024

@prometherion
Thank you for your reply.

I want to confirm where this regex is broken.
For .somedns.com/clastix/capsule:v1.0.0 case registry group is not matched and code here just throws error, and I think this behavior is something expected.

Should registry for .somedns.com/clastix/capsule:v1.0.0 be valid?

Maybe I am wrong somehow, so I want to hear what I am wrong for this regexp.
Sorry for my lack of consideration.

Thank you.

@prometherion
Copy link
Member

No need to be sorry, @coffeecupjapan :)

Any enhancement or improvement here is highly welcome! As I said, I'm not the regex expert, if you think we could enhance it I'll be happy to test it and get it merged, otherwise, let's close this one to avoid having stale PR.

Just a friendly reminder, we also have a #capsule channel for direct interactions, happy to see you there!

@coffeecupjapan
Copy link
Author

@prometherion
Thank you!
Let us discuss this topic at Slack!

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.

2 participants