From 30bcce34b669500585a6ae1ca0fc3422ca9ca4d6 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Sat, 7 Feb 2015 02:55:07 +0300 Subject: [PATCH] contextify: share security token with debug ctx If security token does not match - no changes are allowed to the objects from different context. We already copy the security token to the newly created contexts in contextify.cc . Copy the security token to the debug context too. Fix: https://github.com/joyent/node/issues/9156 --- src/node_contextify.cc | 8 +++++- test/simple/test-vm-debug-context-token.js | 33 ++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 test/simple/test-vm-debug-context-token.js diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 2e8fd2cade6..15f87a2418e 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -257,7 +257,13 @@ class ContextifyContext { Local script_source(args[0]->ToString()); if (script_source.IsEmpty()) return; // Exception pending. - Context::Scope context_scope(Debug::GetDebugContext()); + + Environment* env = Environment::GetCurrent(args.GetIsolate()); + Local ctx = Debug::GetDebugContext(); + if (!ctx.IsEmpty()) + ctx->SetSecurityToken(env->context()->GetSecurityToken()); + + Context::Scope context_scope(ctx); Local