fix : add url validation to all commands#607
Conversation
|
@bupd can you please review this |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #607 +/- ##
=========================================
- Coverage 10.99% 7.26% -3.73%
=========================================
Files 173 260 +87
Lines 8671 12866 +4195
=========================================
- Hits 953 935 -18
- Misses 7612 11823 +4211
- Partials 106 108 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@bupd i have merged the main branch in this , can you please review again . |
fb81159 to
1be6b08
Compare
|
@NucleoFusion done with the changes |
|
@bupd @NucleoFusion any update on this? |
|
@Sypher845 If you could add to the description (and maybe even in a comment on the |
NucleoFusion
left a comment
There was a problem hiding this comment.
Seems like a simple PR. Just some clarification on what the Regex matches.
The Validations work as intended from my testing
95238a6 to
639ee5b
Compare
|
@NucleoFusion added the description and made the changes, PTAL |
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent confusing server-side failures by validating user-supplied URLs client-side (both in flag-driven commands and interactive TUI forms) before making Harbor API calls.
Changes:
- Added
utils.ValidateURL()checks in multiple commands when URL flags are provided. - Updated several interactive views to reject empty/whitespace input and to validate URLs consistently.
- Refactored some commands to return errors (
RunE) instead of logging and exiting, improving CLI error propagation.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/views/webhook/edit/view.go | Adds endpoint URL non-empty (trimmed) validation and URL format validation in the webhook edit TUI. |
| pkg/views/scanner/update/view.go | Adds trimmed non-empty validation and validates a normalized URL for scanner adapter URL input. |
| pkg/views/registry/update/view.go | Trims whitespace for provider/name/url inputs and validates registry URL (currently only validates normalized value). |
| pkg/views/registry/create/view.go | Replaces net/url parsing with utils.ValidateURL() for registry URL validation (currently only validates normalized value). |
| pkg/views/instance/create/view.go | Adds trimmed non-empty validation and validates a normalized endpoint URL (currently only validates normalized value). |
| pkg/utils/helper.go | Documents ValidateURL behavior (function used broadly for URL validation). |
| cmd/harbor/root/webhook/edit.go | Validates endpoint URL before calling api.UpdateWebhook in non-interactive mode. |
| cmd/harbor/root/scanner/update.go | Normalizes + validates --url before updating scanner registration. |
| cmd/harbor/root/scanner/create.go | Normalizes + validates --url before creating/pinging scanner in non-interactive mode. |
| cmd/harbor/root/registry/update.go | Converts to RunE, returns errors, and validates registry --url before update. |
| cmd/harbor/root/registry/create.go | Converts to RunE, returns errors, and validates registry --url before create. |
| cmd/harbor/root/login.go | Changes invalid server URL handling to return the raw validation error. |
| cmd/harbor/root/instance/create.go | Converts to RunE, returns errors, and validates instance endpoint URL before create. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Sypher845 <suyashpatil845@gmail.com>
Signed-off-by: Sypher845 <suyashpatil845@gmail.com>
639ee5b to
11131d9
Compare
|
@bupd done |
Fixes #606
Adds URL validation to commands that accept URL inputs (
instance create,registry create/update,scanner create/update,webhook edit).Changes:
utils.ValidateURL()checks before API callsValidateURL function
What it checks: