ses 0.18.2 → 0.18.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NEWS.md +14 -0
- package/dist/lockdown.cjs +648 -275
- package/dist/lockdown.mjs +648 -275
- package/dist/lockdown.umd.js +648 -275
- package/dist/lockdown.umd.min.js +1 -1
- package/dist/ses.cjs +648 -275
- package/dist/ses.mjs +648 -275
- package/dist/ses.umd.js +648 -275
- package/dist/ses.umd.min.js +1 -1
- package/package.json +9 -16
- package/src/commons.js +14 -8
- package/src/compartment-shim.js +1 -5
- package/src/enablements.js +1 -1
- package/src/error/assert.js +4 -19
- package/src/error/note-log-args.js +280 -0
- package/src/error/tame-v8-error-constructor.js +1 -1
- package/src/eval-scope.js +4 -2
- package/src/get-anonymous-intrinsics.js +2 -4
- package/src/intrinsics.js +4 -1
- package/src/lockdown-shim.js +7 -4
- package/src/make-hardener.js +7 -0
- package/src/make-safe-evaluator.js +6 -5
- package/src/module-instance.js +3 -2
- package/src/module-load.js +1 -1
- package/src/scope-constants.js +1 -0
- package/src/strict-scope-terminator.js +2 -3
- package/src/tame-function-tostring.js +1 -1
- package/src/tame-harden.js +29 -0
- package/src/tame-regexp-constructor.js +10 -1
- package/src/whitelist-intrinsics.js +3 -0
- package/src/whitelist.js +9 -1
- package/types.d.ts +1 -0
package/src/module-instance.js
CHANGED
|
@@ -189,6 +189,7 @@ export const makeModuleInstance = (
|
|
|
189
189
|
// fixed binding state
|
|
190
190
|
let value;
|
|
191
191
|
let tdz = true;
|
|
192
|
+
/** @type {null | Array<(value: any) => void>} */
|
|
192
193
|
let optUpdaters = [];
|
|
193
194
|
|
|
194
195
|
// tdz sensitive getter
|
|
@@ -214,7 +215,7 @@ export const makeModuleInstance = (
|
|
|
214
215
|
const updaters = optUpdaters;
|
|
215
216
|
optUpdaters = null;
|
|
216
217
|
tdz = false;
|
|
217
|
-
for (const updater of updaters) {
|
|
218
|
+
for (const updater of updaters || []) {
|
|
218
219
|
updater(initValue);
|
|
219
220
|
}
|
|
220
221
|
return initValue;
|
|
@@ -228,7 +229,7 @@ export const makeModuleInstance = (
|
|
|
228
229
|
return;
|
|
229
230
|
}
|
|
230
231
|
if (tdz) {
|
|
231
|
-
arrayPush(optUpdaters, updater);
|
|
232
|
+
arrayPush(optUpdaters || [], updater);
|
|
232
233
|
} else {
|
|
233
234
|
updater(value);
|
|
234
235
|
}
|
package/src/module-load.js
CHANGED
|
@@ -319,7 +319,7 @@ export const load = async (
|
|
|
319
319
|
|
|
320
320
|
/** @type {Set<Promise<undefined>>} */
|
|
321
321
|
const pendingJobs = new Set();
|
|
322
|
-
/** @type {Map<object, Map<string, Promise<Record
|
|
322
|
+
/** @type {Map<object, Map<string, Promise<Record<any, any>>>>} */
|
|
323
323
|
const moduleLoads = new Map();
|
|
324
324
|
/** @type {Array<Error>} */
|
|
325
325
|
const errors = [];
|
package/src/scope-constants.js
CHANGED
|
@@ -115,6 +115,7 @@ export const isValidIdentifierName = name => {
|
|
|
115
115
|
function isImmutableDataProperty(obj, name) {
|
|
116
116
|
const desc = getOwnPropertyDescriptor(obj, name);
|
|
117
117
|
return (
|
|
118
|
+
desc &&
|
|
118
119
|
//
|
|
119
120
|
// The getters will not have .writable, don't let the falsyness of
|
|
120
121
|
// 'undefined' trick us: test with === false, not ! . However descriptors
|
|
@@ -57,9 +57,8 @@ const scopeProxyHandlerProperties = {
|
|
|
57
57
|
return null;
|
|
58
58
|
},
|
|
59
59
|
|
|
60
|
-
//
|
|
61
|
-
// TODO
|
|
62
|
-
// TODO report as bug to v8 or Chrome, and record issue link here.
|
|
60
|
+
// See https://github.com/endojs/endo/issues/1510
|
|
61
|
+
// TODO: report as bug to v8 or Chrome, and record issue link here.
|
|
63
62
|
getOwnPropertyDescriptor(_target, prop) {
|
|
64
63
|
// Coerce with `String` in case prop is a symbol.
|
|
65
64
|
const quotedProp = q(String(prop));
|
|
@@ -27,7 +27,7 @@ export const tameFunctionToString = () => {
|
|
|
27
27
|
|
|
28
28
|
const tamingMethods = {
|
|
29
29
|
toString() {
|
|
30
|
-
const str = functionToString(this
|
|
30
|
+
const str = functionToString(this);
|
|
31
31
|
if (
|
|
32
32
|
stringEndsWith(str, nativeSuffix) ||
|
|
33
33
|
!weaksetHas(virtualizedNativeFunctions, this)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* eslint-disable no-restricted-globals */
|
|
2
|
+
import { TypeError, freeze } from './commons.js';
|
|
3
|
+
|
|
4
|
+
export const tameHarden = (safeHarden, hardenTaming) => {
|
|
5
|
+
if (hardenTaming !== 'safe' && hardenTaming !== 'unsafe') {
|
|
6
|
+
throw new TypeError(`unrecognized fakeHardenOption ${hardenTaming}`);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (hardenTaming === 'safe') {
|
|
10
|
+
return safeHarden;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// In on the joke
|
|
14
|
+
Object.isExtensible = () => false;
|
|
15
|
+
Object.isFrozen = () => true;
|
|
16
|
+
Object.isSealed = () => true;
|
|
17
|
+
Reflect.isExtensible = () => false;
|
|
18
|
+
|
|
19
|
+
if (safeHarden.isFake) {
|
|
20
|
+
// The "safe" hardener is already a fake hardener.
|
|
21
|
+
// Just use it.
|
|
22
|
+
return safeHarden;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const fakeHarden = arg => arg;
|
|
26
|
+
fakeHarden.isFake = true;
|
|
27
|
+
return freeze(fakeHarden);
|
|
28
|
+
};
|
|
29
|
+
freeze(tameHarden);
|
|
@@ -15,6 +15,9 @@ export default function tameRegExpConstructor(regExpTaming = 'safe') {
|
|
|
15
15
|
|
|
16
16
|
const makeRegExpConstructor = (_ = {}) => {
|
|
17
17
|
// RegExp has non-writable static properties we need to omit.
|
|
18
|
+
/**
|
|
19
|
+
* @param {Parameters<typeof FERAL_REG_EXP>} rest
|
|
20
|
+
*/
|
|
18
21
|
const ResultRegExp = function RegExp(...rest) {
|
|
19
22
|
if (new.target === undefined) {
|
|
20
23
|
return FERAL_REG_EXP(...rest);
|
|
@@ -22,6 +25,11 @@ export default function tameRegExpConstructor(regExpTaming = 'safe') {
|
|
|
22
25
|
return construct(FERAL_REG_EXP, rest, new.target);
|
|
23
26
|
};
|
|
24
27
|
|
|
28
|
+
const speciesDesc = getOwnPropertyDescriptor(FERAL_REG_EXP, speciesSymbol);
|
|
29
|
+
if (!speciesDesc) {
|
|
30
|
+
throw new TypeError('no RegExp[Symbol.species] descriptor');
|
|
31
|
+
}
|
|
32
|
+
|
|
25
33
|
defineProperties(ResultRegExp, {
|
|
26
34
|
length: { value: 2 },
|
|
27
35
|
prototype: {
|
|
@@ -30,7 +38,7 @@ export default function tameRegExpConstructor(regExpTaming = 'safe') {
|
|
|
30
38
|
enumerable: false,
|
|
31
39
|
configurable: false,
|
|
32
40
|
},
|
|
33
|
-
[speciesSymbol]:
|
|
41
|
+
[speciesSymbol]: speciesDesc,
|
|
34
42
|
});
|
|
35
43
|
return ResultRegExp;
|
|
36
44
|
};
|
|
@@ -39,6 +47,7 @@ export default function tameRegExpConstructor(regExpTaming = 'safe') {
|
|
|
39
47
|
const SharedRegExp = makeRegExpConstructor();
|
|
40
48
|
|
|
41
49
|
if (regExpTaming !== 'unsafe') {
|
|
50
|
+
// @ts-expect-error Deleted properties must be optional
|
|
42
51
|
delete RegExpPrototype.compile;
|
|
43
52
|
}
|
|
44
53
|
defineProperties(RegExpPrototype, {
|
|
@@ -212,6 +212,9 @@ export default function whitelistIntrinsics(
|
|
|
212
212
|
*/
|
|
213
213
|
function isAllowedProperty(path, obj, prop, permit) {
|
|
214
214
|
const desc = getOwnPropertyDescriptor(obj, prop);
|
|
215
|
+
if (!desc) {
|
|
216
|
+
throw new TypeError(`Property ${prop} not found at ${path}`);
|
|
217
|
+
}
|
|
215
218
|
|
|
216
219
|
// Is this a value property?
|
|
217
220
|
if (objectHasOwnProperty(desc, 'value')) {
|
package/src/whitelist.js
CHANGED
|
@@ -1221,6 +1221,10 @@ export const whitelist = {
|
|
|
1221
1221
|
'[[Proto]]': '%FunctionPrototype%',
|
|
1222
1222
|
constructor: '%InertAsyncGeneratorFunction%',
|
|
1223
1223
|
prototype: '%AsyncGeneratorPrototype%',
|
|
1224
|
+
// length prop added here for React Native jsc-android
|
|
1225
|
+
// https://github.com/endojs/endo/issues/660
|
|
1226
|
+
// https://github.com/react-native-community/jsc-android-buildscripts/issues/181
|
|
1227
|
+
length: 'number',
|
|
1224
1228
|
'@@toStringTag': 'string',
|
|
1225
1229
|
},
|
|
1226
1230
|
|
|
@@ -1303,6 +1307,10 @@ export const whitelist = {
|
|
|
1303
1307
|
// Properties of the AsyncFunction Prototype Object
|
|
1304
1308
|
'[[Proto]]': '%FunctionPrototype%',
|
|
1305
1309
|
constructor: '%InertAsyncFunction%',
|
|
1310
|
+
// length prop added here for React Native jsc-android
|
|
1311
|
+
// https://github.com/endojs/endo/issues/660
|
|
1312
|
+
// https://github.com/react-native-community/jsc-android-buildscripts/issues/181
|
|
1313
|
+
length: 'number',
|
|
1306
1314
|
'@@toStringTag': 'string',
|
|
1307
1315
|
},
|
|
1308
1316
|
|
|
@@ -1368,7 +1376,7 @@ export const whitelist = {
|
|
|
1368
1376
|
},
|
|
1369
1377
|
|
|
1370
1378
|
lockdown: fn,
|
|
1371
|
-
harden: fn,
|
|
1379
|
+
harden: { ...fn, isFake: 'boolean' },
|
|
1372
1380
|
|
|
1373
1381
|
'%InitialGetStackString%': fn,
|
|
1374
1382
|
};
|
package/types.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export interface LockdownOptions {
|
|
|
33
33
|
overrideTaming?: 'moderate' | 'min' | 'severe';
|
|
34
34
|
overrideDebug?: Array<string>;
|
|
35
35
|
domainTaming?: 'safe' | 'unsafe';
|
|
36
|
+
__hardenTaming__?: 'safe' | 'unsafe';
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
export type Lockdown = (options?: LockdownOptions) => void;
|