fork of go-git with some jj specific features

plumbing: transport/file, replace os/exec with golang.org/x/sys/execabs to improve path security

Changed files
+12 -9
plumbing
transport
file
+1
go.mod
··· 21 21 github.com/xanzy/ssh-agent v0.3.0 22 22 golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 23 23 golang.org/x/net v0.0.0-20210326060303-6b1517762897 24 + golang.org/x/sys v0.0.0-20210415045647-66c3f260301c // indirect 24 25 golang.org/x/text v0.3.3 25 26 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c 26 27 gopkg.in/warnings.v0 v0.1.2 // indirect
+2
go.sum
··· 101 101 golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 102 102 golang.org/x/sys v0.0.0-20210324051608-47abb6519492 h1:Paq34FxTluEPvVyayQqMPgHm+vTOrIifmcYxFBx9TLg= 103 103 golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 104 + golang.org/x/sys v0.0.0-20210415045647-66c3f260301c h1:6L+uOeS3OQt/f4eFHXZcTxeZrGCuz+CLElgEBjbcTA4= 105 + golang.org/x/sys v0.0.0-20210415045647-66c3f260301c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 104 106 golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= 105 107 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 106 108 golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
+9 -9
plumbing/transport/file/client.go
··· 6 6 "errors" 7 7 "io" 8 8 "os" 9 - "os/exec" 10 9 "path/filepath" 11 10 "strings" 12 11 13 12 "github.com/go-git/go-git/v5/plumbing/transport" 14 13 "github.com/go-git/go-git/v5/plumbing/transport/internal/common" 14 + "golang.org/x/sys/execabs" 15 15 ) 16 16 17 17 // DefaultClient is the default local client. ··· 36 36 37 37 func prefixExecPath(cmd string) (string, error) { 38 38 // Use `git --exec-path` to find the exec path. 39 - execCmd := exec.Command("git", "--exec-path") 39 + execCmd := execabs.Command("git", "--exec-path") 40 40 41 41 stdout, err := execCmd.StdoutPipe() 42 42 if err != nil { ··· 54 54 return "", err 55 55 } 56 56 if isPrefix { 57 - return "", errors.New("Couldn't read exec-path line all at once") 57 + return "", errors.New("couldn't read exec-path line all at once") 58 58 } 59 59 60 60 err = execCmd.Wait() ··· 66 66 cmd = filepath.Join(execPath, cmd) 67 67 68 68 // Make sure it actually exists. 69 - _, err = exec.LookPath(cmd) 69 + _, err = execabs.LookPath(cmd) 70 70 if err != nil { 71 71 return "", err 72 72 } ··· 83 83 cmd = r.ReceivePackBin 84 84 } 85 85 86 - _, err := exec.LookPath(cmd) 86 + _, err := execabs.LookPath(cmd) 87 87 if err != nil { 88 - if e, ok := err.(*exec.Error); ok && e.Err == exec.ErrNotFound { 88 + if e, ok := err.(*execabs.Error); ok && e.Err == execabs.ErrNotFound { 89 89 cmd, err = prefixExecPath(cmd) 90 90 if err != nil { 91 91 return nil, err ··· 95 95 } 96 96 } 97 97 98 - return &command{cmd: exec.Command(cmd, ep.Path)}, nil 98 + return &command{cmd: execabs.Command(cmd, ep.Path)}, nil 99 99 } 100 100 101 101 type command struct { 102 - cmd *exec.Cmd 102 + cmd *execabs.Cmd 103 103 stderrCloser io.Closer 104 104 closed bool 105 105 } ··· 148 148 } 149 149 150 150 // When a repository does not exist, the command exits with code 128. 151 - if _, ok := err.(*exec.ExitError); ok { 151 + if _, ok := err.(*execabs.ExitError); ok { 152 152 return nil 153 153 } 154 154