diff options
author | Dmitry Sharshakov <sh7dm@outlook.com> | 2019-02-08 23:59:38 +0300 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-02-08 15:59:38 -0500 |
commit | 9ab03389f047e5520c184b9fce4cd5fb2e4804bd (patch) | |
tree | c1b3295aa6788595e4b73d28aeba0b8fdc8f3205 /src/flags.rs | |
parent | 3abaf9edb6877c328402b94fa0bcb6a9e0bbe86d (diff) |
Add --allow-read (#1689)
Co-authored-by: Greg Altman <g.s.altman@gmail.com>
Diffstat (limited to 'src/flags.rs')
-rw-r--r-- | src/flags.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/flags.rs b/src/flags.rs index d68bb5e09..a680c8aa1 100644 --- a/src/flags.rs +++ b/src/flags.rs @@ -23,6 +23,7 @@ pub struct DenoFlags { pub version: bool, pub reload: bool, pub recompile: bool, + pub allow_read: bool, pub allow_write: bool, pub allow_net: bool, pub allow_env: bool, @@ -89,6 +90,9 @@ fn set_recognized_flags( if matches.opt_present("recompile") { flags.recompile = true; } + if matches.opt_present("allow-read") { + flags.allow_read = true; + } if matches.opt_present("allow-write") { flags.allow_write = true; } @@ -102,9 +106,11 @@ fn set_recognized_flags( flags.allow_run = true; } if matches.opt_present("allow-all") { + flags.allow_read = true; flags.allow_env = true; flags.allow_net = true; flags.allow_run = true; + flags.allow_read = true; flags.allow_write = true; } if matches.opt_present("types") { @@ -142,6 +148,7 @@ pub fn set_flags( // TODO(kevinkassimo): v8_set_flags intercepts '-help' with single '-' // Resolve that and then uncomment line below (enabling Go style -long-flag) // opts.long_only(true); + opts.optflag("", "allow-read", "Allow file system read access."); opts.optflag("", "allow-write", "Allow file system write access."); opts.optflag("", "allow-net", "Allow network access."); opts.optflag("", "allow-env", "Allow environment access."); @@ -262,12 +269,27 @@ fn test_set_flags_7() { allow_net: true, allow_env: true, allow_run: true, + allow_read: true, allow_write: true, ..DenoFlags::default() } ) } +#[test] +fn test_set_flags_8() { + let (flags, rest, _) = + set_flags(svec!["deno", "gist.ts", "--allow-read"]).unwrap(); + assert_eq!(rest, svec!["deno", "gist.ts"]); + assert_eq!( + flags, + DenoFlags { + allow_read: true, + ..DenoFlags::default() + } + ) +} + // Returns args passed to V8, followed by args passed to JS fn v8_set_flags_preprocess(args: Vec<String>) -> (Vec<String>, Vec<String>) { let (rest, mut v8_args) = |