From d507f85b61b4722ab1a56b6e120b33a7a7e97eb5 Mon Sep 17 00:00:00 2001 From: GLVS Kiriti Date: Wed, 3 Apr 2024 13:44:45 +0530 Subject: [PATCH] Fix: First look whether curl exists or not Signed-off-by: GLVS Kiriti --- .../syscall/program_run_with_disallowed_http_proxy_env.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/events/syscall/program_run_with_disallowed_http_proxy_env.go b/events/syscall/program_run_with_disallowed_http_proxy_env.go index 4af51c30..73b73160 100644 --- a/events/syscall/program_run_with_disallowed_http_proxy_env.go +++ b/events/syscall/program_run_with_disallowed_http_proxy_env.go @@ -27,7 +27,12 @@ var _ = events.Register( ) func ProgramRunWithDisallowedHttpProxyEnv(h events.Helper) error { - cmd := exec.Command("curl", "http://example.com") + curl, err := exec.LookPath("curl") + if err != nil { + h.Log().Warnf("Curl is needed to launch this action") + return err + } + cmd := exec.Command(curl, "http://example.com") cmd.Env = os.Environ() cmd.Env = append(cmd.Env, "HTTP_PROXY=http://my.http.proxy.com ") h.Log().Info("executing curl or wget with disallowed HTTP_PROXY environment variable")