-
Notifications
You must be signed in to change notification settings - Fork 52
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 Validation Domain for login command #271
base: main
Are you sure you want to change the base?
Conversation
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.
What happens for those use cases:
- subdomain with prot -> subdomain.domain.com:port
- ip -> 127.0.0.1 and 127.0.0.1:8080
- top level domain -> registry.com
Hi @Vad1mo, the validation method allow these cases:
The port cannot be less than 0 or greater than 65535 and it validates each label in the domain name for correctness. |
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.
❯ ./harbor-dev login
┃ Server
┃ Server address eg. demo.goharbor.io
┃ > https://127.0.0.4:50
User Name
> lsadkjf
Password
>
Name of Credential
Name of credential to be stored in the harbor config file.
> [email protected]
* invalid domain format: too many colons
the above is a valid domain
TIP
@Standing-Man, Instead of checking if the domain is valid. check only if its invalid by adding only these rules
Incorrect Domain Names:
http:// (missing domain)
https:// (missing domain)
http://example (missing TLD, not valid)
http://127.0.0.256 (invalid IP, exceeds valid octet range)
http://my_site.local (invalid local domain, underscores are not allowed in domain names)
https://example..com (double period, invalid syntax)
https://.example.com (leading dot in the domain, invalid)
http://-example.com/ (hyphen at the start, invalid)
https://example.c (single character TLD, invalid)
http://192.168.0.999 (invalid IP, octet exceeds range)
Domain Names with Special Characters (Not Valid)
http://example (missing TLD, not valid)
Signed-off-by: Alan Tang <[email protected]>
…0.0 (goharbor#189) Bumps [github.com/charmbracelet/bubbles](https://github.com/charmbracelet/bubbles) from 0.18.0 to 0.20.0. - [Release notes](https://github.com/charmbracelet/bubbles/releases) - [Changelog](https://github.com/charmbracelet/bubbles/blob/master/.goreleaser.yml) - [Commits](charmbracelet/bubbles@v0.18.0...v0.20.0) --- updated-dependencies: - dependency-name: github.com/charmbracelet/bubbles dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: Alan Tang <[email protected]>
Signed-off-by: Alan Tang <[email protected]>
Signed-off-by: Alan Tang <[email protected]>
Signed-off-by: Alan Tang <[email protected]>
27e26e4
to
d6daef3
Compare
Signed-off-by: Alan Tang <[email protected]>
Hi @bupd, i'm confused about issue #297 and how to reproduce this issue.
or just
Anyway, i added more restrictions to validate server address and you can try to check if issue #297 solved. |
@Standing-Man server address with leading slash result in failed login. We should fix it. |
@@ -39,6 +41,124 @@ func FormatUrl(url string) string { | |||
return url | |||
} | |||
|
|||
// ValidateDomain validates subdomain, IP, or top-level domain formats | |||
func ValidateDomain(domain string) error { | |||
url := FormatUrl(domain) |
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.
In FormatUrl function. I would suggest adding the removal of leading slash.
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.
fixed #269.
Add the Validation function