Repository navigation
fix(import-url): validate artifact URL scheme #560
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
Changes from 1 commit
1f31e44
2806c15
a64d332
871b27f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,7 +48,11 @@ func NewImportURLCommand(globalClientOpts *connectors.ClientOptions) *cobra.Comm | |
| mainArtifact := true | ||
| secret := "" | ||
|
|
||
| f, mainArtifact, secret = parseImportURLArg(f) | ||
| var err error | ||
| f, mainArtifact, secret, err = parseImportURLArg(f) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| // Try downloading the artifcat | ||
| msg, err := mc.DownloadArtifact(f, mainArtifact, secret) | ||
|
|
@@ -64,7 +68,15 @@ func NewImportURLCommand(globalClientOpts *connectors.ClientOptions) *cobra.Comm | |
| return importURLCmd | ||
| } | ||
|
|
||
| func parseImportURLArg(f string) (string, bool, string) { | ||
| func parseImportURLArg(f string) (string, bool, string, error) { | ||
| if !strings.HasPrefix(f, "https://") && !strings.HasPrefix(f, "http://") { | ||
| return "", false, "", errors.Wrapf( | ||
| errors.KindUsage, | ||
| "invalid artifact URL '%s': must start with http:// or https://", | ||
| f, | ||
| ) | ||
| } | ||
|
dipak0000812 marked this conversation as resolved.
Resolved
|
||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this way it gives to many responsibilities to this function.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I totally agree here. We can use that functionality to shift our validation much closer to the actual user input. |
||
| mainArtifact := true | ||
| secret := "" | ||
|
|
||
|
|
@@ -84,5 +96,5 @@ func parseImportURLArg(f string) (string, bool, string) { | |
| } | ||
| } | ||
| } | ||
| return f, mainArtifact, secret | ||
| return f, mainArtifact, secret, nil | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.