summaryrefslogtreecommitdiff
path: root/cli/args
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-09-27 12:49:43 -0400
committerGitHub <noreply@github.com>2024-09-27 16:49:43 +0000
commita8d1ab52761516b7f9b6069d6e433254794ed48c (patch)
treeac013b9660c254746cf13ebaed7617ea64520c42 /cli/args
parent0f617be84a8e9edf73803210c24af43f729a97de (diff)
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
Diffstat (limited to 'cli/args')
-rw-r--r--cli/args/flags.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs
index 4e151d7d9..9938a0955 100644
--- a/cli/args/flags.rs
+++ b/cli/args/flags.rs
@@ -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());
+ }
+ }
}