summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/args/flags.rs44
-rw-r--r--cli/main.rs5
-rw-r--r--cli/tests/integration/run_tests.rs14
-rw-r--r--cli/tests/testdata/run/unsafe_proto/main.js5
-rw-r--r--cli/tests/testdata/run/unsafe_proto/main.out2
-rw-r--r--cli/tests/testdata/run/unsafe_proto/main_with_unsafe_proto_flag.out2
-rw-r--r--cli/tests/testdata/run/unsafe_proto/worker.js2
-rw-r--r--cli/worker.rs6
8 files changed, 39 insertions, 41 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs
index d1f6c153d..d7d51b374 100644
--- a/cli/args/flags.rs
+++ b/cli/args/flags.rs
@@ -844,45 +844,11 @@ pub fn flags_from_vec(args: Vec<String>) -> clap::error::Result<Flags> {
if matches.get_flag("unstable") {
flags.unstable = true;
}
- if matches.get_flag("unstable-broadcast-channel") {
- flags.unstable_features.push(
- deno_runtime::deno_broadcast_channel::UNSTABLE_FEATURE_NAME.to_string(),
- );
- }
- if matches.get_flag("unstable-ffi") {
- flags
- .unstable_features
- .push(deno_runtime::deno_ffi::UNSTABLE_FEATURE_NAME.to_string());
- }
- if matches.get_flag("unstable-fs") {
- flags
- .unstable_features
- .push(deno_runtime::deno_fs::UNSTABLE_FEATURE_NAME.to_string());
- }
- if matches.get_flag("unstable-http") {
- flags
- .unstable_features
- .push(deno_runtime::ops::http::UNSTABLE_FEATURE_NAME.to_string());
- }
- if matches.get_flag("unstable-kv") {
- flags
- .unstable_features
- .push(deno_runtime::deno_kv::UNSTABLE_FEATURE_NAME.to_string());
- }
- if matches.get_flag("unstable-net") {
- flags
- .unstable_features
- .push(deno_runtime::deno_net::UNSTABLE_FEATURE_NAME.to_string());
- }
- if matches.get_flag("unstable-worker-options") {
- flags
- .unstable_features
- .push(deno_runtime::ops::worker_host::UNSTABLE_FEATURE_NAME.to_string());
- }
- if matches.get_flag("unstable-cron") {
- flags
- .unstable_features
- .push(deno_runtime::deno_cron::UNSTABLE_FEATURE_NAME.to_string());
+
+ for (name, _, _) in crate::UNSTABLE_GRANULAR_FLAGS {
+ if matches.get_flag(&format!("unstable-{}", name)) {
+ flags.unstable_features.push(name.to_string());
+ }
}
flags.unstable_bare_node_builtins =
diff --git a/cli/main.rs b/cli/main.rs
index 1fa4ee851..94b59b9d6 100644
--- a/cli/main.rs
+++ b/cli/main.rs
@@ -310,6 +310,11 @@ pub(crate) static UNSTABLE_GRANULAR_FLAGS: &[(
"Enable unstable Deno.cron API",
8,
),
+ (
+ "unsafe-proto",
+ "Enable unsafe __proto__ support. This is a security risk.",
+ 9,
+ ),
];
pub(crate) fn unstable_exit_cb(_feature: &str, api_name: &str) {
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs
index 0ddedbdfb..4ac18cd50 100644
--- a/cli/tests/integration/run_tests.rs
+++ b/cli/tests/integration/run_tests.rs
@@ -4716,3 +4716,17 @@ itest!(workspaces_nested_member {
http_server: true,
exit_code: 1,
});
+
+itest!(unsafe_proto {
+ args: "run -A run/unsafe_proto/main.js",
+ output: "run/unsafe_proto/main.out",
+ http_server: false,
+ exit_code: 0,
+});
+
+itest!(unsafe_proto_flag {
+ args: "run -A --unstable-unsafe-proto run/unsafe_proto/main.js",
+ output: "run/unsafe_proto/main_with_unsafe_proto_flag.out",
+ http_server: false,
+ exit_code: 0,
+});
diff --git a/cli/tests/testdata/run/unsafe_proto/main.js b/cli/tests/testdata/run/unsafe_proto/main.js
new file mode 100644
index 000000000..eb95c55a0
--- /dev/null
+++ b/cli/tests/testdata/run/unsafe_proto/main.js
@@ -0,0 +1,5 @@
+console.log(Object.hasOwn(Object.prototype, "__proto__"));
+
+new Worker(import.meta.resolve("./worker.js"), {
+ type: "module",
+});
diff --git a/cli/tests/testdata/run/unsafe_proto/main.out b/cli/tests/testdata/run/unsafe_proto/main.out
new file mode 100644
index 000000000..4b095fd0f
--- /dev/null
+++ b/cli/tests/testdata/run/unsafe_proto/main.out
@@ -0,0 +1,2 @@
+false
+false
diff --git a/cli/tests/testdata/run/unsafe_proto/main_with_unsafe_proto_flag.out b/cli/tests/testdata/run/unsafe_proto/main_with_unsafe_proto_flag.out
new file mode 100644
index 000000000..bb101b641
--- /dev/null
+++ b/cli/tests/testdata/run/unsafe_proto/main_with_unsafe_proto_flag.out
@@ -0,0 +1,2 @@
+true
+true
diff --git a/cli/tests/testdata/run/unsafe_proto/worker.js b/cli/tests/testdata/run/unsafe_proto/worker.js
new file mode 100644
index 000000000..b22bc8713
--- /dev/null
+++ b/cli/tests/testdata/run/unsafe_proto/worker.js
@@ -0,0 +1,2 @@
+console.log(Object.hasOwn(Object.prototype, "__proto__"));
+close();
diff --git a/cli/worker.rs b/cli/worker.rs
index 361aad2ec..5be64e117 100644
--- a/cli/worker.rs
+++ b/cli/worker.rs
@@ -570,7 +570,8 @@ impl CliMainWorkerFactory {
// TODO(bartlomieju): this is cruft, update FeatureChecker to spit out
// list of enabled features.
let feature_checker = shared.feature_checker.clone();
- let mut unstable_features = Vec::with_capacity(8);
+ let mut unstable_features =
+ Vec::with_capacity(crate::UNSTABLE_GRANULAR_FLAGS.len());
for (feature_name, _, id) in crate::UNSTABLE_GRANULAR_FLAGS {
if feature_checker.check(feature_name) {
unstable_features.push(*id);
@@ -768,7 +769,8 @@ fn create_web_worker_callback(
// TODO(bartlomieju): this is cruft, update FeatureChecker to spit out
// list of enabled features.
let feature_checker = shared.feature_checker.clone();
- let mut unstable_features = Vec::with_capacity(8);
+ let mut unstable_features =
+ Vec::with_capacity(crate::UNSTABLE_GRANULAR_FLAGS.len());
for (feature_name, _, id) in crate::UNSTABLE_GRANULAR_FLAGS {
if feature_checker.check(feature_name) {
unstable_features.push(*id);