mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
fix(init): route --remote through validated git.SetOrAddRemote
The CLI addRemote ran a raw "git remote add origin <url>" with the user-supplied URL, sharing the argv flag-smuggling risk just fixed in the git package. Delegate to git.SetOrAddRemote so the --remote flag goes through the same leading-dash rejection and "--" terminator, removing the duplicated exec path.
This commit is contained in:
@@ -1214,9 +1214,10 @@ func setupGitRemote(sourcePath, remoteURL string, dryRun bool) bool {
|
||||
}
|
||||
|
||||
func addRemote(sourcePath, remoteURL string) bool {
|
||||
cmd := exec.Command("git", "remote", "add", "origin", remoteURL)
|
||||
cmd.Dir = sourcePath
|
||||
if err := cmd.Run(); err != nil {
|
||||
// SetOrAddRemote validates the URL (rejecting flag-smuggling values that
|
||||
// begin with "-") and passes "--" before positional args. setupGitRemote
|
||||
// has already confirmed origin is absent, so this takes the add path.
|
||||
if err := gitops.SetOrAddRemote(sourcePath, remoteURL); err != nil {
|
||||
ui.Warning("Failed to add remote: %v", err)
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user