-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(permission): support suffix wildcards in
--allow-env
flag (#25255
) This commit adds support for suffix wildcard for `--allow-env` flag. Specifying flag like `--allow-env=DENO_*` will enable access to all environmental variables starting with `DENO_*`. Closes #24847 --------- Co-authored-by: Bartek Iwańczuk <[email protected]> Co-authored-by: David Sherret <[email protected]>
- Loading branch information
1 parent
56f3162
commit b729bf0
Showing
7 changed files
with
250 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
tests/specs/permission/process_env_permissions/__test__.jsonc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"tempDir": true, | ||
"tests": { | ||
"deno_env_wildcard_tests": { | ||
"envs": { | ||
"MYAPP_HELLO": "Hello\tworld,", | ||
"MYAPP_GOODBYE": "farewell", | ||
"OTHER_VAR": "ignore" | ||
}, | ||
"steps": [ | ||
{ | ||
"args": "run --allow-env=MYAPP_* main.js", | ||
"output": "Hello\tworld,\nfarewell\ndone\n" | ||
}, | ||
{ | ||
"args": "run --allow-env main.js", | ||
"output": "Hello\tworld,\nfarewell\ndone\n" | ||
}, | ||
{ | ||
"args": "run --allow-env=MYAPP_HELLO,MYAPP_GOODBYE,MYAPP_TEST,MYAPP_DONE main.js", | ||
"output": "Hello\tworld,\nfarewell\ndone\n" | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
console.log(Deno.env.get("MYAPP_HELLO")); | ||
console.log(Deno.env.get("MYAPP_GOODBYE")); | ||
Deno.env.set("MYAPP_TEST", "done"); | ||
Deno.env.set("MYAPP_DONE", "done"); | ||
console.log(Deno.env.get("MYAPP_DONE")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"envs": { | ||
"DENO_HELLO": "hello", | ||
"DENO_BYE": "bye", | ||
"AWS_HELLO": "aws" | ||
}, | ||
"args": "run --allow-env --allow-read --unstable-worker-options main.js", | ||
"output": "main.out", | ||
"exitCode": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
console.log("main1", Deno.env.get("DENO_HELLO")); | ||
console.log("main2", Deno.env.get("DENO_BYE")); | ||
console.log("main3", Deno.env.get("AWS_HELLO")); | ||
|
||
new Worker(import.meta.resolve("./worker.js"), { | ||
type: "module", | ||
deno: { | ||
permissions: { | ||
env: ["DENO_*"], | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
main1 hello | ||
main2 bye | ||
main3 aws | ||
worker1 hello | ||
worker2 bye | ||
error: Uncaught (in worker "") (in promise) NotCapable: Requires env access to "AWS_HELLO", run again with the --allow-env flag | ||
console.log("worker3", Deno.env.get("AWS_HELLO")); | ||
^ | ||
[WILDCARD] | ||
error: Uncaught (in promise) Error: Unhandled error in child worker. | ||
[WILDCARD] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
console.log("worker1", Deno.env.get("DENO_HELLO")); | ||
console.log("worker2", Deno.env.get("DENO_BYE")); | ||
console.log("worker3", Deno.env.get("AWS_HELLO")); |