-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: reenable indirect eval #26
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,22 +96,7 @@ export function createSafeEvaluatorFactory(unsafeRec, safeGlobal, transforms) { | |
); | ||
endowments = endowmentState.endowments; | ||
|
||
// todo (shim limitation): scan endowments, throw error if endowment | ||
// overlaps with the const optimization (which would otherwise | ||
// incorrectly shadow endowments), or if endowments includes 'eval'. Also | ||
// prohibit accessor properties (to be able to consistently explain | ||
// things in terms of shimming the global lexical scope). | ||
// writeable-vs-nonwritable == let-vs-const, but there's no | ||
// global-lexical-scope equivalent of an accessor, outside what we can | ||
// explain/spec | ||
const scopeTarget = create( | ||
safeGlobal, | ||
getOwnPropertyDescriptors(endowments) | ||
); | ||
const scopeProxy = new Proxy(scopeTarget, scopeHandler); | ||
const scopedEvaluator = apply(scopedEvaluatorFactory, safeGlobal, [ | ||
scopeProxy | ||
]); | ||
let scopedEvaluator; | ||
|
||
// We use the the concise method syntax to create an eval without a | ||
// [[Construct]] behavior (such that the invocation "new eval()" throws | ||
|
@@ -155,6 +140,27 @@ export function createSafeEvaluatorFactory(unsafeRec, safeGlobal, transforms) { | |
// of Function in any compartment of the same root realm. | ||
setPrototypeOf(safeEval, unsafeFunction.prototype); | ||
|
||
// todo (shim limitation): scan endowments, throw error if endowment | ||
// overlaps with the const optimization (which would otherwise | ||
// incorrectly shadow endowments), or if endowments includes 'eval'. Also | ||
// prohibit accessor properties (to be able to consistently explain | ||
// things in terms of shimming the global lexical scope). | ||
// writeable-vs-nonwritable == let-vs-const, but there's no | ||
// global-lexical-scope equivalent of an accessor, outside what we can | ||
// explain/spec | ||
const scopeTarget = create(safeGlobal, { | ||
...getOwnPropertyDescriptors(endowments), | ||
eval: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you mean to have this I do see in the todo comments above that we should ban Did we not put Thus, if we do place There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Today I experimented with putting safe What should be the expected behaviour? I can certainly rewrite the tests to use |
||
// We need this on the scopeTarget to permit indirect eval. | ||
value: safeEval, | ||
writable: false, | ||
enumerable: false, | ||
configurable: true | ||
} | ||
}); | ||
const scopeProxy = new Proxy(scopeTarget, scopeHandler); | ||
scopedEvaluator = apply(scopedEvaluatorFactory, safeGlobal, [scopeProxy]); | ||
|
||
assert(getPrototypeOf(safeEval).constructor !== Function, 'hide Function'); | ||
assert( | ||
getPrototypeOf(safeEval).constructor !== unsafeFunction, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is stale. Nothing in this PR causes it to be stale, since it is in a todo anyway. However, our safe module plans depend on our ability to install accessors on the
scopeTarget
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll update the comment.