mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
fix(flags): --allow-all should conflict with lower permissions (#25909)
Using `--allow-all` with other `--allow-x` permission flags should cause an error since `--allow-all` is a superset of `--allow-x`. Closes #25901
This commit is contained in:
parent
0f617be84a
commit
a8d1ab5276
3 changed files with 35 additions and 0 deletions
|
@ -3603,6 +3603,14 @@ fn allow_all_arg() -> Arg {
|
|||
Arg::new("allow-all")
|
||||
.short('A')
|
||||
.long("allow-all")
|
||||
.conflicts_with("allow-read")
|
||||
.conflicts_with("allow-write")
|
||||
.conflicts_with("allow-net")
|
||||
.conflicts_with("allow-env")
|
||||
.conflicts_with("allow-run")
|
||||
.conflicts_with("allow-sys")
|
||||
.conflicts_with("allow-ffi")
|
||||
.conflicts_with("allow-import")
|
||||
.action(ArgAction::SetTrue)
|
||||
.help("Allow all permissions")
|
||||
}
|
||||
|
@ -11007,4 +11015,23 @@ Usage: deno repl [OPTIONS] [-- [ARGS]...]\n"
|
|||
);
|
||||
assert_eq!(parse("file:///example.com"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allow_all_conflicts_allow_perms() {
|
||||
let flags = [
|
||||
"--allow-read",
|
||||
"--allow-write",
|
||||
"--allow-net",
|
||||
"--allow-env",
|
||||
"--allow-run",
|
||||
"--allow-sys",
|
||||
"--allow-ffi",
|
||||
"--allow-import",
|
||||
];
|
||||
for flag in flags {
|
||||
let r =
|
||||
flags_from_vec(svec!["deno", "run", "--allow-all", flag, "foo.ts"]);
|
||||
assert!(r.is_err());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,11 @@
|
|||
"output": "run.out",
|
||||
"exitCode": 1
|
||||
},
|
||||
"run_allow_all": {
|
||||
"args": "run --quiet --allow-all success.ts",
|
||||
"output": "3\n",
|
||||
"exitCode": 0
|
||||
},
|
||||
"serve": {
|
||||
"args": "serve main.ts",
|
||||
"output": "serve.out",
|
||||
|
|
3
tests/specs/permission/allow_import/success.ts
Normal file
3
tests/specs/permission/allow_import/success.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
import { add } from "http://localhost:4545/add.ts";
|
||||
|
||||
console.log(add(1, 2));
|
Loading…
Reference in a new issue