Skip to content

Commit

Permalink
Refactor: Now http_proxy env variable set only for curl command not f…
Browse files Browse the repository at this point in the history
…or entire event generator

Signed-off-by: GLVS Kiriti <glvskiriti2003369@gmail.com>
  • Loading branch information
GLVSKiriti authored and poiana committed Apr 3, 2024
1 parent 8e60661 commit 545c1f4
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions events/syscall/program_run_with_disallowed_http_proxy_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,13 @@ import (

var _ = events.Register(
ProgramRunWithDisallowedHttpProxyEnv,
// events.WithDisabled(), // this rules is not included in falco_rules.yaml (stable rules), so disable the action
events.WithDisabled(), // this rules is not included in falco_rules.yaml (stable rules), so disable the action
)

func ProgramRunWithDisallowedHttpProxyEnv(h events.Helper) error {
// Get the current value of HTTP_PROXY environment variable
originalHTTPProxy := os.Getenv("HTTP_PROXY")

// Modify HTTP_PROXY environment variable
os.Setenv("HTTP_PROXY", "http://my.http.proxy.com ")

// Ensure the original HTTP_PROXY value is reverted even if an error occurs
defer os.Setenv("HTTP_PROXY", originalHTTPProxy)

h.Log().Info("executing curl or wget with disallowed HTTP_PROXY environment variable")
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")
return cmd.Run()
}

0 comments on commit 545c1f4

Please sign in to comment.