@@ -40,6 +40,10 @@ function getOptimizableGlobals(safeGlobal) {
40
40
41
41
if ( ! regexpMatch ( identifierPattern , name ) ) return ;
42
42
43
+ // todo: reject keywords, which pass the isIdentifier check, to block
44
+ // injection attacks. test should use a property name that is itself a
45
+ // full program
46
+
43
47
// getters will not have .writable, don't let the falsyness of
44
48
// 'undefined' trick us: test with === false, not ! . However descriptors
45
49
// inherit from the (potentially poisoned) global object, so we might see
@@ -116,6 +120,14 @@ export function createSafeEvaluatorFactory(unsafeRec, safeGlobal) {
116
120
const scopedEvaluatorFactory = createScopedEvaluatorFactory ( unsafeRec , optimizableGlobals ) ;
117
121
118
122
function factory ( endowments ) {
123
+ // todo (shim limitation): scan endowments, throw error if endowment
124
+ // overlaps with the const optimization (which would otherwise
125
+ // incorrectly shadow endowments), or if endowments includes 'eval'. Also
126
+ // prohibit accessor properties (to be able to consistently explain
127
+ // things in terms of shimming the global lexical scope).
128
+ // writeable-vs-nonwritable == let-vs-const, but there's no
129
+ // global-lexical-scope equivalent of an accessor, outside what we can
130
+ // explain/spec
119
131
const scopeTarget = create ( safeGlobal , getOwnPropertyDescriptors ( endowments ) ) ;
120
132
const scopeProxy = new Proxy ( scopeTarget , scopeHandler ) ;
121
133
const scopedEvaluator = scopedEvaluatorFactory ( scopeProxy ) ;
0 commit comments