| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c179254 commit 7964849
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -64,8 +64,29 @@ using v8::UnboundScript; | |||
| 64 | 64 | using v8::Value; | |
| 65 | 65 | using v8::WeakCallbackInfo; | |
| 66 | 66 | ||
| 67 | + // The vm module executes code in a sandboxed environment with a different | ||
| 68 | + // global object than the rest of the code. This is achieved by applying | ||
| 69 | + // every call that changes or queries a property on the global `this` in the | ||
| 70 | + // sandboxed code, to the sandbox object. | ||
| 71 | + // | ||
| 72 | + // The implementation uses V8's interceptors for methods like `set`, `get`, | ||
| 73 | + // `delete`, `defineProperty`, and for any query of the property attributes. | ||
| 74 | + // Property handlers with interceptors are set on the object template for | ||
| 75 | + // the sandboxed code. Handlers for both named properties and for indexed | ||
| 76 | + // properties are used. Their functionality is almost identical, the indexed | ||
| 77 | + // interceptors mostly just call the named interceptors. | ||
| 78 | + // | ||
| 79 | + // For every `get` of a global property in the sandboxed context, the | ||
| 80 | + // interceptor callback checks the sandbox object for the property. | ||
| 81 | + // If the property is defined on the sandbox, that result is returned to | ||
| 82 | + // the original call instead of finishing the query on the global object. | ||
| 83 | + // | ||
| 84 | + // For every `set` of a global property, the interceptor callback defines or | ||
| 85 | + // changes the property both on the sandbox and the global proxy. | ||
| 86 | + | ||
| 67 | 87 | namespace { | |
| 68 | 88 | ||
| 89 | + // Convert an int to a V8 Name (String or Symbol). | ||
| 69 | 90 | Local<Name> Uint32ToName(Local<Context> context, uint32_t index) { | |
| 70 | 91 | return Uint32::New(context->GetIsolate(), index)->ToString(context) | |
| 71 | 92 | .ToLocalChecked(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments