mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-02-25 18:55:28 -06:00
add secureexec file for getting around windows checking for a binary first in the current dir
This commit is contained in:
11
pkg/secureexec/secureexec_default.go
Normal file
11
pkg/secureexec/secureexec_default.go
Normal file
@@ -0,0 +1,11 @@
|
||||
// +build !windows
|
||||
|
||||
package secureexec
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func Command(name string, args ...string) *exec.Cmd {
|
||||
return exec.Command(name, args...)
|
||||
}
|
||||
30
pkg/secureexec/secureexec_windows.go
Normal file
30
pkg/secureexec/secureexec_windows.go
Normal file
@@ -0,0 +1,30 @@
|
||||
// +build windows
|
||||
|
||||
package secureexec
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
|
||||
"github.com/cli/safeexec"
|
||||
)
|
||||
|
||||
// calling exec.Command directly on a windows machine poses a security risk due to
|
||||
// the current directory being searched first before any directories in the PATH
|
||||
// variable, meaning you might clone a repo that contains a program called 'git'
|
||||
// which does something malicious when executed.
|
||||
|
||||
// see https://github.com/golang/go/issues/38736 for more context. We'll likely
|
||||
// be able to just throw out this code and switch to the official solution when it exists.
|
||||
|
||||
// I consider this a minor security concern because you're just as vulnerable if
|
||||
// you call `git status` from the command line directly but no harm in playing it
|
||||
// safe.
|
||||
|
||||
func Command(name string, args ...string) *exec.Cmd {
|
||||
bin, err := safeexec.LookPath(name)
|
||||
if err != nil {
|
||||
bin = name
|
||||
}
|
||||
|
||||
return exec.Command(bin, args...)
|
||||
}
|
||||
Reference in New Issue
Block a user