-
Notifications
You must be signed in to change notification settings - Fork 30
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
feat: add domain name validation #925
base: main
Are you sure you want to change the base?
Conversation
instance/conn_name.go
Outdated
@@ -27,6 +27,8 @@ var ( | |||
// Additionally, we have to support legacy "domain-scoped" projects | |||
// (e.g. "google.com:PROJECT") | |||
connNameRegex = regexp.MustCompile("([^:]+(:[^:]+)?):([^:]+):([^:]+)") | |||
// The domain name pattern in accordance with RFC 1035, RFC 1123 and RFC 2181. | |||
domainNameRegex = regexp.MustCompile("^[A-Za-z0-9-]{1,63}\\.[A-Za-z]{2,6}$") |
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.
This is just placeholder regex as same regex used in Java Connector will not compile in Go.
panic: regexp: Compile(`^(?=.{1,255}$)(?!-)[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}$`): error parsing regexp: invalid or unsupported Perl syntax: `(?=`
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.
Using this regex as of now: https://regex101.com/library/SEg6KL
To improve error handling and error messages returned to end user, we should
validate domain name prior to resolving it. This will allow for differentiating error
messages for invalid connection names vs failed DNS resolution.
Fixes #923