Skip to content

Commit

Permalink
HTTP_PROXY env variable value is reverted to its original value after…
Browse files Browse the repository at this point in the history
… function return

Signed-off-by: GLVS Kiriti <[email protected]>
  • Loading branch information
GLVSKiriti authored and poiana committed Apr 3, 2024
1 parent 4ef79f5 commit 8e60661
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions events/syscall/program_run_with_disallowed_http_proxy_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,20 @@ 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 {
h.Log().Info("executing curl or wget with disallowed HTTP_PROXY environment variable")
// 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")

return cmd.Run()
Expand Down

0 comments on commit 8e60661

Please sign in to comment.