-
Notifications
You must be signed in to change notification settings - Fork 74
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(ses): Patch leak of globalLexicals thru moduleLexicals #1341
Changes from 1 commit
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 |
---|---|---|
|
@@ -26,14 +26,20 @@ function buildOptimizer(constants, name) { | |
* | ||
* @param {object} context | ||
* @param {object} context.evalScope | ||
* @param {object} context.globalLexicals | ||
* @param {object} context.globalObject | ||
* @param {object} context.globalLexicals | ||
* @param {object} context.moduleLexicals | ||
Comment on lines
-29
to
+31
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. wondering if we should keep the order the same as in the nested scopes |
||
* @param {object} context.scopeTerminator | ||
*/ | ||
export const makeEvaluate = context => { | ||
const { globalObjectConstants, globalLexicalConstants } = getScopeConstants( | ||
const { | ||
globalObjectConstants, | ||
globalLexicalConstants, | ||
moduleLexicalConstants, | ||
} = getScopeConstants( | ||
context.globalObject, | ||
context.globalLexicals, | ||
context.moduleLexicals, | ||
); | ||
const globalObjectOptimizer = buildOptimizer( | ||
globalObjectConstants, | ||
|
@@ -43,6 +49,10 @@ export const makeEvaluate = context => { | |
globalLexicalConstants, | ||
'globalLexicals', | ||
); | ||
const moduleLexicalOptimizer = buildOptimizer( | ||
moduleLexicalConstants, | ||
'moduleLexicals', | ||
); | ||
Comment on lines
+52
to
+55
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. Can this ever actually happen? I mean this is probably the safest way, and doesn't cost much. 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. Not in any correct arrangement. Any potential overlap would need to be censored by a transform. |
||
|
||
// Create a function in sloppy mode, so that we can use 'with'. It returns | ||
// a function in strict mode that evaluates the provided code using direct | ||
|
@@ -93,13 +103,16 @@ export const makeEvaluate = context => { | |
with (this.scopeTerminator) { | ||
with (this.globalObject) { | ||
with (this.globalLexicals) { | ||
with (this.evalScope) { | ||
${globalObjectOptimizer} | ||
${globalLexicalOptimizer} | ||
return function() { | ||
'use strict'; | ||
return eval(arguments[0]); | ||
}; | ||
with (this.moduleLexicals) { | ||
with (this.evalScope) { | ||
${globalObjectOptimizer} | ||
${globalLexicalOptimizer} | ||
${moduleLexicalOptimizer} | ||
return function() { | ||
'use strict'; | ||
return eval(arguments[0]); | ||
}; | ||
} | ||
} | ||
} | ||
} | ||
|
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 is really one of those cases where I prefer to write
__moduleShimLexicals__ != null