Description
The harbor ldap ping command currently lacks proper input validation for certain flags before invoking the API.
Specifically:
- The
--ldap-url flag is not normalized or validated using utils.FormatUrl() / utils.ValidateURL().
- The
--ldap-scope flag accepts any integer value, even though only:
0 (base)
1 (one level)
2 (subtree)
are valid.
This results in invalid inputs being passed to the API, causing delayed or unclear errors instead of immediate CLI validation feedback.
Steps to Reproduce
- Run the command:
harbor ldap ping --ldap-url invalid_url --ldap-scope 999
Observed Behavior
- The command accepts an invalid URL.
- The command accepts an out-of-range scope value (
999).
- The request is sent to the API without validation.
Expected Behavior
- Invalid
--ldap-url should be normalized and validated using utils.FormatUrl() / utils.ValidateURL(), and rejected early if invalid.
--ldap-scope should only accept values 0, 1, or 2.
- The CLI should return clear, immediate error messages before making the API call.
Actual Behavior
- Invalid URL is passed directly to the API without normalization/validation.
- Any integer value for
--ldap-scope is accepted without bounds checking.
- Errors occur later at the API level instead of at the CLI level.
Additional Context
This behavior is inconsistent with other CLI commands that normalize URLs using utils.FormatUrl() before validation.
Similar issues were addressed in:
- URL normalization fixes (e.g., webhook commands)
- Input validation improvements in other CLI commands
Description
The
harbor ldap pingcommand currently lacks proper input validation for certain flags before invoking the API.Specifically:
--ldap-urlflag is not normalized or validated usingutils.FormatUrl()/utils.ValidateURL().--ldap-scopeflag accepts any integer value, even though only:0(base)1(one level)2(subtree)are valid.
This results in invalid inputs being passed to the API, causing delayed or unclear errors instead of immediate CLI validation feedback.
Steps to Reproduce
Observed Behavior
999).Expected Behavior
--ldap-urlshould be normalized and validated usingutils.FormatUrl()/utils.ValidateURL(), and rejected early if invalid.--ldap-scopeshould only accept values0,1, or2.Actual Behavior
--ldap-scopeis accepted without bounds checking.Additional Context
This behavior is inconsistent with other CLI commands that normalize URLs using
utils.FormatUrl()before validation.Similar issues were addressed in: