summaryrefslogtreecommitdiff
path: root/cli/flags.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/flags.rs')
-rw-r--r--cli/flags.rs54
1 files changed, 34 insertions, 20 deletions
diff --git a/cli/flags.rs b/cli/flags.rs
index 086b20e10..f42dd771c 100644
--- a/cli/flags.rs
+++ b/cli/flags.rs
@@ -133,7 +133,7 @@ pub struct Flags {
pub allow_env: Option<Vec<String>>,
pub allow_hrtime: bool,
pub allow_net: Option<Vec<String>>,
- pub allow_plugin: bool,
+ pub allow_ffi: Option<Vec<String>>,
pub allow_read: Option<Vec<PathBuf>>,
pub allow_run: Option<Vec<String>>,
pub allow_write: Option<Vec<PathBuf>>,
@@ -235,8 +235,15 @@ impl Flags {
_ => {}
}
- if self.allow_plugin {
- args.push("--allow-plugin".to_string());
+ match &self.allow_ffi {
+ Some(ffi_allowlist) if ffi_allowlist.is_empty() => {
+ args.push("--allow-ffi".to_string());
+ }
+ Some(ffi_allowlist) => {
+ let s = format!("--allow-ffi={}", ffi_allowlist.join(","));
+ args.push(s);
+ }
+ _ => {}
}
if self.allow_hrtime {
@@ -253,7 +260,7 @@ impl From<Flags> for PermissionsOptions {
allow_env: flags.allow_env,
allow_hrtime: flags.allow_hrtime,
allow_net: flags.allow_net,
- allow_plugin: flags.allow_plugin,
+ allow_ffi: flags.allow_ffi,
allow_read: flags.allow_read,
allow_run: flags.allow_run,
allow_write: flags.allow_write,
@@ -1228,9 +1235,13 @@ fn permission_args<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
.help("Allow running subprocesses"),
)
.arg(
- Arg::with_name("allow-plugin")
- .long("allow-plugin")
- .help("Allow loading plugins"),
+ Arg::with_name("allow-ffi")
+ .long("allow-ffi")
+ .min_values(0)
+ .takes_value(true)
+ .use_delimiter(true)
+ .require_equals(true)
+ .help("Allow loading dynamic libraries"),
)
.arg(
Arg::with_name("allow-hrtime")
@@ -1577,7 +1588,7 @@ fn eval_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
flags.allow_run = Some(vec![]);
flags.allow_read = Some(vec![]);
flags.allow_write = Some(vec![]);
- flags.allow_plugin = true;
+ flags.allow_ffi = Some(vec![]);
flags.allow_hrtime = true;
// TODO(@satyarohith): remove this flag in 2.0.
let as_typescript = matches.is_present("ts");
@@ -1696,7 +1707,7 @@ fn repl_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
flags.allow_run = Some(vec![]);
flags.allow_read = Some(vec![]);
flags.allow_write = Some(vec![]);
- flags.allow_plugin = true;
+ flags.allow_ffi = Some(vec![]);
flags.allow_hrtime = true;
}
@@ -1876,9 +1887,12 @@ fn permission_args_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
debug!("run allowlist: {:#?}", &flags.allow_run);
}
- if matches.is_present("allow-plugin") {
- flags.allow_plugin = true;
+ if let Some(ffi_wl) = matches.values_of("allow-ffi") {
+ let ffi_allowlist: Vec<String> = ffi_wl.map(ToString::to_string).collect();
+ flags.allow_ffi = Some(ffi_allowlist);
+ debug!("ffi allowlist: {:#?}", &flags.allow_ffi);
}
+
if matches.is_present("allow-hrtime") {
flags.allow_hrtime = true;
}
@@ -1888,7 +1902,7 @@ fn permission_args_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
flags.allow_net = Some(vec![]);
flags.allow_run = Some(vec![]);
flags.allow_write = Some(vec![]);
- flags.allow_plugin = true;
+ flags.allow_ffi = Some(vec![]);
flags.allow_hrtime = true;
}
if matches.is_present("prompt") {
@@ -2227,7 +2241,7 @@ mod tests {
allow_run: Some(vec![]),
allow_read: Some(vec![]),
allow_write: Some(vec![]),
- allow_plugin: true,
+ allow_ffi: Some(vec![]),
allow_hrtime: true,
..Flags::default()
}
@@ -2564,7 +2578,7 @@ mod tests {
allow_run: Some(vec![]),
allow_read: Some(vec![]),
allow_write: Some(vec![]),
- allow_plugin: true,
+ allow_ffi: Some(vec![]),
allow_hrtime: true,
..Flags::default()
}
@@ -2587,7 +2601,7 @@ mod tests {
allow_run: Some(vec![]),
allow_read: Some(vec![]),
allow_write: Some(vec![]),
- allow_plugin: true,
+ allow_ffi: Some(vec![]),
allow_hrtime: true,
..Flags::default()
}
@@ -2611,7 +2625,7 @@ mod tests {
allow_run: Some(vec![]),
allow_read: Some(vec![]),
allow_write: Some(vec![]),
- allow_plugin: true,
+ allow_ffi: Some(vec![]),
allow_hrtime: true,
..Flags::default()
}
@@ -2648,7 +2662,7 @@ mod tests {
allow_run: Some(vec![]),
allow_read: Some(vec![]),
allow_write: Some(vec![]),
- allow_plugin: true,
+ allow_ffi: Some(vec![]),
allow_hrtime: true,
..Flags::default()
}
@@ -2678,7 +2692,7 @@ mod tests {
allow_run: Some(vec![]),
allow_read: Some(vec![]),
allow_write: Some(vec![]),
- allow_plugin: true,
+ allow_ffi: Some(vec![]),
allow_hrtime: true,
..Flags::default()
}
@@ -2698,7 +2712,7 @@ mod tests {
allow_run: Some(vec![]),
allow_read: Some(vec![]),
allow_write: Some(vec![]),
- allow_plugin: true,
+ allow_ffi: Some(vec![]),
allow_hrtime: true,
..Flags::default()
}
@@ -2732,7 +2746,7 @@ mod tests {
allow_run: Some(vec![]),
allow_read: Some(vec![]),
allow_write: Some(vec![]),
- allow_plugin: true,
+ allow_ffi: Some(vec![]),
allow_hrtime: true,
..Flags::default()
}