ses 0.18.1 → 0.18.2
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 +5 -0
- package/README.md +9 -4
- package/SECURITY.md +1 -1
- package/dist/lockdown.cjs +171 -146
- package/dist/lockdown.mjs +171 -146
- package/dist/lockdown.umd.js +171 -146
- package/dist/lockdown.umd.min.js +1 -1
- package/dist/ses.cjs +171 -146
- package/dist/ses.mjs +171 -146
- package/dist/ses.umd.js +171 -146
- package/dist/ses.umd.min.js +1 -1
- package/index.js +1 -0
- package/package.json +13 -11
- package/src/commons.js +2 -0
- package/src/compartment-shim.js +3 -3
- package/src/enablements.js +12 -0
- package/src/environment-options.js +10 -19
- package/src/error/assert.js +24 -16
- package/src/error/internal-types.js +3 -3
- package/src/error/types.js +51 -70
- package/src/get-anonymous-intrinsics.js +2 -2
- package/src/get-source-url.js +3 -0
- package/src/global-object.js +9 -9
- package/src/intrinsics.js +1 -1
- package/src/lockdown-shim.js +7 -4
- package/src/make-hardener.js +1 -1
- package/src/make-safe-evaluator.js +4 -4
- package/src/module-instance.js +11 -5
- package/src/module-load.js +1 -1
- package/src/scope-constants.js +2 -2
- package/src/sloppy-globals-scope-terminator.js +1 -0
- package/src/tame-domains.js +1 -0
- package/src/tame-locale-methods.js +2 -2
- package/src/transforms.js +15 -0
- package/src/whitelist-intrinsics.js +2 -2
- package/tools.js +25 -0
- /package/{index.d.ts → types.d.ts} +0 -0
|
@@ -16,9 +16,9 @@ const { Fail } = assert;
|
|
|
16
16
|
* Build the low-level operation used by all evaluators:
|
|
17
17
|
* eval(), Function(), Compartment.prototype.evaluate().
|
|
18
18
|
*
|
|
19
|
-
* @param {
|
|
20
|
-
* @param {
|
|
21
|
-
* @param {
|
|
19
|
+
* @param {object} options
|
|
20
|
+
* @param {object} options.globalObject
|
|
21
|
+
* @param {object} [options.moduleLexicals]
|
|
22
22
|
* @param {Array<Transform>} [options.globalTransforms]
|
|
23
23
|
* @param {bool} [options.sloppyGlobalsMode]
|
|
24
24
|
*/
|
|
@@ -53,7 +53,7 @@ export const makeSafeEvaluator = ({
|
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* @param {string} source
|
|
56
|
-
* @param {
|
|
56
|
+
* @param {object} [options]
|
|
57
57
|
* @param {Array<Transform>} [options.localTransforms]
|
|
58
58
|
*/
|
|
59
59
|
const safeEvaluate = (source, { localTransforms = [] } = {}) => {
|
package/src/module-instance.js
CHANGED
|
@@ -136,6 +136,7 @@ export const makeModuleInstance = (
|
|
|
136
136
|
__liveExportMap__: liveExportMap = {},
|
|
137
137
|
__reexportMap__: reexportMap = {},
|
|
138
138
|
__needsImportMeta__: needsImportMeta = false,
|
|
139
|
+
__syncModuleFunctor__,
|
|
139
140
|
} = staticModuleRecord;
|
|
140
141
|
|
|
141
142
|
const compartmentFields = weakmapGet(privateFields, compartment);
|
|
@@ -444,11 +445,16 @@ export const makeModuleInstance = (
|
|
|
444
445
|
activate();
|
|
445
446
|
}
|
|
446
447
|
|
|
447
|
-
let optFunctor
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
448
|
+
let optFunctor;
|
|
449
|
+
if (__syncModuleFunctor__ !== undefined) {
|
|
450
|
+
optFunctor = __syncModuleFunctor__;
|
|
451
|
+
} else {
|
|
452
|
+
optFunctor = compartmentEvaluate(compartmentFields, functorSource, {
|
|
453
|
+
globalObject: compartment.globalThis,
|
|
454
|
+
transforms: __shimTransforms__,
|
|
455
|
+
__moduleShimLexicals__: moduleLexicals,
|
|
456
|
+
});
|
|
457
|
+
}
|
|
452
458
|
let didThrow = false;
|
|
453
459
|
let thrownError;
|
|
454
460
|
function execute() {
|
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<
|
|
322
|
+
/** @type {Map<object, Map<string, Promise<Record>>} */
|
|
323
323
|
const moduleLoads = new Map();
|
|
324
324
|
/** @type {Array<Error>} */
|
|
325
325
|
const errors = [];
|
package/src/scope-constants.js
CHANGED
|
@@ -143,8 +143,8 @@ function isImmutableDataProperty(obj, name) {
|
|
|
143
143
|
* service if any of the names are keywords or keyword-like. This is
|
|
144
144
|
* safe and only prevent performance optimization.
|
|
145
145
|
*
|
|
146
|
-
* @param {
|
|
147
|
-
* @param {
|
|
146
|
+
* @param {object} globalObject
|
|
147
|
+
* @param {object} moduleLexicals
|
|
148
148
|
*/
|
|
149
149
|
export const getScopeConstants = (globalObject, moduleLexicals = {}) => {
|
|
150
150
|
// getOwnPropertyNames() does ignore Symbols so we don't need to
|
package/src/tame-domains.js
CHANGED
|
@@ -26,6 +26,7 @@ export function tameDomains(domainTaming = 'safe') {
|
|
|
26
26
|
if (domainDescriptor !== undefined && domainDescriptor.get !== undefined) {
|
|
27
27
|
// The domain descriptor on Node.js initially has value: null, which
|
|
28
28
|
// becomes a get, set pair after domains initialize.
|
|
29
|
+
// See https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_NO_DOMAINS.md
|
|
29
30
|
throw new TypeError(
|
|
30
31
|
`SES failed to lockdown, Node.js domains have been initialized (SES_NO_DOMAINS)`,
|
|
31
32
|
);
|
|
@@ -17,14 +17,14 @@ const localePattern = /^(\w*[a-z])Locale([A-Z]\w*)$/;
|
|
|
17
17
|
// behavior or `.prototype` property.
|
|
18
18
|
const tamedMethods = {
|
|
19
19
|
// See https://tc39.es/ecma262/#sec-string.prototype.localecompare
|
|
20
|
-
localeCompare(
|
|
20
|
+
localeCompare(arg) {
|
|
21
21
|
if (this === null || this === undefined) {
|
|
22
22
|
throw new TypeError(
|
|
23
23
|
'Cannot localeCompare with null or undefined "this" value',
|
|
24
24
|
);
|
|
25
25
|
}
|
|
26
26
|
const s = `${this}`;
|
|
27
|
-
that = `${
|
|
27
|
+
const that = `${arg}`;
|
|
28
28
|
if (s < that) {
|
|
29
29
|
return -1;
|
|
30
30
|
}
|
package/src/transforms.js
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
stringSearch,
|
|
8
8
|
stringSlice,
|
|
9
9
|
stringSplit,
|
|
10
|
+
freeze,
|
|
10
11
|
} from './commons.js';
|
|
11
12
|
import { getSourceURL } from './get-source-url.js';
|
|
12
13
|
|
|
@@ -69,6 +70,7 @@ export const rejectHtmlComments = src => {
|
|
|
69
70
|
return src;
|
|
70
71
|
}
|
|
71
72
|
const name = getSourceURL(src);
|
|
73
|
+
// See https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_HTML_COMMENT_REJECTED.md
|
|
72
74
|
throw new SyntaxError(
|
|
73
75
|
`Possible HTML comment rejected at ${name}:${lineNumber}. (SES_HTML_COMMENT_REJECTED)`,
|
|
74
76
|
);
|
|
@@ -144,6 +146,7 @@ export const rejectImportExpressions = src => {
|
|
|
144
146
|
return src;
|
|
145
147
|
}
|
|
146
148
|
const name = getSourceURL(src);
|
|
149
|
+
// See https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_IMPORT_REJECTED.md
|
|
147
150
|
throw new SyntaxError(
|
|
148
151
|
`Possible import expression rejected at ${name}:${lineNumber}. (SES_IMPORT_REJECTED)`,
|
|
149
152
|
);
|
|
@@ -215,6 +218,7 @@ export const rejectSomeDirectEvalExpressions = src => {
|
|
|
215
218
|
return src;
|
|
216
219
|
}
|
|
217
220
|
const name = getSourceURL(src);
|
|
221
|
+
// See https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_EVAL_REJECTED.md
|
|
218
222
|
throw new SyntaxError(
|
|
219
223
|
`Possible direct eval expression rejected at ${name}:${lineNumber}. (SES_EVAL_REJECTED)`,
|
|
220
224
|
);
|
|
@@ -249,3 +253,14 @@ export const applyTransforms = (source, transforms) => {
|
|
|
249
253
|
}
|
|
250
254
|
return source;
|
|
251
255
|
};
|
|
256
|
+
|
|
257
|
+
// export all as a frozen object
|
|
258
|
+
export const transforms = freeze({
|
|
259
|
+
rejectHtmlComments: freeze(rejectHtmlComments),
|
|
260
|
+
evadeHtmlCommentTest: freeze(evadeHtmlCommentTest),
|
|
261
|
+
rejectImportExpressions: freeze(rejectImportExpressions),
|
|
262
|
+
evadeImportExpressionTest: freeze(evadeImportExpressionTest),
|
|
263
|
+
rejectSomeDirectEvalExpressions: freeze(rejectSomeDirectEvalExpressions),
|
|
264
|
+
mandatoryTransforms: freeze(mandatoryTransforms),
|
|
265
|
+
applyTransforms: freeze(applyTransforms),
|
|
266
|
+
});
|
|
@@ -66,8 +66,8 @@ import {
|
|
|
66
66
|
* Removes all non-allowed properties found by recursively and
|
|
67
67
|
* reflectively walking own property chains.
|
|
68
68
|
*
|
|
69
|
-
* @param {
|
|
70
|
-
* @param {(
|
|
69
|
+
* @param {object} intrinsics
|
|
70
|
+
* @param {(object) => void} markVirtualizedNativeFunction
|
|
71
71
|
*/
|
|
72
72
|
export default function whitelistIntrinsics(
|
|
73
73
|
intrinsics,
|
package/tools.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Copyright (C) 2018 Agoric
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
import { freeze } from './src/commons.js';
|
|
16
|
+
import { transforms } from './src/transforms.js';
|
|
17
|
+
import { strictScopeTerminator } from './src/strict-scope-terminator.js';
|
|
18
|
+
import { createSloppyGlobalsScopeTerminator } from './src/sloppy-globals-scope-terminator.js';
|
|
19
|
+
|
|
20
|
+
export { transforms };
|
|
21
|
+
|
|
22
|
+
export const scopeTerminators = freeze({
|
|
23
|
+
strictScopeTerminator,
|
|
24
|
+
createSloppyGlobalsScopeTerminator,
|
|
25
|
+
});
|
|
File without changes
|