Skip to content

feat: add env helper function - #362

Closed
0xhackify wants to merge 1 commit into
projectdiscovery:mainfrom
0xhackify:feat/env-helper
Closed

0xhackify wants to merge 1 commit into
projectdiscovery:mainfrom
0xhackify:feat/env-helper

Conversation

@0xhackify

Copy link
Copy Markdown
Contributor

Closes #192

Adds an env(key, optionalDefault) helper that returns the value of an
environment variable, or the optional default when it is not set.

  • Uses os.LookupEnv, so a variable set to "" returns "" (not the default)
  • Added TestEnvDSLFunction, updated the signatures test and the README

Testing: go test -run TestEnvDSLFunction -v passes.
Note: TestDslExpressions has 4 pre-existing failures (gzip, zlib, zip,
deflate) on Go 1.27.3; they also fail on main without this change,
likely due to compress/flate output changes in newer Go versions.

Security note: since templates may come from third parties, nuclei may
want to gate this behind an opt-in flag (similar to -env-vars) to avoid
leaking secrets from the scanning machine.

@Mzack9999

Copy link
Copy Markdown
Member

Closing this. Putting env() in the default DSL helpers would let a template read the process environment, including API keys, and send those values out in a request. I do not want that in the default set. Happy to look again if it stays out of the helpers a template can call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add env helper function

2 participants