From d3fd9bddd9d5967729bed80f586524530e8c9f00 Mon Sep 17 00:00:00 2001 From: Fabrizio Destro <7031675+dexpota@users.noreply.github.com> Date: Sun, 25 Aug 2019 20:08:39 +0200 Subject: [PATCH] Fix issue with relative paths and command execution --- webhook.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/webhook.go b/webhook.go index 5d41077..8ce27d2 100644 --- a/webhook.go +++ b/webhook.go @@ -10,6 +10,7 @@ import ( "net/url" "os" "os/exec" + "path/filepath" "strings" "time" @@ -328,6 +329,13 @@ func handleHook(h *hook.Hook, rid string, headers, query, payload *map[string]in // check the command exists cmdPath, err := exec.LookPath(h.ExecuteCommand) + if err != nil { + // give a last chance, maybe is a relative path + relativeToCwd := filepath.Join(h.CommandWorkingDirectory, h.ExecuteCommand) + // check the command exists + cmdPath, err = exec.LookPath(relativeToCwd) + } + if err != nil { log.Printf("unable to locate command: '%s'", h.ExecuteCommand)