Add flag to ignore env requests #27520
quentinadam
started this conversation in
General
Replies: 1 comment 1 reply
-
|
Deno 2.6 added |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It is quite common for (npm-) packages to use environment variables to enable optional behaviour.
For example the
npm:esbuildpackage checks if the optionalESBUILD_BINARY_PATHenvironment variable is set and dependending on this value will either use that as the path to theesbuildbinary or will otherwise download theesbuildbinary fromnpm.Another example is the
npm:chalkpackage which has vendored in the code from thenpm:supports-colorpackage which checks a lot of optional environment variables likeFORCE_COLOR,TERM,CI,TERM_PROGRAMorCOLORTERMto name a few.When running Deno code that (directly or indirectly) depends on such packages that check optional environment variables, there is currently no way to run this code successfully without supplying an
--allowflag such as--allow-all,--allow-envor--allow-env=ESBUILD_BINARY_PATHfor example.In security sensitive contexts, it may not be desirable to add an
--allowflag. I would suggest adding an--ignore-envflag that would silently ignore any access to environment variables (if access was not explicitly allowed with an--allowflag), without requesting permissions or throwing an error, and that would for example returnundefinedfor any call toDeno.env.getas if the environment variable was not set.Optionally this flag would support adding specific environment variable names that should be ignored, like for example
--ignore-env=ESBUILD_BINARY_PATH,FORCE_COLOR.Beta Was this translation helpful? Give feedback.
All reactions