mirror of
https://github.com/adnanh/webhook.git
synced 2025-05-22 21:32:32 +00:00
Produce warnings if unable to locate binary and if static parameters specified erroneously
This commit is contained in:
parent
d52d7bde1c
commit
1fc4445668
1 changed files with 15 additions and 1 deletions
16
webhook.go
16
webhook.go
|
@ -312,7 +312,21 @@ func hookHandler(w http.ResponseWriter, r *http.Request) {
|
|||
func handleHook(h *hook.Hook, headers, query, payload *map[string]interface{}, body *[]byte) (string, error) {
|
||||
var errors []error
|
||||
|
||||
cmd := exec.Command(h.ExecuteCommand)
|
||||
// check the command exists
|
||||
cmdPath, err := exec.LookPath(h.ExecuteCommand)
|
||||
if err != nil {
|
||||
log.Printf("unable to locate command: '%s'", h.ExecuteCommand)
|
||||
|
||||
// check if parameters specified in execute-command by mistake
|
||||
if strings.IndexByte(h.ExecuteCommand, ' ') != -1 {
|
||||
s := strings.Fields(h.ExecuteCommand)[0]
|
||||
log.Printf("use 'pass-arguments-to-command' to specify args for '%s'", s)
|
||||
}
|
||||
|
||||
return "", err
|
||||
}
|
||||
|
||||
cmd := exec.Command(cmdPath)
|
||||
cmd.Dir = h.CommandWorkingDirectory
|
||||
|
||||
cmd.Args, errors = h.ExtractCommandArguments(headers, query, payload)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue