-
-
Notifications
You must be signed in to change notification settings - Fork 707
[management] Extend nameserver match domain validation #3864
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
Conversation
Signed-off-by: bcmmbaga <[email protected]>
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.
Pull Request Overview
This PR refactors domain validation to support single-label domains, top-level domains (prefixed with “.”), and wildcard domains, and updates tests accordingly.
- validateDomain now handles TLDs and
*.
-wildcards and removes the two-label minimum - Introduced
maxLabelLen
,invalidDomainName
, and adomainPattern
regex (currently unused) - Added new test cases for single-label, TLD, and wildcard domains in
nameserver_test.go
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
management/server/nameserver.go | Extended validateDomain for TLDs & wildcards; added constants |
management/server/nameserver_test.go | Added tests for single-label, .com , and *.example ; renamed cases |
Comments suppressed due to low confidence (4)
management/server/nameserver.go:6
- The
regexp
import is no longer used (thedomainPattern
regex isn’t referenced). Consider removing the import and the unuseddomainPattern
constant to keep the code clean.
"regexp"
management/server/nameserver.go:23
- The
domainPattern
constant is defined but never used. Either integrate it intovalidateDomain
or remove it to prevent confusion.
domainPattern = `^(?i)[\.*a-z0-9]+([\-\.]{1}[a-z0-9]+)*[*.a-z]{1,}$`
management/server/nameserver_test.go:921
- There’s no test case covering the behavior of a single-label domain without a dot or wildcard (e.g., "com"). Add a test to assert whether such domains should pass or fail.
// removed test for single-label "com"
management/server/nameserver.go:338
- The original check enforcing a minimum of two labels for non-TLD domains was removed, so single-label domains like "com" will now be accepted. Verify whether this change matches the intended validation rules.
if !valid {
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
3d89cd4
to
3e3268d
Compare
|
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.
Pull Request Overview
This PR refactors domain validation logic and extends test coverage for various domain formats.
- Removed the minimum label count check and centralized the error return in
validateDomain
. - Updated (but currently unused)
domainPattern
regex for domain matching. - Expanded
TestValidateDomain
with new scenarios (single-label, trailing dot, wildcard, leading dot, dot-only).
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
management/server/nameserver.go | Refactored validateDomain , added invalidDomainName var, updated domainPattern |
management/server/nameserver_test.go | Extended and reordered test cases in TestValidateDomain |
Comments suppressed due to low confidence (2)
management/server/nameserver.go:23
- [nitpick] Rename
invalidDomainName
toErrInvalidDomainName
to follow Go conventions for error variable names.
var invalidDomainName = errors.New("invalid domain name")
management/server/nameserver_test.go:908
- The test expects
example.
to pass, butdns.IsDomainName
may reject trailing dots; verify the intention or adjust the test to match the actual validation behavior.
domain: "example.",
Describe your changes
Issue ticket number and link
Closes #2021
Stack
Checklist