ses 0.18.0 → 0.18.1
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 +12 -0
- package/README.md +1 -1
- package/dist/lockdown.cjs +148 -97
- package/dist/lockdown.mjs +148 -97
- package/dist/lockdown.umd.js +148 -97
- package/dist/lockdown.umd.min.js +1 -1
- package/dist/ses.cjs +148 -97
- package/dist/ses.mjs +148 -97
- package/dist/ses.umd.js +148 -97
- package/dist/ses.umd.min.js +1 -1
- package/index.d.ts +2 -1
- package/package.json +9 -8
- package/src/compartment-evaluate.js +2 -4
- package/src/error/console.js +2 -6
- package/src/error/types.js +25 -11
- package/src/get-anonymous-intrinsics.js +4 -2
- package/src/lockdown-shim.js +4 -9
- package/src/module-instance.js +18 -8
- package/src/module-link.js +2 -6
- package/src/module-load.js +57 -20
- package/src/tame-function-constructors.js +3 -2
- package/src/tame-math-object.js +2 -3
- package/CHANGELOG.md +0 -596
package/index.d.ts
CHANGED
|
@@ -64,9 +64,10 @@ export type FinalStaticModuleType =
|
|
|
64
64
|
| ThirdPartyStaticModuleInterface;
|
|
65
65
|
|
|
66
66
|
export interface RedirectStaticModuleInterface {
|
|
67
|
-
record: FinalStaticModuleType;
|
|
68
67
|
specifier: string;
|
|
68
|
+
record?: FinalStaticModuleType;
|
|
69
69
|
importMeta?: any;
|
|
70
|
+
compartment?: Compartment;
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
export type StaticModuleType =
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ses",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.1",
|
|
4
4
|
"description": "Hardened JavaScript for Fearless Cooperation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lockdown",
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
"test:platform-compatibility": "node test/package/test.cjs"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@endo/compartment-mapper": "^0.8.
|
|
63
|
-
"@endo/eslint-config": "^0.5.
|
|
64
|
-
"@endo/static-module-record": "^0.7.
|
|
65
|
-
"@endo/test262-runner": "^0.1.
|
|
66
|
-
"ava": "^
|
|
62
|
+
"@endo/compartment-mapper": "^0.8.1",
|
|
63
|
+
"@endo/eslint-config": "^0.5.2",
|
|
64
|
+
"@endo/static-module-record": "^0.7.16",
|
|
65
|
+
"@endo/test262-runner": "^0.1.29",
|
|
66
|
+
"ava": "^5.1.0",
|
|
67
67
|
"babel-eslint": "^10.0.3",
|
|
68
68
|
"c8": "^7.7.3",
|
|
69
69
|
"eslint": "^7.32.0",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"eslint-plugin-eslint-comments": "^3.1.2",
|
|
73
73
|
"eslint-plugin-import": "^2.26.0",
|
|
74
74
|
"eslint-plugin-prettier": "^3.4.1",
|
|
75
|
-
"prettier": "^
|
|
75
|
+
"prettier": "^2.8.0",
|
|
76
76
|
"sinon": "8.0.4",
|
|
77
77
|
"terser": "^4.8.0",
|
|
78
78
|
"tsd": "^0.24.1",
|
|
@@ -170,6 +170,7 @@
|
|
|
170
170
|
]
|
|
171
171
|
},
|
|
172
172
|
"prettier": {
|
|
173
|
+
"arrowParens": "avoid",
|
|
173
174
|
"trailingComma": "all",
|
|
174
175
|
"singleQuote": true
|
|
175
176
|
},
|
|
@@ -179,5 +180,5 @@
|
|
|
179
180
|
],
|
|
180
181
|
"timeout": "2m"
|
|
181
182
|
},
|
|
182
|
-
"gitHead": "
|
|
183
|
+
"gitHead": "ab8d64ae6fc9c628a2d1c02d16bf9ef249f5c8dc"
|
|
183
184
|
}
|
|
@@ -13,10 +13,8 @@ import {
|
|
|
13
13
|
import { makeSafeEvaluator } from './make-safe-evaluator.js';
|
|
14
14
|
|
|
15
15
|
export const provideCompartmentEvaluator = (compartmentFields, options) => {
|
|
16
|
-
const {
|
|
17
|
-
|
|
18
|
-
__moduleShimLexicals__ = undefined,
|
|
19
|
-
} = options;
|
|
16
|
+
const { sloppyGlobalsMode = false, __moduleShimLexicals__ = undefined } =
|
|
17
|
+
options;
|
|
20
18
|
|
|
21
19
|
let safeEvaluate;
|
|
22
20
|
|
package/src/error/console.js
CHANGED
|
@@ -174,12 +174,8 @@ freeze(ErrorInfo);
|
|
|
174
174
|
|
|
175
175
|
/** @type {MakeCausalConsole} */
|
|
176
176
|
const makeCausalConsole = (baseConsole, loggedErrorHandler) => {
|
|
177
|
-
const {
|
|
178
|
-
|
|
179
|
-
tagError,
|
|
180
|
-
takeMessageLogArgs,
|
|
181
|
-
takeNoteLogArgsArray,
|
|
182
|
-
} = loggedErrorHandler;
|
|
177
|
+
const { getStackString, tagError, takeMessageLogArgs, takeNoteLogArgsArray } =
|
|
178
|
+
loggedErrorHandler;
|
|
183
179
|
|
|
184
180
|
/**
|
|
185
181
|
* @param {ReadonlyArray<any>} logArgs
|
package/src/error/types.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* @typedef {
|
|
15
|
+
* @typedef {object} AssertMakeErrorOptions
|
|
16
16
|
* @property {string=} errorName
|
|
17
17
|
*/
|
|
18
18
|
|
|
@@ -59,51 +59,65 @@
|
|
|
59
59
|
*/
|
|
60
60
|
|
|
61
61
|
// Type all the overloads of the assertTypeof function.
|
|
62
|
-
// There may eventually be a better way to do this, but
|
|
63
|
-
// Typescript 4.0.
|
|
62
|
+
// There may eventually be a better way to do this, but
|
|
63
|
+
// thems the breaks with Typescript 4.0.
|
|
64
64
|
/**
|
|
65
65
|
* @callback AssertTypeofBigint
|
|
66
66
|
* @param {any} specimen
|
|
67
67
|
* @param {'bigint'} typename
|
|
68
68
|
* @param {Details=} optDetails
|
|
69
69
|
* @returns {asserts specimen is bigint}
|
|
70
|
-
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
/**
|
|
71
73
|
* @callback AssertTypeofBoolean
|
|
72
74
|
* @param {any} specimen
|
|
73
75
|
* @param {'boolean'} typename
|
|
74
76
|
* @param {Details=} optDetails
|
|
75
77
|
* @returns {asserts specimen is boolean}
|
|
76
|
-
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
/**
|
|
77
81
|
* @callback AssertTypeofFunction
|
|
78
82
|
* @param {any} specimen
|
|
79
83
|
* @param {'function'} typename
|
|
80
84
|
* @param {Details=} optDetails
|
|
81
85
|
* @returns {asserts specimen is Function}
|
|
82
|
-
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
/**
|
|
83
89
|
* @callback AssertTypeofNumber
|
|
84
90
|
* @param {any} specimen
|
|
85
91
|
* @param {'number'} typename
|
|
86
92
|
* @param {Details=} optDetails
|
|
87
93
|
* @returns {asserts specimen is number}
|
|
88
|
-
|
|
94
|
+
*/
|
|
95
|
+
|
|
96
|
+
/**
|
|
89
97
|
* @callback AssertTypeofObject
|
|
90
98
|
* @param {any} specimen
|
|
91
99
|
* @param {'object'} typename
|
|
92
100
|
* @param {Details=} optDetails
|
|
93
101
|
* @returns {asserts specimen is Record<any, any> | null}
|
|
94
|
-
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
/**
|
|
95
105
|
* @callback AssertTypeofString
|
|
96
106
|
* @param {any} specimen
|
|
97
107
|
* @param {'string'} typename
|
|
98
108
|
* @param {Details=} optDetails
|
|
99
109
|
* @returns {asserts specimen is string}
|
|
100
|
-
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
/**
|
|
101
113
|
* @callback AssertTypeofSymbol
|
|
102
114
|
* @param {any} specimen
|
|
103
115
|
* @param {'symbol'} typename
|
|
104
116
|
* @param {Details=} optDetails
|
|
105
117
|
* @returns {asserts specimen is symbol}
|
|
106
|
-
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
/**
|
|
107
121
|
* @callback AssertTypeofUndefined
|
|
108
122
|
* @param {any} specimen
|
|
109
123
|
* @param {'undefined'} typename
|
|
@@ -157,7 +171,7 @@
|
|
|
157
171
|
*/
|
|
158
172
|
|
|
159
173
|
/**
|
|
160
|
-
* @typedef {
|
|
174
|
+
* @typedef {object} StringablePayload
|
|
161
175
|
* Holds the payload passed to quote so that its printed form is visible.
|
|
162
176
|
* @property {() => string} toString How to print the payload
|
|
163
177
|
*/
|
|
@@ -45,8 +45,10 @@ export const getAnonymousIntrinsics = () => {
|
|
|
45
45
|
|
|
46
46
|
// 9.2.4.1 %ThrowTypeError%
|
|
47
47
|
|
|
48
|
-
const ThrowTypeError = getOwnPropertyDescriptor(
|
|
49
|
-
|
|
48
|
+
const ThrowTypeError = getOwnPropertyDescriptor(
|
|
49
|
+
makeArguments(),
|
|
50
|
+
'callee',
|
|
51
|
+
).get;
|
|
50
52
|
|
|
51
53
|
// 21.1.5.2 The %StringIteratorPrototype% Object
|
|
52
54
|
|
package/src/lockdown-shim.js
CHANGED
|
@@ -151,10 +151,8 @@ export const repairIntrinsics = (options = {}) => {
|
|
|
151
151
|
// [`stackFiltering` options](https://github.com/Agoric/SES-shim/blob/master/packages/ses/lockdown-options.md#stackfiltering-options)
|
|
152
152
|
// for an explanation.
|
|
153
153
|
|
|
154
|
-
const {
|
|
155
|
-
|
|
156
|
-
getCapturedEnvironmentOptionNames,
|
|
157
|
-
} = makeEnvironmentCaptor(globalThis);
|
|
154
|
+
const { getEnvironmentOption: getenv, getCapturedEnvironmentOptionNames } =
|
|
155
|
+
makeEnvironmentCaptor(globalThis);
|
|
158
156
|
|
|
159
157
|
const {
|
|
160
158
|
errorTaming = getenv('LOCKDOWN_ERROR_TAMING', 'safe'),
|
|
@@ -260,11 +258,8 @@ export const repairIntrinsics = (options = {}) => {
|
|
|
260
258
|
|
|
261
259
|
tameDomains(domainTaming);
|
|
262
260
|
|
|
263
|
-
const {
|
|
264
|
-
|
|
265
|
-
completePrototypes,
|
|
266
|
-
finalIntrinsics,
|
|
267
|
-
} = makeIntrinsicsCollector();
|
|
261
|
+
const { addIntrinsics, completePrototypes, finalIntrinsics } =
|
|
262
|
+
makeIntrinsicsCollector();
|
|
268
263
|
|
|
269
264
|
addIntrinsics({ harden });
|
|
270
265
|
|
package/src/module-instance.js
CHANGED
|
@@ -134,6 +134,7 @@ export const makeModuleInstance = (
|
|
|
134
134
|
__syncModuleProgram__: functorSource,
|
|
135
135
|
__fixedExportMap__: fixedExportMap = {},
|
|
136
136
|
__liveExportMap__: liveExportMap = {},
|
|
137
|
+
__reexportMap__: reexportMap = {},
|
|
137
138
|
__needsImportMeta__: needsImportMeta = false,
|
|
138
139
|
} = staticModuleRecord;
|
|
139
140
|
|
|
@@ -387,26 +388,35 @@ export const makeModuleInstance = (
|
|
|
387
388
|
}
|
|
388
389
|
if (arrayIncludes(exportAlls, specifier)) {
|
|
389
390
|
// Make all these imports candidates.
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
391
|
+
// Note names don't change in reexporting all
|
|
392
|
+
for (const [importAndExportName, importNotify] of entries(
|
|
393
|
+
importNotifiers,
|
|
394
|
+
)) {
|
|
395
|
+
if (candidateAll[importAndExportName] === undefined) {
|
|
396
|
+
candidateAll[importAndExportName] = importNotify;
|
|
393
397
|
} else {
|
|
394
398
|
// Already a candidate: remove ambiguity.
|
|
395
|
-
candidateAll[
|
|
399
|
+
candidateAll[importAndExportName] = false;
|
|
396
400
|
}
|
|
397
401
|
}
|
|
398
402
|
}
|
|
403
|
+
if (reexportMap[specifier]) {
|
|
404
|
+
// Make named reexports candidates too.
|
|
405
|
+
for (const [localName, exportedName] of reexportMap[specifier]) {
|
|
406
|
+
candidateAll[exportedName] = importNotifiers[localName];
|
|
407
|
+
}
|
|
408
|
+
}
|
|
399
409
|
}
|
|
400
410
|
|
|
401
|
-
for (const [
|
|
402
|
-
if (!notifiers[
|
|
403
|
-
notifiers[
|
|
411
|
+
for (const [exportName, notify] of entries(candidateAll)) {
|
|
412
|
+
if (!notifiers[exportName] && notify !== false) {
|
|
413
|
+
notifiers[exportName] = notify;
|
|
404
414
|
|
|
405
415
|
// exported live binding state
|
|
406
416
|
let value;
|
|
407
417
|
const update = newValue => (value = newValue);
|
|
408
418
|
notify(update);
|
|
409
|
-
exportsProps[
|
|
419
|
+
exportsProps[exportName] = {
|
|
410
420
|
get() {
|
|
411
421
|
return value;
|
|
412
422
|
},
|
package/src/module-link.js
CHANGED
|
@@ -120,12 +120,8 @@ export const instantiate = (
|
|
|
120
120
|
moduleAliases,
|
|
121
121
|
moduleRecord,
|
|
122
122
|
) => {
|
|
123
|
-
const {
|
|
124
|
-
|
|
125
|
-
moduleSpecifier,
|
|
126
|
-
resolvedImports,
|
|
127
|
-
staticModuleRecord,
|
|
128
|
-
} = moduleRecord;
|
|
123
|
+
const { compartment, moduleSpecifier, resolvedImports, staticModuleRecord } =
|
|
124
|
+
moduleRecord;
|
|
129
125
|
const { instances } = weakmapGet(compartmentPrivateFields, compartment);
|
|
130
126
|
|
|
131
127
|
// Memoize.
|
package/src/module-load.js
CHANGED
|
@@ -54,7 +54,7 @@ const resolveAll = (imports, resolveHook, fullReferrerSpecifier) => {
|
|
|
54
54
|
return freeze(resolvedImports);
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
const loadRecord =
|
|
57
|
+
const loadRecord = (
|
|
58
58
|
compartmentPrivateFields,
|
|
59
59
|
moduleAliases,
|
|
60
60
|
compartment,
|
|
@@ -175,27 +175,64 @@ const loadWithoutErrorAnnotation = async (
|
|
|
175
175
|
)} in compartment ${q(compartment.name)}`;
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
if
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
record
|
|
183
|
-
|
|
184
|
-
|
|
178
|
+
// check if record is a RedirectStaticModuleInterface
|
|
179
|
+
if (staticModuleRecord.specifier !== undefined) {
|
|
180
|
+
// check if this redirect with an explicit record
|
|
181
|
+
if (staticModuleRecord.record !== undefined) {
|
|
182
|
+
// ensure expected record shape
|
|
183
|
+
if (staticModuleRecord.compartment !== undefined) {
|
|
184
|
+
throw new TypeError(
|
|
185
|
+
'Cannot redirect to an explicit record with a specified compartment',
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
const {
|
|
189
|
+
compartment: aliasCompartment = compartment,
|
|
190
|
+
specifier: aliasSpecifier = moduleSpecifier,
|
|
191
|
+
record: aliasModuleRecord,
|
|
192
|
+
importMeta,
|
|
193
|
+
} = staticModuleRecord;
|
|
185
194
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
195
|
+
const aliasRecord = loadRecord(
|
|
196
|
+
compartmentPrivateFields,
|
|
197
|
+
moduleAliases,
|
|
198
|
+
aliasCompartment,
|
|
199
|
+
aliasSpecifier,
|
|
200
|
+
aliasModuleRecord,
|
|
201
|
+
pendingJobs,
|
|
202
|
+
moduleLoads,
|
|
203
|
+
errors,
|
|
204
|
+
importMeta,
|
|
205
|
+
);
|
|
206
|
+
mapSet(moduleRecords, moduleSpecifier, aliasRecord);
|
|
207
|
+
return aliasRecord;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// check if this redirect with an explicit compartment
|
|
211
|
+
if (staticModuleRecord.compartment !== undefined) {
|
|
212
|
+
// ensure expected record shape
|
|
213
|
+
if (staticModuleRecord.importMeta !== undefined) {
|
|
214
|
+
throw new TypeError(
|
|
215
|
+
'Cannot redirect to an implicit record with a specified importMeta',
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
// Behold: recursion.
|
|
219
|
+
// eslint-disable-next-line no-use-before-define
|
|
220
|
+
const aliasRecord = await memoizedLoadWithErrorAnnotation(
|
|
221
|
+
compartmentPrivateFields,
|
|
222
|
+
moduleAliases,
|
|
223
|
+
staticModuleRecord.compartment,
|
|
224
|
+
staticModuleRecord.specifier,
|
|
225
|
+
pendingJobs,
|
|
226
|
+
moduleLoads,
|
|
227
|
+
errors,
|
|
228
|
+
);
|
|
229
|
+
mapSet(moduleRecords, moduleSpecifier, aliasRecord);
|
|
230
|
+
return aliasRecord;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
throw new TypeError(
|
|
234
|
+
'Unnexpected RedirectStaticModuleInterface record shape',
|
|
196
235
|
);
|
|
197
|
-
mapSet(moduleRecords, moduleSpecifier, aliasRecord);
|
|
198
|
-
return aliasRecord;
|
|
199
236
|
}
|
|
200
237
|
|
|
201
238
|
return loadRecord(
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
defineProperties,
|
|
6
6
|
getPrototypeOf,
|
|
7
7
|
setPrototypeOf,
|
|
8
|
+
freeze,
|
|
8
9
|
} from './commons.js';
|
|
9
10
|
|
|
10
11
|
// This module replaces the original `Function` constructor, and the original
|
|
@@ -49,7 +50,7 @@ export default function tameFunctionConstructors() {
|
|
|
49
50
|
FERAL_FUNCTION.prototype.constructor('return 1');
|
|
50
51
|
} catch (ignore) {
|
|
51
52
|
// Throws, no need to patch.
|
|
52
|
-
return
|
|
53
|
+
return freeze({});
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
const newIntrinsics = {};
|
|
@@ -82,7 +83,7 @@ export default function tameFunctionConstructors() {
|
|
|
82
83
|
// Prevents the evaluation of source when calling constructor on the
|
|
83
84
|
// prototype of functions.
|
|
84
85
|
// eslint-disable-next-line func-names
|
|
85
|
-
const InertConstructor = function() {
|
|
86
|
+
const InertConstructor = function () {
|
|
86
87
|
throw new TypeError(
|
|
87
88
|
'Function.prototype.constructor is not a valid constructor.',
|
|
88
89
|
);
|
package/src/tame-math-object.js
CHANGED
|
@@ -13,9 +13,8 @@ export default function tameMathObject(mathTaming = 'safe') {
|
|
|
13
13
|
const originalMath = Math;
|
|
14
14
|
const initialMath = originalMath; // to follow the naming pattern
|
|
15
15
|
|
|
16
|
-
const { random: _, ...otherDescriptors } =
|
|
17
|
-
originalMath
|
|
18
|
-
);
|
|
16
|
+
const { random: _, ...otherDescriptors } =
|
|
17
|
+
getOwnPropertyDescriptors(originalMath);
|
|
19
18
|
|
|
20
19
|
const sharedMath = create(objectPrototype, otherDescriptors);
|
|
21
20
|
|