@@ -27,7 +27,6 @@ import (
2727 "sync"
2828
2929 "github.com/bep/logg"
30- "github.com/cli/safeexec"
3130 "github.com/gohugoio/hugo/common/loggers"
3231 "github.com/gohugoio/hugo/common/maps"
3332 "github.com/gohugoio/hugo/config"
@@ -113,18 +112,6 @@ func IsNotFound(err error) bool {
113112 return errors .As (err , & notFoundErr )
114113}
115114
116- // SafeCommand is a wrapper around os/exec Command which uses a LookPath
117- // implementation that does not search in current directory before looking in PATH.
118- // See https://github.com/cli/safeexec and the linked issues.
119- func SafeCommand (name string , arg ... string ) (* exec.Cmd , error ) {
120- bin , err := safeexec .LookPath (name )
121- if err != nil {
122- return nil , err
123- }
124-
125- return exec .Command (bin , arg ... ), nil
126- }
127-
128115// Exec enforces a security policy for commands run via os/exec.
129116type Exec struct {
130117 sc security.Config
@@ -197,7 +184,7 @@ func (e *Exec) Npx(name string, arg ...any) (Runner, error) {
197184 tryFuncs := map [binaryLocation ]tryFunc {
198185 binaryLocationNodeModules : func () func (... any ) (Runner , error ) {
199186 nodeBinFilename := filepath .Join (e .workingDir , nodeModulesBinPath , name )
200- _ , err := safeexec .LookPath (nodeBinFilename )
187+ _ , err := exec .LookPath (nodeBinFilename )
201188 if err != nil {
202189 return nil
203190 }
@@ -215,7 +202,7 @@ func (e *Exec) Npx(name string, arg ...any) (Runner, error) {
215202 }
216203 },
217204 binaryLocationPath : func () func (... any ) (Runner , error ) {
218- if _ , err := safeexec .LookPath (name ); err != nil {
205+ if _ , err := exec .LookPath (name ); err != nil {
219206 return nil
220207 }
221208 return func (arg2 ... any ) (Runner , error ) {
@@ -346,7 +333,7 @@ func (c *commandeer) command(arg ...any) (*cmdWrapper, error) {
346333 bin = c .fullyQualifiedName
347334 } else {
348335 var err error
349- bin , err = safeexec .LookPath (c .name )
336+ bin , err = exec .LookPath (c .name )
350337 if err != nil {
351338 return nil , & NotFoundError {
352339 name : c .name ,
@@ -384,7 +371,7 @@ func InPath(binaryName string) bool {
384371 if strings .Contains (binaryName , "/" ) {
385372 panic ("binary name should not contain any slash" )
386373 }
387- _ , err := safeexec .LookPath (binaryName )
374+ _ , err := exec .LookPath (binaryName )
388375 return err == nil
389376}
390377
@@ -394,7 +381,7 @@ func LookPath(binaryName string) string {
394381 if strings .Contains (binaryName , "/" ) {
395382 panic ("binary name should not contain any slash" )
396383 }
397- s , err := safeexec .LookPath (binaryName )
384+ s , err := exec .LookPath (binaryName )
398385 if err != nil {
399386 return ""
400387 }
0 commit comments