Skip to content

[bug]: CLI validation missing: ldap ping command lacks URL normalization and scope bounds checking #803

@PrasunaEnumarthy

Description

@PrasunaEnumarthy

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

  1. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions