ses 0.15.3 → 0.15.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/CHANGELOG.md +19 -0
- package/NEWS.md +7 -0
- package/README.md +204 -10
- package/SECURITY.md +30 -17
- package/dist/lockdown.cjs +61 -5
- package/dist/lockdown.mjs +61 -5
- package/dist/lockdown.umd.js +61 -5
- package/dist/lockdown.umd.min.js +1 -1
- package/dist/ses.cjs +61 -5
- package/dist/ses.mjs +61 -5
- package/dist/ses.umd.js +61 -5
- package/dist/ses.umd.min.js +1 -1
- package/index.d.ts +2 -1
- package/package.json +7 -8
- package/src/commons.js +1 -0
- package/src/lockdown-shim.js +35 -0
- package/src/tame-locale-methods.js +12 -0
- package/src/whitelist.js +6 -0
package/index.d.ts
CHANGED
|
@@ -89,6 +89,7 @@ export type DetailsToken = Record<any, never>
|
|
|
89
89
|
export type Details = string | DetailsToken
|
|
90
90
|
|
|
91
91
|
export interface AssertMakeErrorOptions {
|
|
92
|
+
errorName?: string,
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
type AssertTypeofBigint = (specimen: any, typeName: 'bigint', details?: Details) => asserts specimen is bigint;
|
|
@@ -119,7 +120,7 @@ interface ToStringable {
|
|
|
119
120
|
export interface Assert {
|
|
120
121
|
(value: any, details?: Details, errorConstructor?:ErrorConstructor): asserts value;
|
|
121
122
|
typeof: AssertTypeof,
|
|
122
|
-
error(details?: Details, errorConstructor?:ErrorConstructor): Error;
|
|
123
|
+
error(details?: Details, errorConstructor?:ErrorConstructor, options?:AssertMakeErrorOptions): Error;
|
|
123
124
|
fail(details?: Details, errorConstructor?:ErrorConstructor): never;
|
|
124
125
|
equal(left: any, right: any, details?: Details, errorConstructor?:ErrorConstructor): void;
|
|
125
126
|
string(specimen: any, details?: Details): asserts specimen is string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ses",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.4",
|
|
4
4
|
"description": "Hardened JavaScript for Fearless Cooperation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lockdown",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"build": "node scripts/bundle.js",
|
|
49
49
|
"clean": "rm -rf dist",
|
|
50
50
|
"cover": "c8 ava",
|
|
51
|
-
"demo": "
|
|
51
|
+
"demo": "python3 -m http.server",
|
|
52
52
|
"lint": "yarn lint:types && yarn lint:js",
|
|
53
53
|
"lint-fix": "eslint --fix .",
|
|
54
54
|
"lint:js": "eslint .",
|
|
@@ -59,10 +59,10 @@
|
|
|
59
59
|
"test:platform-compatability": "node test/package/test.cjs"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@endo/compartment-mapper": "^0.6.
|
|
63
|
-
"@endo/eslint-config": "^0.3.
|
|
64
|
-
"@endo/static-module-record": "^0.6.
|
|
65
|
-
"@endo/test262-runner": "^0.1.
|
|
62
|
+
"@endo/compartment-mapper": "^0.6.2",
|
|
63
|
+
"@endo/eslint-config": "^0.3.21",
|
|
64
|
+
"@endo/static-module-record": "^0.6.9",
|
|
65
|
+
"@endo/test262-runner": "^0.1.15",
|
|
66
66
|
"ava": "^3.12.1",
|
|
67
67
|
"babel-eslint": "^10.0.3",
|
|
68
68
|
"c8": "^7.7.3",
|
|
@@ -72,7 +72,6 @@
|
|
|
72
72
|
"eslint-plugin-eslint-comments": "^3.1.2",
|
|
73
73
|
"eslint-plugin-import": "^2.19.1",
|
|
74
74
|
"eslint-plugin-prettier": "^3.1.2",
|
|
75
|
-
"http-server": "^0.12.1",
|
|
76
75
|
"prettier": "^1.19.1",
|
|
77
76
|
"sinon": "8.0.4",
|
|
78
77
|
"terser": "^4.8.0",
|
|
@@ -179,5 +178,5 @@
|
|
|
179
178
|
],
|
|
180
179
|
"timeout": "2m"
|
|
181
180
|
},
|
|
182
|
-
"gitHead": "
|
|
181
|
+
"gitHead": "b986f1b0afbec1261fb2c047257751b9d418df7c"
|
|
183
182
|
}
|
package/src/commons.js
CHANGED
package/src/lockdown-shim.js
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
// @ts-check
|
|
16
16
|
|
|
17
17
|
import {
|
|
18
|
+
FERAL_FUNCTION,
|
|
19
|
+
FERAL_EVAL,
|
|
18
20
|
TypeError,
|
|
19
21
|
arrayFilter,
|
|
20
22
|
arrayMap,
|
|
@@ -87,6 +89,37 @@ const harden = makeHardener();
|
|
|
87
89
|
// only ever need to be called once and that simplifying lockdown will improve
|
|
88
90
|
// the quality of audits.
|
|
89
91
|
|
|
92
|
+
const assertDirectEvalAvailable = () => {
|
|
93
|
+
let allowed = false;
|
|
94
|
+
try {
|
|
95
|
+
allowed = FERAL_FUNCTION(
|
|
96
|
+
'eval',
|
|
97
|
+
'SES_changed',
|
|
98
|
+
`\
|
|
99
|
+
eval("SES_changed = true");
|
|
100
|
+
return SES_changed;
|
|
101
|
+
`,
|
|
102
|
+
)(FERAL_EVAL, false);
|
|
103
|
+
// If we get here and SES_changed stayed false, that means the eval was sloppy
|
|
104
|
+
// and indirect, which generally creates a new global.
|
|
105
|
+
// We are going to throw an exception for failing to initialize SES, but
|
|
106
|
+
// good neighbors clean up.
|
|
107
|
+
if (!allowed) {
|
|
108
|
+
delete globalThis.SES_changed;
|
|
109
|
+
}
|
|
110
|
+
} catch (_error) {
|
|
111
|
+
// We reach here if eval is outright forbidden by a Content Security Policy.
|
|
112
|
+
// We allow this for SES usage that delegates the responsibility to isolate
|
|
113
|
+
// guest code to production code generation.
|
|
114
|
+
allowed = true;
|
|
115
|
+
}
|
|
116
|
+
if (!allowed) {
|
|
117
|
+
throw new TypeError(
|
|
118
|
+
`SES cannot initialize unless 'eval' is the original intrinsic 'eval', suitable for direct-eval (dynamically scoped eval) (SES_DIRECT_EVAL)`,
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
90
123
|
/**
|
|
91
124
|
* @param {LockdownOptions} [options]
|
|
92
125
|
* @returns {() => void} repairIntrinsics
|
|
@@ -174,6 +207,8 @@ export const repairIntrinsics = (options = {}) => {
|
|
|
174
207
|
// trace retained:
|
|
175
208
|
priorLockdown.stack;
|
|
176
209
|
|
|
210
|
+
assertDirectEvalAvailable();
|
|
211
|
+
|
|
177
212
|
/**
|
|
178
213
|
* Because of packagers and bundlers, etc, multiple invocations of lockdown
|
|
179
214
|
* might happen in separate instantiations of the source of this module.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Number,
|
|
2
3
|
String,
|
|
3
4
|
TypeError,
|
|
4
5
|
defineProperty,
|
|
@@ -33,9 +34,14 @@ const tamedMethods = {
|
|
|
33
34
|
assert(s === that, d`expected ${q(s)} and ${q(that)} to compare`);
|
|
34
35
|
return 0;
|
|
35
36
|
},
|
|
37
|
+
|
|
38
|
+
toString() {
|
|
39
|
+
return `${this}`;
|
|
40
|
+
},
|
|
36
41
|
};
|
|
37
42
|
|
|
38
43
|
const nonLocaleCompare = tamedMethods.localeCompare;
|
|
44
|
+
const numberToString = tamedMethods.toString;
|
|
39
45
|
|
|
40
46
|
export default function tameLocaleMethods(intrinsics, localeTaming = 'safe') {
|
|
41
47
|
if (localeTaming !== 'safe' && localeTaming !== 'unsafe') {
|
|
@@ -70,4 +76,10 @@ export default function tameLocaleMethods(intrinsics, localeTaming = 'safe') {
|
|
|
70
76
|
}
|
|
71
77
|
}
|
|
72
78
|
}
|
|
79
|
+
|
|
80
|
+
// Numbers are special because toString accepts a radix instead of ignoring
|
|
81
|
+
// all of the arguments that we would otherwise forward.
|
|
82
|
+
defineProperty(Number.prototype, 'toLocaleString', {
|
|
83
|
+
value: numberToString,
|
|
84
|
+
});
|
|
73
85
|
}
|
package/src/whitelist.js
CHANGED
|
@@ -288,6 +288,9 @@ function NativeErrorPrototype(constructor) {
|
|
|
288
288
|
name: 'string',
|
|
289
289
|
// Redundantly present only on v8. Safe to remove.
|
|
290
290
|
toString: false,
|
|
291
|
+
// Superfluously present in some versions of V8.
|
|
292
|
+
// https://github.com/tc39/notes/blob/master/meetings/2021-10/oct-26.md#:~:text=However%2C%20Chrome%2093,and%20node%2016.11.
|
|
293
|
+
cause: false,
|
|
291
294
|
};
|
|
292
295
|
}
|
|
293
296
|
|
|
@@ -552,6 +555,9 @@ export const whitelist = {
|
|
|
552
555
|
at: false,
|
|
553
556
|
// Seen on FF and XS
|
|
554
557
|
stack: false,
|
|
558
|
+
// Superfluously present in some versions of V8.
|
|
559
|
+
// https://github.com/tc39/notes/blob/master/meetings/2021-10/oct-26.md#:~:text=However%2C%20Chrome%2093,and%20node%2016.11.
|
|
560
|
+
cause: false,
|
|
555
561
|
},
|
|
556
562
|
|
|
557
563
|
// NativeError
|