ses 0.15.17 → 0.15.20
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/CHANGELOG.md +28 -0
- package/NEWS.md +9 -1
- package/dist/lockdown.cjs +54 -26
- package/dist/lockdown.mjs +54 -26
- package/dist/lockdown.umd.js +54 -26
- package/dist/lockdown.umd.min.js +1 -1
- package/dist/ses.cjs +54 -26
- package/dist/ses.mjs +54 -26
- package/dist/ses.umd.js +54 -26
- package/dist/ses.umd.min.js +1 -1
- package/index.d.ts +0 -1
- package/package.json +4 -4
- package/src/environment-options.js +3 -3
- package/src/error/tame-v8-error-constructor.js +46 -12
- package/src/lockdown-shim.js +3 -9
- package/src/tame-function-constructors.js +1 -1
package/index.d.ts
CHANGED
|
@@ -33,7 +33,6 @@ export interface LockdownOptions {
|
|
|
33
33
|
overrideTaming?: 'moderate' | 'min' | 'severe';
|
|
34
34
|
overrideDebug?: Array<string>;
|
|
35
35
|
domainTaming?: 'safe' | 'unsafe';
|
|
36
|
-
__allowUnsafeMonkeyPatching__?: 'safe' | 'unsafe';
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
export type Lockdown = (options?: LockdownOptions) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ses",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.20",
|
|
4
4
|
"description": "Hardened JavaScript for Fearless Cooperation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lockdown",
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
"test:platform-compatability": "node test/package/test.cjs"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@endo/compartment-mapper": "^0.7.
|
|
62
|
+
"@endo/compartment-mapper": "^0.7.10",
|
|
63
63
|
"@endo/eslint-config": "^0.5.1",
|
|
64
|
-
"@endo/static-module-record": "^0.7.
|
|
64
|
+
"@endo/static-module-record": "^0.7.9",
|
|
65
65
|
"@endo/test262-runner": "^0.1.28",
|
|
66
66
|
"ava": "^3.12.1",
|
|
67
67
|
"babel-eslint": "^10.0.3",
|
|
@@ -179,5 +179,5 @@
|
|
|
179
179
|
],
|
|
180
180
|
"timeout": "2m"
|
|
181
181
|
},
|
|
182
|
-
"gitHead": "
|
|
182
|
+
"gitHead": "01878cf30cd3196cb4ce0bc08972fefc32fb1143"
|
|
183
183
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// environment-options needs to be imported quite early, and so should
|
|
4
4
|
// avoid importing from anything but commons.js and assert.js
|
|
5
|
-
import { arrayPush,
|
|
5
|
+
import { arrayPush, freeze } from './commons.js';
|
|
6
6
|
import { assert } from './error/assert.js';
|
|
7
7
|
|
|
8
8
|
const { details: X, quote: q } = assert;
|
|
@@ -116,10 +116,10 @@ export const makeEnvironmentCaptor = aGlobal => {
|
|
|
116
116
|
freeze(getEnvironmentOption);
|
|
117
117
|
|
|
118
118
|
const getCapturedEnvironmentOptionNames = () => {
|
|
119
|
-
return freeze(
|
|
119
|
+
return freeze([...capturedEnvironmentOptionNames]);
|
|
120
120
|
};
|
|
121
121
|
freeze(getCapturedEnvironmentOptionNames);
|
|
122
122
|
|
|
123
|
-
return { getEnvironmentOption, getCapturedEnvironmentOptionNames };
|
|
123
|
+
return freeze({ getEnvironmentOption, getCapturedEnvironmentOptionNames });
|
|
124
124
|
};
|
|
125
125
|
freeze(makeEnvironmentCaptor);
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
regexpExec,
|
|
14
14
|
regexpTest,
|
|
15
15
|
weakmapGet,
|
|
16
|
-
weakmapHas,
|
|
17
16
|
weakmapSet,
|
|
18
17
|
weaksetAdd,
|
|
19
18
|
weaksetHas,
|
|
@@ -165,6 +164,9 @@ export const tameV8ErrorConstructor = (
|
|
|
165
164
|
errorTaming,
|
|
166
165
|
stackFiltering,
|
|
167
166
|
) => {
|
|
167
|
+
// TODO: Proper CallSite types
|
|
168
|
+
/** @typedef {{}} CallSite */
|
|
169
|
+
|
|
168
170
|
const originalCaptureStackTrace = OriginalError.captureStackTrace;
|
|
169
171
|
|
|
170
172
|
// const callSiteFilter = _callSite => true;
|
|
@@ -190,9 +192,23 @@ export const tameV8ErrorConstructor = (
|
|
|
190
192
|
'',
|
|
191
193
|
);
|
|
192
194
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
195
|
+
/**
|
|
196
|
+
* @typedef {object} StructuredStackInfo
|
|
197
|
+
* @property {CallSite[]} callSites
|
|
198
|
+
* @property {undefined} [stackString]
|
|
199
|
+
*/
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @typedef {object} ParsedStackInfo
|
|
203
|
+
* @property {undefined} [callSites]
|
|
204
|
+
* @property {string} stackString
|
|
205
|
+
*/
|
|
206
|
+
|
|
207
|
+
// Mapping from error instance to the stack for that instance.
|
|
208
|
+
// The stack info is either the structured stack trace
|
|
209
|
+
// or the generated tamed stack string
|
|
210
|
+
/** @type {WeakMap<Error, ParsedStackInfo | StructuredStackInfo} */
|
|
211
|
+
const stackInfos = new WeakMap();
|
|
196
212
|
|
|
197
213
|
// Use concise methods to obtain named functions without constructors.
|
|
198
214
|
const tamedMethods = {
|
|
@@ -214,23 +230,41 @@ export const tameV8ErrorConstructor = (
|
|
|
214
230
|
// string associated with an error.
|
|
215
231
|
// See https://tc39.es/proposal-error-stacks/
|
|
216
232
|
getStackString(error) {
|
|
217
|
-
|
|
233
|
+
let stackInfo = weakmapGet(stackInfos, error);
|
|
234
|
+
|
|
235
|
+
if (stackInfo === undefined) {
|
|
236
|
+
// The following will call `prepareStackTrace()` synchronously
|
|
237
|
+
// which will populate stackInfos
|
|
218
238
|
// eslint-disable-next-line no-void
|
|
219
239
|
void error.stack;
|
|
240
|
+
stackInfo = weakmapGet(stackInfos, error);
|
|
241
|
+
if (!stackInfo) {
|
|
242
|
+
stackInfo = { stackString: '' };
|
|
243
|
+
weakmapSet(stackInfos, error, stackInfo);
|
|
244
|
+
}
|
|
220
245
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
246
|
+
|
|
247
|
+
// prepareStackTrace() may generate the stackString
|
|
248
|
+
// if errorTaming === 'unsafe'
|
|
249
|
+
|
|
250
|
+
if (stackInfo.stackString !== undefined) {
|
|
251
|
+
return stackInfo.stackString;
|
|
224
252
|
}
|
|
225
|
-
|
|
253
|
+
|
|
254
|
+
const stackString = stackStringFromSST(error, stackInfo.callSites);
|
|
255
|
+
weakmapSet(stackInfos, error, { stackString });
|
|
256
|
+
|
|
257
|
+
return stackString;
|
|
226
258
|
},
|
|
227
259
|
prepareStackTrace(error, sst) {
|
|
228
|
-
weakmapSet(ssts, error, sst);
|
|
229
260
|
if (errorTaming === 'unsafe') {
|
|
230
261
|
const stackString = stackStringFromSST(error, sst);
|
|
262
|
+
weakmapSet(stackInfos, error, { stackString });
|
|
231
263
|
return `${error}${stackString}`;
|
|
264
|
+
} else {
|
|
265
|
+
weakmapSet(stackInfos, error, { callSites: sst });
|
|
266
|
+
return '';
|
|
232
267
|
}
|
|
233
|
-
return '';
|
|
234
268
|
},
|
|
235
269
|
};
|
|
236
270
|
|
|
@@ -265,7 +299,7 @@ export const tameV8ErrorConstructor = (
|
|
|
265
299
|
// Use concise methods to obtain named functions without constructors.
|
|
266
300
|
const systemMethods = {
|
|
267
301
|
prepareStackTrace(error, sst) {
|
|
268
|
-
weakmapSet(
|
|
302
|
+
weakmapSet(stackInfos, error, { callSites: sst });
|
|
269
303
|
return inputPrepareFn(error, safeV8SST(sst));
|
|
270
304
|
},
|
|
271
305
|
};
|
package/src/lockdown-shim.js
CHANGED
|
@@ -176,10 +176,6 @@ export const repairIntrinsics = (options = {}) => {
|
|
|
176
176
|
/** @param {string} debugName */
|
|
177
177
|
debugName => debugName !== '',
|
|
178
178
|
),
|
|
179
|
-
__allowUnsafeMonkeyPatching__ = getenv(
|
|
180
|
-
'__LOCKDOWN_ALLOW_UNSAFE_MONKEY_PATCHING__',
|
|
181
|
-
'safe',
|
|
182
|
-
),
|
|
183
179
|
dateTaming = 'safe', // deprecated
|
|
184
180
|
mathTaming = 'safe', // deprecated
|
|
185
181
|
...extraOptions
|
|
@@ -386,11 +382,9 @@ export const repairIntrinsics = (options = {}) => {
|
|
|
386
382
|
// @ts-ignore enablePropertyOverrides does its own input validation
|
|
387
383
|
enablePropertyOverrides(intrinsics, overrideTaming, overrideDebug);
|
|
388
384
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
harden(intrinsics);
|
|
393
|
-
}
|
|
385
|
+
// Finally register and optionally freeze all the intrinsics. This
|
|
386
|
+
// must be the operation that modifies the intrinsics.
|
|
387
|
+
harden(intrinsics);
|
|
394
388
|
|
|
395
389
|
// Reveal harden after lockdown.
|
|
396
390
|
// Harden is dangerous before lockdown because hardening just
|