@memberjunction/templates 6.2.0-edge.2 → 6.2.0-edge.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/README.md +62 -0
- package/dist/InheritedMemberNames.d.ts +12 -0
- package/dist/InheritedMemberNames.d.ts.map +1 -0
- package/dist/InheritedMemberNames.js +19 -0
- package/dist/InheritedMemberNames.js.map +1 -0
- package/dist/NunjucksCompileGuard.d.ts +17 -0
- package/dist/NunjucksCompileGuard.d.ts.map +1 -0
- package/dist/NunjucksCompileGuard.js +273 -0
- package/dist/NunjucksCompileGuard.js.map +1 -0
- package/dist/NunjucksSandbox.d.ts +26 -0
- package/dist/NunjucksSandbox.d.ts.map +1 -0
- package/dist/NunjucksSandbox.js +292 -0
- package/dist/NunjucksSandbox.js.map +1 -0
- package/dist/TemplateEngine.d.ts.map +1 -1
- package/dist/TemplateEngine.js +5 -0
- package/dist/TemplateEngine.js.map +1 -1
- package/dist/TemplateSandboxError.d.ts +9 -0
- package/dist/TemplateSandboxError.d.ts.map +1 -0
- package/dist/TemplateSandboxError.js +12 -0
- package/dist/TemplateSandboxError.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/operations/TemplateRunAuthorization.d.ts +20 -0
- package/dist/operations/TemplateRunAuthorization.d.ts.map +1 -0
- package/dist/operations/TemplateRunAuthorization.js +37 -0
- package/dist/operations/TemplateRunAuthorization.js.map +1 -0
- package/dist/operations/TemplateRunOperation.d.ts +6 -0
- package/dist/operations/TemplateRunOperation.d.ts.map +1 -1
- package/dist/operations/TemplateRunOperation.js +10 -1
- package/dist/operations/TemplateRunOperation.js.map +1 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -124,6 +124,68 @@ The engine provides built-in filters for JSON operations:
|
|
|
124
124
|
{% set parsed = jsonString | jsonparse %}
|
|
125
125
|
```
|
|
126
126
|
|
|
127
|
+
### Template Sandbox
|
|
128
|
+
|
|
129
|
+
Users can edit stored templates, so the engine guards nunjucks when this package loads
|
|
130
|
+
(`HardenNunjucksRuntime()`). The guard is process-wide: it also covers nunjucks environments that
|
|
131
|
+
other packages create, and templates loaded through `include` and `import`. It checks templates at
|
|
132
|
+
two points.
|
|
133
|
+
|
|
134
|
+
**Before a template compiles.** The nunjucks compiler copies names from the template into the code it
|
|
135
|
+
generates, so `AssertTemplateTreeIsSafe()` checks every parsed template first:
|
|
136
|
+
|
|
137
|
+
- Variable, filter, loop, `set`, macro, import and block names must be plain names: letters,
|
|
138
|
+
combining marks, digits, connector characters such as `_`, and `$`. A filter name can also contain
|
|
139
|
+
dots.
|
|
140
|
+
- A test name (`is defined`, `is none`) and an extension's registered name and method must not
|
|
141
|
+
contain a quote, a backslash or a line break.
|
|
142
|
+
- A name that every object inherits (a member of `Object.prototype`, such as `toString`,
|
|
143
|
+
`hasOwnProperty` or `constructor`), or `prototype`, must not be used as a dictionary key, a keyword
|
|
144
|
+
argument, a macro or call-block argument, a `set`, loop, import, macro or block name, or a filter or
|
|
145
|
+
test name. The code generator also refuses such a name as a dictionary key or keyword argument. Bare
|
|
146
|
+
names and member reads are not in this rule: `{{ constructor }}` reads only an own key of the render
|
|
147
|
+
data, and a member read such as `obj.constructor` or `value.toLocaleString()` goes through the
|
|
148
|
+
render-time member check (see below).
|
|
149
|
+
- The name of a called member, such as `obj["key"]()`, must not contain a backslash or a line break.
|
|
150
|
+
- A loop variable must not reuse an identifier that the generated loop code uses, such as `context`,
|
|
151
|
+
`frame`, `runtime`, `env`, `cb`, `next`, `tasks` or `undefined`. A unit test compiles every kind of
|
|
152
|
+
loop body with nunjucks 3.2.4, including loops inside macros and blocks, and checks this list against
|
|
153
|
+
the generated code, so a nunjucks upgrade that adds an identifier fails the test.
|
|
154
|
+
- The parse tree may hold only nunjucks nodes, plain values and regular expression literals. This
|
|
155
|
+
matters only for extensions, which build their own nodes.
|
|
156
|
+
|
|
157
|
+
**While a template renders.**
|
|
158
|
+
|
|
159
|
+
- A filter, test or global resolves only to a name that the environment registered itself, never to a
|
|
160
|
+
member that every object inherits. This also covers the test names that the `select` and `reject`
|
|
161
|
+
filters receive while the template renders. Such a name must be text, a number or another simple
|
|
162
|
+
value such as `none`; an object, a function or a symbol is refused.
|
|
163
|
+
- The member names `constructor`, `prototype` and the `__define/lookup Getter/Setter__` accessors read
|
|
164
|
+
as empty unless they hold an object's own data that is not a function. `__proto__` always reads as
|
|
165
|
+
empty. This applies to a literal member name (`obj.name`, `obj["name"]`) and to one computed while
|
|
166
|
+
the template renders (`obj[key]`) alike.
|
|
167
|
+
- A bare name such as `{{ user }}` resolves only to a template variable, an own key of the render data,
|
|
168
|
+
or an own environment global. It never resolves to a property that the data or the globals inherit,
|
|
169
|
+
such as `valueOf`.
|
|
170
|
+
- A macro or call-block argument that a call leaves out is filled only from a keyword argument of the
|
|
171
|
+
same name that the call itself passes, never from a member that the keyword arguments inherit, so
|
|
172
|
+
otherwise it reads as empty. Keyword arguments written at a call site must be a plain object literal
|
|
173
|
+
with ordinary names; keyword arguments passed as a value (from render data, for example) are read
|
|
174
|
+
through a copy of their own keys.
|
|
175
|
+
- A template must not read a member of the render context, an environment, a loader, a frame, a
|
|
176
|
+
template or a nunjucks module. A lookup or call that would return one of them fails.
|
|
177
|
+
- A template must not reach `Function` (or its async and generator variants), `eval`, `Object`,
|
|
178
|
+
`Reflect`, `globalThis` or `process`.
|
|
179
|
+
|
|
180
|
+
A template that breaks one of these rules fails with a `TemplateSandboxError`.
|
|
181
|
+
|
|
182
|
+
The guard blocks reflection and code injection, not ordinary methods. Pass templates plain data, not
|
|
183
|
+
objects whose methods reach the database or the file system (for example `BaseEntity` instances).
|
|
184
|
+
|
|
185
|
+
The `RunTemplate` mutation and the `Template.Run` remote operation also apply
|
|
186
|
+
`GetTemplateRunRefusal()` before they load anything: they refuse scope-limited sessions and callers
|
|
187
|
+
without read permission on `MJ: Templates` and `MJ: Template Contents`.
|
|
188
|
+
|
|
127
189
|
### Template Extensions
|
|
128
190
|
|
|
129
191
|
Extensions are registered via the MJ class factory:
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The one list of names that the template sandbox refuses wherever a template names something.
|
|
3
|
+
* @module @memberjunction/templates
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* True for a name that a template may not use as a dictionary key, a keyword argument, a macro or call-block
|
|
7
|
+
* argument, a variable, macro or block name, or a filter or test name. nunjucks reads and writes such names
|
|
8
|
+
* on plain objects, where they reach inherited members or the object's prototype.
|
|
9
|
+
* @param name the name as nunjucks uses it
|
|
10
|
+
*/
|
|
11
|
+
export declare function IsInheritedMemberName(name: string): boolean;
|
|
12
|
+
//# sourceMappingURL=InheritedMemberNames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InheritedMemberNames.d.ts","sourceRoot":"","sources":["../src/InheritedMemberNames.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE3D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The one list of names that the template sandbox refuses wherever a template names something.
|
|
3
|
+
* @module @memberjunction/templates
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The members of `Object.prototype`, which every plain object inherits (such as `constructor`, `toString`
|
|
7
|
+
* and `__proto__`), and `prototype`, which leads from a constructor to what its instances inherit.
|
|
8
|
+
*/
|
|
9
|
+
const INHERITED_MEMBER_NAMES = new Set([...Object.getOwnPropertyNames(Object.prototype), 'prototype']);
|
|
10
|
+
/**
|
|
11
|
+
* True for a name that a template may not use as a dictionary key, a keyword argument, a macro or call-block
|
|
12
|
+
* argument, a variable, macro or block name, or a filter or test name. nunjucks reads and writes such names
|
|
13
|
+
* on plain objects, where they reach inherited members or the object's prototype.
|
|
14
|
+
* @param name the name as nunjucks uses it
|
|
15
|
+
*/
|
|
16
|
+
export function IsInheritedMemberName(name) {
|
|
17
|
+
return INHERITED_MEMBER_NAMES.has(name);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=InheritedMemberNames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InheritedMemberNames.js","sourceRoot":"","sources":["../src/InheritedMemberNames.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,sBAAsB,GAAwB,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;AAE5H;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAC9C,OAAO,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks a parsed nunjucks template, and throws a {@link TemplateSandboxError} if a name in it could
|
|
3
|
+
* change the code the compiler generates:
|
|
4
|
+
* - every variable, filter, loop, `set`, macro, import and block name must be a plain name (letters,
|
|
5
|
+
* combining marks, digits, connector punctuation such as `_`, and `$`); a filter name can also contain dots
|
|
6
|
+
* - a test name, and an extension's registered name and method, must not contain a quote, a backslash or a line break
|
|
7
|
+
* - a name that every object inherits (`toString`, `hasOwnProperty`, ...), or `prototype`, must not be a
|
|
8
|
+
* dictionary key, a keyword argument, a macro or call-block argument, a `set`, loop, import, macro or
|
|
9
|
+
* block name, or a filter or test name
|
|
10
|
+
* - the name of a called member must not contain a backslash or a line break
|
|
11
|
+
* - a loop variable must not reuse an identifier that the generated loop code uses (`context`, `frame`,
|
|
12
|
+
* `runtime`, `tasks`, `undefined`, ...)
|
|
13
|
+
* - the tree must hold only nunjucks nodes, plain values and regular expression literals
|
|
14
|
+
* @param tree the root node the nunjucks parser returns
|
|
15
|
+
*/
|
|
16
|
+
export declare function AssertTemplateTreeIsSafe(tree: unknown): void;
|
|
17
|
+
//# sourceMappingURL=NunjucksCompileGuard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NunjucksCompileGuard.d.ts","sourceRoot":"","sources":["../src/NunjucksCompileGuard.ts"],"names":[],"mappings":"AA6DA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAE5D"}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Refuses nunjucks templates whose names could change the code nunjucks compiles.
|
|
3
|
+
*
|
|
4
|
+
* The nunjucks 3.2.4 compiler copies template-controlled names into the JavaScript it generates
|
|
5
|
+
* without escaping them. That covers variable, filter, test and loop names; the names that `set`,
|
|
6
|
+
* `macro`, `import` and `from` bind; and the name of a called member. The generated code runs when
|
|
7
|
+
* the template renders, so the runtime guard in `NunjucksSandbox.ts` never sees it. nunjucks also
|
|
8
|
+
* reads and writes template names as keys of plain objects, so a name that every object inherits is
|
|
9
|
+
* refused as a key, an argument or a binding. Bare names and member reads are left to the runtime guard.
|
|
10
|
+
* {@link AssertTemplateTreeIsSafe} checks a parsed template before it compiles.
|
|
11
|
+
* @module @memberjunction/templates
|
|
12
|
+
*/
|
|
13
|
+
import nunjucks from 'nunjucks';
|
|
14
|
+
import { IsInheritedMemberName } from './InheritedMemberNames.js';
|
|
15
|
+
import { TemplateSandboxError } from './TemplateSandboxError.js';
|
|
16
|
+
const NUNJUCKS = nunjucks;
|
|
17
|
+
/**
|
|
18
|
+
* Letters, combining marks, decimal digits, connector punctuation (such as `_`) and `$`. Each one is safe
|
|
19
|
+
* inside a JavaScript string. In a raw identifier, a character that cannot start it (a digit, a mark, or
|
|
20
|
+
* connector punctuation other than `_`) or cannot appear in it at all (U+2E2F) only makes the generated
|
|
21
|
+
* code fail with a SyntaxError.
|
|
22
|
+
*/
|
|
23
|
+
const PLAIN_NAME = /^[\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}$]+$/u;
|
|
24
|
+
/** A filter name can also contain dots (`{{ x | ns.filter }}`). */
|
|
25
|
+
const PLAIN_FILTER_NAME = /^[\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}$]+(?:\.[\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}$]+)*$/u;
|
|
26
|
+
/** Characters that end a double-quoted JavaScript string, or escape out of it. */
|
|
27
|
+
const UNSAFE_STRING_CHARACTERS = /["\\\r\n\u2028\u2029]/;
|
|
28
|
+
/** The compiler escapes `"` in a called member's name, so only these characters can end that string. */
|
|
29
|
+
const UNSAFE_CALL_NAME_CHARACTERS = /[\\\r\n\u2028\u2029]/;
|
|
30
|
+
/**
|
|
31
|
+
* Identifiers that the generated code of a loop body uses (nunjucks 3.2.4). An async loop binds its loop
|
|
32
|
+
* variables as raw function parameters, so a loop variable with one of these names shadows them.
|
|
33
|
+
* `NunjucksCompileGuard.test.ts` compiles every kind of loop body and checks this list against the
|
|
34
|
+
* generated code.
|
|
35
|
+
*/
|
|
36
|
+
const RESERVED_LOOP_NAMES = new Set([
|
|
37
|
+
'env', 'context', 'frame', 'runtime', 'cb', 'next', 'lineno', 'colno', 'output', 'tasks',
|
|
38
|
+
'parentTemplate', 'callerFrame', 'kwargs', 'Object', 'Math', 'Error', 'undefined', 'Infinity',
|
|
39
|
+
]);
|
|
40
|
+
/** Prefixes of generated identifiers: temporaries (`t_3`, `macro_t_3`, `hole_0`), blocks (`b_`), macro arguments (`l_`). */
|
|
41
|
+
const RESERVED_LOOP_NAME_PREFIX = /^(?:t|macro_t|hole|b|l)_/;
|
|
42
|
+
/**
|
|
43
|
+
* Checks a parsed nunjucks template, and throws a {@link TemplateSandboxError} if a name in it could
|
|
44
|
+
* change the code the compiler generates:
|
|
45
|
+
* - every variable, filter, loop, `set`, macro, import and block name must be a plain name (letters,
|
|
46
|
+
* combining marks, digits, connector punctuation such as `_`, and `$`); a filter name can also contain dots
|
|
47
|
+
* - a test name, and an extension's registered name and method, must not contain a quote, a backslash or a line break
|
|
48
|
+
* - a name that every object inherits (`toString`, `hasOwnProperty`, ...), or `prototype`, must not be a
|
|
49
|
+
* dictionary key, a keyword argument, a macro or call-block argument, a `set`, loop, import, macro or
|
|
50
|
+
* block name, or a filter or test name
|
|
51
|
+
* - the name of a called member must not contain a backslash or a line break
|
|
52
|
+
* - a loop variable must not reuse an identifier that the generated loop code uses (`context`, `frame`,
|
|
53
|
+
* `runtime`, `tasks`, `undefined`, ...)
|
|
54
|
+
* - the tree must hold only nunjucks nodes, plain values and regular expression literals
|
|
55
|
+
* @param tree the root node the nunjucks parser returns
|
|
56
|
+
*/
|
|
57
|
+
export function AssertTemplateTreeIsSafe(tree) {
|
|
58
|
+
new TemplateTreeCheck().Visit(tree);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* One pass over a parse tree. It visits every own property of every node, not only the fields
|
|
62
|
+
* nunjucks lists, because the parser stores some compiled parts outside them (the body of a `set` block).
|
|
63
|
+
*/
|
|
64
|
+
class TemplateTreeCheck {
|
|
65
|
+
constructor() {
|
|
66
|
+
this.visited = new WeakSet();
|
|
67
|
+
this.filterNames = new WeakSet();
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Checks a value of the tree and everything under it.
|
|
71
|
+
* @param owner the node whose field holds the value
|
|
72
|
+
* @param field the name of that field
|
|
73
|
+
*/
|
|
74
|
+
Visit(value, owner, field) {
|
|
75
|
+
if (Array.isArray(value)) {
|
|
76
|
+
asArray(value).forEach((item) => this.Visit(item, owner, field));
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (!isNode(value)) {
|
|
80
|
+
if (!isPlainValue(value) && !isPatternLiteral(value, owner, field)) {
|
|
81
|
+
throw refusal('Template parse trees may only hold nunjucks nodes, plain values and regular expressions', owner);
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (this.visited.has(value)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this.visited.add(value);
|
|
89
|
+
this.checkNode(value);
|
|
90
|
+
for (const key of Object.keys(value)) {
|
|
91
|
+
this.Visit(property(value, key), value, key);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
checkNode(node) {
|
|
95
|
+
switch (node.typename) {
|
|
96
|
+
case 'Symbol':
|
|
97
|
+
return this.checkName(node, node, this.filterNames.has(node) ? PLAIN_FILTER_NAME : PLAIN_NAME);
|
|
98
|
+
case 'Pair':
|
|
99
|
+
return this.refuseInheritedName(nameValue(property(node, 'key')), node, 'a dictionary key or keyword argument');
|
|
100
|
+
case 'Filter':
|
|
101
|
+
case 'FilterAsync':
|
|
102
|
+
return this.checkFilterName(node);
|
|
103
|
+
case 'Is':
|
|
104
|
+
return this.checkTestName(node);
|
|
105
|
+
case 'FunCall':
|
|
106
|
+
return this.checkCallName(node);
|
|
107
|
+
case 'Set':
|
|
108
|
+
return asArray(property(node, 'targets')).forEach((target) => this.checkBindingName(target, node));
|
|
109
|
+
case 'For':
|
|
110
|
+
case 'AsyncEach':
|
|
111
|
+
case 'AsyncAll':
|
|
112
|
+
return this.checkLoopNames(node);
|
|
113
|
+
case 'Macro':
|
|
114
|
+
case 'Caller':
|
|
115
|
+
return this.checkMacroNames(node);
|
|
116
|
+
case 'Import':
|
|
117
|
+
return this.checkBindingName(property(node, 'target'), node);
|
|
118
|
+
case 'FromImport':
|
|
119
|
+
return this.checkImportedNames(node);
|
|
120
|
+
case 'Block':
|
|
121
|
+
return this.checkBindingName(property(node, 'name'), node);
|
|
122
|
+
case 'Super':
|
|
123
|
+
return this.checkName(property(node, 'blockName'), node);
|
|
124
|
+
case 'CallExtension':
|
|
125
|
+
case 'CallExtensionAsync':
|
|
126
|
+
return this.checkExtensionCall(node);
|
|
127
|
+
default:
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/** A name the compiler copies as written: a symbol or a quoted string that is a plain name. */
|
|
132
|
+
checkName(nameNode, owner, pattern = PLAIN_NAME) {
|
|
133
|
+
const name = nameValue(nameNode);
|
|
134
|
+
if (name === undefined || !pattern.test(name)) {
|
|
135
|
+
throw refusal('Templates may only use plain names (letters, marks, digits, _ and $)', owner);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/** The one rule for every position that names something: a name that `IsInheritedMemberName` matches is refused. */
|
|
139
|
+
refuseInheritedName(name, owner, position) {
|
|
140
|
+
if (name !== undefined && IsInheritedMemberName(name)) {
|
|
141
|
+
throw refusal(`Templates may not use "${name}" as ${position}`, owner);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/** A name that `set`, a loop, `import`, `from` or `macro` binds as a variable, or a block name. */
|
|
145
|
+
checkBindingName(nameNode, owner) {
|
|
146
|
+
this.checkName(nameNode, owner);
|
|
147
|
+
this.refuseInheritedName(nameValue(nameNode), owner, 'a variable, macro or block name');
|
|
148
|
+
}
|
|
149
|
+
/** nunjucks finds a filter in a plain object, so a name it inherits would resolve to the inherited member. */
|
|
150
|
+
checkFilterName(node) {
|
|
151
|
+
const name = property(node, 'name');
|
|
152
|
+
if (isNode(name)) {
|
|
153
|
+
this.filterNames.add(name);
|
|
154
|
+
}
|
|
155
|
+
this.checkName(name, node, PLAIN_FILTER_NAME);
|
|
156
|
+
this.refuseInheritedName(nameValue(name), node, 'a filter or test name');
|
|
157
|
+
}
|
|
158
|
+
/** The compiler writes the test name into a double-quoted string, as text and without escaping it. */
|
|
159
|
+
checkTestName(node) {
|
|
160
|
+
const name = testName(node);
|
|
161
|
+
if (UNSAFE_STRING_CHARACTERS.test(name)) {
|
|
162
|
+
throw refusal('Templates may not use a test name that contains a quote, a backslash or a line break', node);
|
|
163
|
+
}
|
|
164
|
+
this.refuseInheritedName(name, node, 'a filter or test name');
|
|
165
|
+
}
|
|
166
|
+
/** The compiler writes the called expression's name, built by its own `_getNodeName`, into a string. */
|
|
167
|
+
checkCallName(node) {
|
|
168
|
+
let name;
|
|
169
|
+
try {
|
|
170
|
+
const compiler = NUNJUCKS.compiler.Compiler.prototype;
|
|
171
|
+
name = compiler._getNodeName.call(compiler, property(node, 'name'));
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
name = undefined;
|
|
175
|
+
}
|
|
176
|
+
if (typeof name !== 'string' || UNSAFE_CALL_NAME_CHARACTERS.test(name)) {
|
|
177
|
+
throw refusal('Templates may not call a member whose name contains a backslash or a line break', node);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
checkLoopNames(node) {
|
|
181
|
+
const name = property(node, 'name');
|
|
182
|
+
const loopNames = isNode(name) && name.typename === 'Array' ? asArray(property(name, 'children')) : [name];
|
|
183
|
+
for (const loopName of loopNames) {
|
|
184
|
+
this.checkBindingName(loopName, node);
|
|
185
|
+
const value = nameValue(loopName) ?? '';
|
|
186
|
+
if (RESERVED_LOOP_NAMES.has(value) || RESERVED_LOOP_NAME_PREFIX.test(value)) {
|
|
187
|
+
throw refusal(`Templates may not use "${value}" as a loop variable`, node);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/** Positional arguments, and the keys of a trailing keyword-argument dictionary, become names. */
|
|
192
|
+
checkMacroNames(node) {
|
|
193
|
+
this.checkBindingName(property(node, 'name'), node);
|
|
194
|
+
const args = asArray(property(property(node, 'args'), 'children'));
|
|
195
|
+
args.forEach((arg, index) => {
|
|
196
|
+
const isKeywordArguments = index === args.length - 1 && isNode(arg) && (arg.typename === 'Dict' || arg.typename === 'KeywordArgs');
|
|
197
|
+
if (!isKeywordArguments) {
|
|
198
|
+
this.checkArgumentName(arg, node);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
asArray(property(arg, 'children')).forEach((pair) => this.checkArgumentName(property(pair, 'key'), node));
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* A macro or call-block argument. When a call leaves out a positional argument, nunjucks fills it from the
|
|
206
|
+
* call's keyword arguments, so an argument named after a member every object inherits would read that member.
|
|
207
|
+
*/
|
|
208
|
+
checkArgumentName(nameNode, owner) {
|
|
209
|
+
this.checkName(nameNode, owner);
|
|
210
|
+
this.refuseInheritedName(nameValue(nameNode), owner, 'a macro or call-block argument');
|
|
211
|
+
}
|
|
212
|
+
/** The names `from ... import` reads from the imported template, and the names it binds. */
|
|
213
|
+
checkImportedNames(node) {
|
|
214
|
+
for (const entry of asArray(property(property(node, 'names'), 'children'))) {
|
|
215
|
+
if (isNode(entry) && entry.typename === 'Pair') {
|
|
216
|
+
this.checkBindingName(property(entry, 'key'), node);
|
|
217
|
+
this.checkBindingName(property(entry, 'value'), node);
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
this.checkBindingName(entry, node);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/** The compiler writes an extension tag's registered name and method into double-quoted strings. */
|
|
225
|
+
checkExtensionCall(node) {
|
|
226
|
+
for (const value of [property(node, 'extName'), property(node, 'prop')]) {
|
|
227
|
+
if (typeof value !== 'string' || UNSAFE_STRING_CHARACTERS.test(value)) {
|
|
228
|
+
throw refusal('Template extensions must have names without a quote, a backslash or a line break', node);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* The test name as the compiler writes it: the text of the called name's value for `is test(...)`,
|
|
235
|
+
* else the text of the test's own value. `is none` gives `"null"`.
|
|
236
|
+
*/
|
|
237
|
+
function testName(node) {
|
|
238
|
+
const test = property(node, 'right');
|
|
239
|
+
const calledName = property(test, 'name');
|
|
240
|
+
return String(calledName ? property(calledName, 'value') : property(test, 'value'));
|
|
241
|
+
}
|
|
242
|
+
function isNode(value) {
|
|
243
|
+
return value instanceof NUNJUCKS.nodes.Node;
|
|
244
|
+
}
|
|
245
|
+
/** `undefined`, `null`, a string, a number or a boolean. */
|
|
246
|
+
function isPlainValue(value) {
|
|
247
|
+
return value === undefined || value === null || typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';
|
|
248
|
+
}
|
|
249
|
+
/** A regular expression literal (`r/.../`), which the parser stores as the value of a Literal node. */
|
|
250
|
+
function isPatternLiteral(value, owner, field) {
|
|
251
|
+
return value instanceof RegExp && owner?.typename === 'Literal' && field === 'value';
|
|
252
|
+
}
|
|
253
|
+
/** A node's field, or `undefined` when the value is not a node. */
|
|
254
|
+
function property(node, key) {
|
|
255
|
+
return isNode(node) ? node[key] : undefined;
|
|
256
|
+
}
|
|
257
|
+
function asArray(value) {
|
|
258
|
+
return Array.isArray(value) ? value : [];
|
|
259
|
+
}
|
|
260
|
+
/** The text of a symbol or of a quoted string, or `undefined` for any other node. */
|
|
261
|
+
function nameValue(node) {
|
|
262
|
+
if (!isNode(node) || (node.typename !== 'Symbol' && node.typename !== 'Literal')) {
|
|
263
|
+
return undefined;
|
|
264
|
+
}
|
|
265
|
+
const value = property(node, 'value');
|
|
266
|
+
return typeof value === 'string' ? value : undefined;
|
|
267
|
+
}
|
|
268
|
+
/** The error for a refused template, with the node's position when the node has one. */
|
|
269
|
+
function refusal(reason, node) {
|
|
270
|
+
const hasPosition = node !== undefined && Number.isInteger(node.lineno) && Number.isInteger(node.colno);
|
|
271
|
+
return new TemplateSandboxError(hasPosition ? `${reason} (line ${node.lineno + 1}, column ${node.colno + 1})` : reason);
|
|
272
|
+
}
|
|
273
|
+
//# sourceMappingURL=NunjucksCompileGuard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NunjucksCompileGuard.js","sourceRoot":"","sources":["../src/NunjucksCompileGuard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,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,MAAc,EAAE,IAA8B;IAC3D,MAAM,WAAW,GAAG,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxG,OAAO,IAAI,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,MAAM,UAAU,IAAI,CAAC,MAAM,GAAG,CAAC,YAAY,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAC5H,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guards the nunjucks parser, code generator and runtime used by every nunjucks environment in this process. After this call:
|
|
3
|
+
* - a template whose names could change the compiled code fails to compile (see `AssertTemplateTreeIsSafe`)
|
|
4
|
+
* - a macro or call-block argument that a call leaves out is filled only from a keyword argument that the
|
|
5
|
+
* call itself passes under that name, never from a member the keyword arguments inherit, so otherwise it
|
|
6
|
+
* reads as empty
|
|
7
|
+
* - keyword arguments written at a call site must be an ordinary object literal: ones that inherit from anything
|
|
8
|
+
* but `Object.prototype`, or that use a name that every object inherits (or `prototype`), throw, and the code
|
|
9
|
+
* generator refuses such a name as a dictionary key or keyword argument too; keyword arguments passed as a
|
|
10
|
+
* value (from render data, for example) are read through a copy of their own keys
|
|
11
|
+
* - a filter, test or global resolves only to a name the environment registered itself, never to a member
|
|
12
|
+
* that every object inherits (such as `hasOwnProperty`); an object, a function or a symbol is refused as the name
|
|
13
|
+
* - a member named `constructor`, `prototype`, `__proto__` or one of the `__define/lookup Getter/Setter__`
|
|
14
|
+
* accessors, written literally or computed while rendering, reads as `undefined`, unless it is an object's
|
|
15
|
+
* own data that is not a function; `__proto__` always reads as `undefined`
|
|
16
|
+
* - a bare name resolves only to a template variable, an own key of the render data, or an own environment
|
|
17
|
+
* global, never to a property that the render data or the globals inherit
|
|
18
|
+
* - a template may not read a member of the render context, an environment, a loader, a frame, a
|
|
19
|
+
* template or a nunjucks module, and a lookup or call that would return one of them throws
|
|
20
|
+
* - a lookup or call that would produce or use `Function` (or its async and generator variants), `eval`,
|
|
21
|
+
* `Object`, `Reflect`, `globalThis` or `process` throws a {@link TemplateSandboxError}
|
|
22
|
+
*
|
|
23
|
+
* Safe to call any number of times: a hook that already carries the guard is left as it is.
|
|
24
|
+
*/
|
|
25
|
+
export declare function HardenNunjucksRuntime(): void;
|
|
26
|
+
//# sourceMappingURL=NunjucksSandbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NunjucksSandbox.d.ts","sourceRoot":"","sources":["../src/NunjucksSandbox.ts"],"names":[],"mappings":"AAiIA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAY5C"}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Guards nunjucks so templates cannot run JavaScript or reach server objects.
|
|
3
|
+
*
|
|
4
|
+
* nunjucks has no sandbox mode, and a template can attack it at two points:
|
|
5
|
+
* - **Compile time.** The compiler copies template-controlled names into the code it generates.
|
|
6
|
+
* {@link HardenNunjucksRuntime} wraps the parser that the compiler calls, so every parsed template is
|
|
7
|
+
* checked by `AssertTemplateTreeIsSafe` (`NunjucksCompileGuard.ts`) before it compiles. It also wraps
|
|
8
|
+
* the code generator's `compilePair`, which writes dictionary keys and keyword arguments.
|
|
9
|
+
* - **Render time.** Every compiled template resolves bare names, member access and calls through
|
|
10
|
+
* three functions on nunjucks' shared runtime module: `contextOrFrameLookup`, `memberLookup` and
|
|
11
|
+
* `callWrap`. It builds macros with `makeMacro` and marks keyword arguments with `makeKeywordArgs`, and
|
|
12
|
+
* it finds filters and tests with the environment's `getFilter` and `getTest`, which read plain
|
|
13
|
+
* objects. Unguarded, a template can walk from any value to `Function`, or reach the render context
|
|
14
|
+
* and change the shared environment. {@link HardenNunjucksRuntime} wraps those functions in place.
|
|
15
|
+
*
|
|
16
|
+
* The parser, the code generator, the runtime module and the `Environment` prototype are shared by every
|
|
17
|
+
* nunjucks environment in the process, so the guard covers all of them, including templates loaded
|
|
18
|
+
* through `include` and `import`.
|
|
19
|
+
* @module @memberjunction/templates
|
|
20
|
+
*/
|
|
21
|
+
import nunjucks from 'nunjucks';
|
|
22
|
+
import { IsInheritedMemberName } from './InheritedMemberNames.js';
|
|
23
|
+
import { AssertTemplateTreeIsSafe } from './NunjucksCompileGuard.js';
|
|
24
|
+
import { TemplateSandboxError } from './TemplateSandboxError.js';
|
|
25
|
+
const NUNJUCKS = nunjucks;
|
|
26
|
+
/** Member names that lead from a value to its constructor or prototype, and from there to `Function`. */
|
|
27
|
+
const RESTRICTED_MEMBER_NAMES = new Set([
|
|
28
|
+
'constructor',
|
|
29
|
+
'prototype',
|
|
30
|
+
'__proto__',
|
|
31
|
+
'__defineGetter__',
|
|
32
|
+
'__defineSetter__',
|
|
33
|
+
'__lookupGetter__',
|
|
34
|
+
'__lookupSetter__',
|
|
35
|
+
]);
|
|
36
|
+
/** Values a template may never hold: constructors that compile code from strings, and reflection over any object. */
|
|
37
|
+
const RESTRICTED_VALUES = new Set([
|
|
38
|
+
Function,
|
|
39
|
+
(async () => undefined).constructor,
|
|
40
|
+
(function* () { }).constructor,
|
|
41
|
+
(async function* () { }).constructor,
|
|
42
|
+
globalThis.eval,
|
|
43
|
+
Object,
|
|
44
|
+
Reflect,
|
|
45
|
+
globalThis,
|
|
46
|
+
globalThis.process,
|
|
47
|
+
].filter((value) => value !== undefined && value !== null));
|
|
48
|
+
/** nunjucks' base `Obj` class, which render contexts and templates extend. */
|
|
49
|
+
const NUNJUCKS_OBJ_PROTOTYPE = Object.getPrototypeOf(NUNJUCKS.Template.prototype);
|
|
50
|
+
/** nunjucks' base `EmitterObj` class, which environments and loaders extend. */
|
|
51
|
+
const NUNJUCKS_EMITTER_PROTOTYPE = Object.getPrototypeOf(NUNJUCKS.Environment.prototype);
|
|
52
|
+
/** Prototypes of the objects nunjucks uses to render: contexts and templates, environments and loaders, and frames. */
|
|
53
|
+
const NUNJUCKS_OBJECT_PROTOTYPES = [NUNJUCKS_OBJ_PROTOTYPE, NUNJUCKS_EMITTER_PROTOTYPE, NUNJUCKS.runtime.Frame.prototype];
|
|
54
|
+
/** The nunjucks module and its submodules. */
|
|
55
|
+
const NUNJUCKS_MODULES = new Set([
|
|
56
|
+
nunjucks, NUNJUCKS.runtime, NUNJUCKS.parser, NUNJUCKS.lib, NUNJUCKS.compiler, NUNJUCKS.lexer, NUNJUCKS.nodes,
|
|
57
|
+
]);
|
|
58
|
+
/** Guards this module installed, so hardening again does not wrap a guard in another guard. */
|
|
59
|
+
const installedGuards = new WeakSet();
|
|
60
|
+
/**
|
|
61
|
+
* Guards the nunjucks parser, code generator and runtime used by every nunjucks environment in this process. After this call:
|
|
62
|
+
* - a template whose names could change the compiled code fails to compile (see `AssertTemplateTreeIsSafe`)
|
|
63
|
+
* - a macro or call-block argument that a call leaves out is filled only from a keyword argument that the
|
|
64
|
+
* call itself passes under that name, never from a member the keyword arguments inherit, so otherwise it
|
|
65
|
+
* reads as empty
|
|
66
|
+
* - keyword arguments written at a call site must be an ordinary object literal: ones that inherit from anything
|
|
67
|
+
* but `Object.prototype`, or that use a name that every object inherits (or `prototype`), throw, and the code
|
|
68
|
+
* generator refuses such a name as a dictionary key or keyword argument too; keyword arguments passed as a
|
|
69
|
+
* value (from render data, for example) are read through a copy of their own keys
|
|
70
|
+
* - a filter, test or global resolves only to a name the environment registered itself, never to a member
|
|
71
|
+
* that every object inherits (such as `hasOwnProperty`); an object, a function or a symbol is refused as the name
|
|
72
|
+
* - a member named `constructor`, `prototype`, `__proto__` or one of the `__define/lookup Getter/Setter__`
|
|
73
|
+
* accessors, written literally or computed while rendering, reads as `undefined`, unless it is an object's
|
|
74
|
+
* own data that is not a function; `__proto__` always reads as `undefined`
|
|
75
|
+
* - a bare name resolves only to a template variable, an own key of the render data, or an own environment
|
|
76
|
+
* global, never to a property that the render data or the globals inherit
|
|
77
|
+
* - a template may not read a member of the render context, an environment, a loader, a frame, a
|
|
78
|
+
* template or a nunjucks module, and a lookup or call that would return one of them throws
|
|
79
|
+
* - a lookup or call that would produce or use `Function` (or its async and generator variants), `eval`,
|
|
80
|
+
* `Object`, `Reflect`, `globalThis` or `process` throws a {@link TemplateSandboxError}
|
|
81
|
+
*
|
|
82
|
+
* Safe to call any number of times: a hook that already carries the guard is left as it is.
|
|
83
|
+
*/
|
|
84
|
+
export function HardenNunjucksRuntime() {
|
|
85
|
+
const { parser, compiler, runtime, Environment } = NUNJUCKS;
|
|
86
|
+
installGuard(parser, 'parse', guardParse);
|
|
87
|
+
installGuard(compiler.Compiler.prototype, 'compilePair', guardCompilePair);
|
|
88
|
+
installGuard(runtime, 'memberLookup', guardMemberLookup);
|
|
89
|
+
installGuard(runtime, 'contextOrFrameLookup', guardContextOrFrameLookup);
|
|
90
|
+
installGuard(runtime, 'callWrap', guardCallWrap);
|
|
91
|
+
installGuard(runtime, 'makeMacro', guardMakeMacro);
|
|
92
|
+
installGuard(runtime, 'makeKeywordArgs', guardMakeKeywordArgs);
|
|
93
|
+
installGuard(Environment.prototype, 'getFilter', guardRegistryLookup('filters'));
|
|
94
|
+
installGuard(Environment.prototype, 'getTest', guardRegistryLookup('tests'));
|
|
95
|
+
installGuard(Environment.prototype, 'getGlobal', guardRegistryLookup('globals'));
|
|
96
|
+
}
|
|
97
|
+
/** Replaces one hook with its guarded version, unless the hook is already a guard. */
|
|
98
|
+
function installGuard(target, hook, guard) {
|
|
99
|
+
if (installedGuards.has(target[hook])) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const guarded = guard(target[hook]);
|
|
103
|
+
installedGuards.add(guarded);
|
|
104
|
+
target[hook] = guarded;
|
|
105
|
+
}
|
|
106
|
+
/** Parsing for the compiler: the tree is checked before nunjucks compiles it. */
|
|
107
|
+
function guardParse(original) {
|
|
108
|
+
return (src, extensions, opts) => {
|
|
109
|
+
const tree = original(src, extensions, opts);
|
|
110
|
+
AssertTemplateTreeIsSafe(tree);
|
|
111
|
+
return tree;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The code generator writes a dictionary key or keyword argument as an object-literal key. A key that
|
|
116
|
+
* `IsInheritedMemberName` matches is refused here as well, so one that reaches the code generator without
|
|
117
|
+
* passing the parse-time check still cannot become an object-literal key.
|
|
118
|
+
*/
|
|
119
|
+
function guardCompilePair(original) {
|
|
120
|
+
return function guardedCompilePair(node, frame) {
|
|
121
|
+
const key = pairKeyName(node);
|
|
122
|
+
if (key !== undefined && IsInheritedMemberName(key)) {
|
|
123
|
+
throw new TemplateSandboxError(`Templates may not use "${key}" as a dictionary key or keyword argument`);
|
|
124
|
+
}
|
|
125
|
+
original.call(this, node, frame);
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* `runtime.makeMacro`, which builds every macro and call block. The macro it returns fills an argument that a
|
|
130
|
+
* call leaves out by reading the call's keyword arguments, and stores extra positional values in them. The
|
|
131
|
+
* guard gives nunjucks a copy of the keyword arguments without a prototype, holding only the keys the call
|
|
132
|
+
* passed, so neither step can reach an inherited member.
|
|
133
|
+
*/
|
|
134
|
+
function guardMakeMacro(original) {
|
|
135
|
+
return (argNames, kwargNames, func) => {
|
|
136
|
+
const macro = original(argNames, kwargNames, func);
|
|
137
|
+
return function guardedMacro(...macroArgs) {
|
|
138
|
+
return macro.apply(this, withOwnKeywordArguments(macroArgs));
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The call's arguments, with its keyword arguments replaced by a copy of their own keys in an object without a
|
|
144
|
+
* prototype. A call without keyword arguments gets an empty copy, because nunjucks would read from a new plain object.
|
|
145
|
+
*/
|
|
146
|
+
function withOwnKeywordArguments(macroArgs) {
|
|
147
|
+
const last = macroArgs[macroArgs.length - 1];
|
|
148
|
+
const hasKeywordArguments = isKeywordArguments(last);
|
|
149
|
+
const ownKeywordArguments = Object.create(null);
|
|
150
|
+
if (hasKeywordArguments) {
|
|
151
|
+
for (const key of Object.keys(last)) {
|
|
152
|
+
ownKeywordArguments[key] = readMember(last, key);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
ownKeywordArguments.__keywords = true;
|
|
156
|
+
return [...(hasKeywordArguments ? macroArgs.slice(0, -1) : macroArgs), ownKeywordArguments];
|
|
157
|
+
}
|
|
158
|
+
/** Keyword arguments as nunjucks recognizes them: an object or function that owns `__keywords`. */
|
|
159
|
+
function isKeywordArguments(value) {
|
|
160
|
+
return (typeof value === 'object' || typeof value === 'function') && value !== null && Object.hasOwn(value, '__keywords');
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* `runtime.makeKeywordArgs`, which marks the object literal that a call site passes as keyword arguments. It must
|
|
164
|
+
* inherit from `Object.prototype`, as an object literal does, and must not own a key that `IsInheritedMemberName` matches.
|
|
165
|
+
*/
|
|
166
|
+
function guardMakeKeywordArgs(original) {
|
|
167
|
+
return (obj) => {
|
|
168
|
+
if (Object.getPrototypeOf(obj) !== Object.prototype || Object.getOwnPropertyNames(obj).some((key) => IsInheritedMemberName(key))) {
|
|
169
|
+
throw new TemplateSandboxError('Templates may only pass keyword arguments that are a plain object with ordinary names');
|
|
170
|
+
}
|
|
171
|
+
return original(obj);
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* `env.getFilter(name)`, `env.getTest(name)` and `env.getGlobal(name)`. nunjucks keeps each registry in a
|
|
176
|
+
* plain object, so a name such as `toString` would find the member every object inherits. Only a name the
|
|
177
|
+
* environment registered itself resolves. A name that is not there at all still fails as nunjucks reports it.
|
|
178
|
+
*
|
|
179
|
+
* The `select` and `reject` filters pass a template value as the name. The name is converted to a key once,
|
|
180
|
+
* and nunjucks receives that same key, so it reads the key the guard checked. An object, a function or a
|
|
181
|
+
* symbol is refused before conversion, because converting it could run template code.
|
|
182
|
+
*/
|
|
183
|
+
function guardRegistryLookup(registry) {
|
|
184
|
+
return (original) => function guardedRegistryLookup(name) {
|
|
185
|
+
if ((typeof name === 'object' && name !== null) || typeof name === 'function' || typeof name === 'symbol') {
|
|
186
|
+
throw new TemplateSandboxError('Templates may not use an object, a function or a symbol as the name of a filter, test or global');
|
|
187
|
+
}
|
|
188
|
+
const key = String(name);
|
|
189
|
+
const entries = this[registry];
|
|
190
|
+
if (key in entries && !Object.hasOwn(entries, key)) {
|
|
191
|
+
throw new TemplateSandboxError(`Templates may only use filters, tests and globals that the environment registered ("${key}")`);
|
|
192
|
+
}
|
|
193
|
+
return original.call(this, key);
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* `obj.key` and `obj[key]`. The key is converted to a string once, so a computed key cannot change
|
|
198
|
+
* between the check and the read. The member is checked before nunjucks reads it again; templates
|
|
199
|
+
* cannot define accessors (the accessor helpers are restricted names), so both reads see the same value.
|
|
200
|
+
*/
|
|
201
|
+
function guardMemberLookup(original) {
|
|
202
|
+
return (obj, val) => {
|
|
203
|
+
if (obj === undefined || obj === null || typeof val === 'symbol') {
|
|
204
|
+
return undefined;
|
|
205
|
+
}
|
|
206
|
+
const key = String(val);
|
|
207
|
+
if (isNunjucksObject(obj)) {
|
|
208
|
+
throw new TemplateSandboxError(`Templates may not read members of the render context or other nunjucks objects (reading "${key}")`);
|
|
209
|
+
}
|
|
210
|
+
if (RESTRICTED_MEMBER_NAMES.has(key) && !isOwnDataValue(obj, key)) {
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
assertAllowed(obj, `members of a restricted value (reading "${key}")`);
|
|
214
|
+
assertAllowed(readMember(obj, key), `the member "${key}"`);
|
|
215
|
+
return original(obj, key);
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* A bare name such as `{{ user }}`: a template variable, then an own key of the render data, then an own
|
|
220
|
+
* environment global. The guard resolves the name itself, because nunjucks would also return members
|
|
221
|
+
* that the render data or the globals inherit.
|
|
222
|
+
*/
|
|
223
|
+
function guardContextOrFrameLookup() {
|
|
224
|
+
return (context, frame, name) => {
|
|
225
|
+
if (name === '__proto__') {
|
|
226
|
+
return undefined;
|
|
227
|
+
}
|
|
228
|
+
const value = ownBinding(context, frame, name);
|
|
229
|
+
if (value === undefined || (RESTRICTED_MEMBER_NAMES.has(name) && typeof value === 'function')) {
|
|
230
|
+
return undefined;
|
|
231
|
+
}
|
|
232
|
+
assertAllowed(value, `the name "${name}"`, context);
|
|
233
|
+
return value;
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
/** A call such as `{{ fn(x) }}`. nunjucks passes the render context as `this`, so a call may not return it. */
|
|
237
|
+
function guardCallWrap(original) {
|
|
238
|
+
return (obj, name, context, args) => {
|
|
239
|
+
assertAllowed(obj, `the function "${name}"`, context);
|
|
240
|
+
const result = original(obj, name, context, args);
|
|
241
|
+
assertAllowed(result, `the value returned by "${name}"`, context);
|
|
242
|
+
return result;
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
/** The value of a bare name: a template variable, else an own key of the render data, else an own environment global. */
|
|
246
|
+
function ownBinding(context, frame, name) {
|
|
247
|
+
const variable = frame.lookup(name);
|
|
248
|
+
if (variable !== undefined) {
|
|
249
|
+
return variable;
|
|
250
|
+
}
|
|
251
|
+
const data = context.getVariables();
|
|
252
|
+
if (Object.hasOwn(data, name)) {
|
|
253
|
+
return readMember(data, name);
|
|
254
|
+
}
|
|
255
|
+
const globals = context.env.globals;
|
|
256
|
+
return Object.hasOwn(globals, name) ? readMember(globals, name) : undefined;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* True when an object (not a function) stores data that is not a function under `key` itself, as
|
|
260
|
+
* `{"constructor": "Acme"}` does. A prototype's own `constructor` is a function, so it never counts,
|
|
261
|
+
* and neither does `__proto__`.
|
|
262
|
+
*/
|
|
263
|
+
function isOwnDataValue(obj, key) {
|
|
264
|
+
return key !== '__proto__'
|
|
265
|
+
&& typeof obj === 'object' && obj !== null
|
|
266
|
+
&& Object.hasOwn(obj, key)
|
|
267
|
+
&& typeof readMember(obj, key) !== 'function';
|
|
268
|
+
}
|
|
269
|
+
/** True for the render context, an environment, a loader, a frame, a template or a nunjucks module. */
|
|
270
|
+
function isNunjucksObject(value) {
|
|
271
|
+
if (typeof value !== 'object' || value === null) {
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
return NUNJUCKS_MODULES.has(value) || NUNJUCKS_OBJECT_PROTOTYPES.some((prototype) => prototype.isPrototypeOf(value));
|
|
275
|
+
}
|
|
276
|
+
/** Reads a member the way a template does, including members of primitive strings and numbers. */
|
|
277
|
+
function readMember(obj, key) {
|
|
278
|
+
return obj[key];
|
|
279
|
+
}
|
|
280
|
+
/** The text of a dictionary key or keyword argument (a symbol or a quoted string), or `undefined` for any other key. */
|
|
281
|
+
function pairKeyName(pair) {
|
|
282
|
+
const key = typeof pair === 'object' && pair !== null ? readMember(pair, 'key') : undefined;
|
|
283
|
+
const value = typeof key === 'object' && key !== null ? readMember(key, 'value') : undefined;
|
|
284
|
+
return typeof value === 'string' ? value : undefined;
|
|
285
|
+
}
|
|
286
|
+
/** Throws when a lookup or call would give a template a restricted value, the render context or another nunjucks object. */
|
|
287
|
+
function assertAllowed(value, subject, context) {
|
|
288
|
+
if (RESTRICTED_VALUES.has(value) || isNunjucksObject(value) || (context !== undefined && value === context)) {
|
|
289
|
+
throw new TemplateSandboxError(`Templates may not access ${subject}`);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
//# sourceMappingURL=NunjucksSandbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NunjucksSandbox.js","sourceRoot":"","sources":["../src/NunjucksSandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OA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AAG,OAAO,CAAC,oBAAoB,CAAC;IAiE/M;;;;;;;;;OASG;IACU,oBAAoB,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAqBrI;;;;;;OAMG;IACH,SAAS,CAAC,mBAAmB,CAAC,iBAAiB,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,GAAG,GAAG;IAgB3G;;;;;OAKG;IACH,SAAS,CAAC,sBAAsB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,GAAE,QAAQ,CAAC,WAA+B,GAAG,GAAG;IAI1G;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAUnB,kBAAkB;IAIzB;;;;OAIG;cACa,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAa5F;;;;;;;;;;;;;OAaG;IACH,SAAS,CAAC,kBAAkB,CAAC,cAAc,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,GAAG;CAuD5G"}
|
package/dist/TemplateEngine.js
CHANGED
|
@@ -2,7 +2,11 @@ import { LogError } from "@memberjunction/core";
|
|
|
2
2
|
import nunjucks from 'nunjucks';
|
|
3
3
|
import { BaseSingleton, MJGlobal, UUIDsEqual } from "@memberjunction/global";
|
|
4
4
|
import { TemplateExtensionBase } from "./extensions/TemplateExtensionBase.js";
|
|
5
|
+
import { HardenNunjucksRuntime } from "./NunjucksSandbox.js";
|
|
5
6
|
import { TemplateEngineBase } from '@memberjunction/templates-base-types';
|
|
7
|
+
// Stored templates are user-editable, so nunjucks is guarded as soon as the engine loads. The guard
|
|
8
|
+
// is process-wide: it also covers nunjucks environments that other packages create.
|
|
9
|
+
HardenNunjucksRuntime();
|
|
6
10
|
/**
|
|
7
11
|
* This class extends the nunjucks loader to allow adding templates directly to the loader
|
|
8
12
|
*/
|
|
@@ -329,6 +333,7 @@ export class TemplateEngineServer extends BaseSingleton {
|
|
|
329
333
|
* @param data the data to render the template with
|
|
330
334
|
*/
|
|
331
335
|
async renderTemplateAsync(template, data) {
|
|
336
|
+
HardenNunjucksRuntime(); // no-op unless something replaced a guarded nunjucks hook
|
|
332
337
|
return new Promise((resolve, reject) => {
|
|
333
338
|
template.render(data, (err, result) => {
|
|
334
339
|
if (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateEngine.js","sourceRoot":"","sources":["../src/TemplateEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,QAAQ,EAAiC,MAAM,sBAAsB,CAAC;AAElG,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAwB,kBAAkB,EAAE,MAAM,sCAAsC,CAAA;AAE/F;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,QAAQ,CAAC,MAAM;IAAzD;;QACW,UAAK,GAAG,IAAI,CAAC;QAWZ,cAAS,GAAuD,EAAE,CAAC;IAgC/E,CAAC;IAzCG,qCAAqC;IACrC,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IACD,qCAAqC;IACrC,IAAW,KAAK,CAAC,KAAK;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC,CAAC,wCAAwC;IAI1C;;;;OAIG;IACI,WAAW,CAAC,UAAkB,EAAE,QAAkC;QACrE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC;IAC1C,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,IAAY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;QAChC,CAAC,CAAC,CAAC;QAEH,8CAA8C;QAC9C,YAAY,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YACjC,8DAA8D;YAC9D,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,SAAS,IAAI,KAAK,CAAC,YAAY,KAAK,IAAI,IAAI,KAAK,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;gBACpG,IAAI,CAAC;oBACD,mCAAmC;oBACnC,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;wBACjB,KAAK,OAAO,CAAC;wBACb,KAAK,QAAQ,CAAC;wBACd,KAAK,QAAQ,CAAC;wBACd,KAAK,QAAQ;4BACT,yCAAyC;4BACzC,IAAI,CAAC;gCACD,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;4BACtD,CAAC;4BAAC,MAAM,CAAC;gCACL,+BAA+B;gCAC/B,UAAU,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC;4BAC1C,CAAC;4BACD,MAAM;wBAEV,KAAK,QAAQ,CAAC;wBACd;4BACI,2CAA2C;4BAC3C,UAAU,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC;4BACtC,MAAM;oBACd,CAAC;gBACL,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACb,0DAA0D;oBAC1D,QAAQ,CAAC,gDAAgD,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;gBACxF,CAAC;YACL,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The error the template sandbox throws.
|
|
3
|
+
* @module @memberjunction/templates
|
|
4
|
+
*/
|
|
5
|
+
/** Thrown when a template uses a name, a value or a call that the template sandbox does not allow. */
|
|
6
|
+
export declare class TemplateSandboxError extends Error {
|
|
7
|
+
constructor(message: string);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=TemplateSandboxError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateSandboxError.d.ts","sourceRoot":"","sources":["../src/TemplateSandboxError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,sGAAsG;AACtG,qBAAa,oBAAqB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI9B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The error the template sandbox throws.
|
|
3
|
+
* @module @memberjunction/templates
|
|
4
|
+
*/
|
|
5
|
+
/** Thrown when a template uses a name, a value or a call that the template sandbox does not allow. */
|
|
6
|
+
export class TemplateSandboxError extends Error {
|
|
7
|
+
constructor(message) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = 'TemplateSandboxError';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=TemplateSandboxError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateSandboxError.js","sourceRoot":"","sources":["../src/TemplateSandboxError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,sGAAsG;AACtG,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACvC,CAAC;CACJ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export * from './TemplateEngine.js';
|
|
2
|
+
export * from './NunjucksSandbox.js';
|
|
3
|
+
export * from './NunjucksCompileGuard.js';
|
|
4
|
+
export * from './TemplateSandboxError.js';
|
|
2
5
|
export * from './extensions/AIPrompt.extension.js';
|
|
3
6
|
export * from './extensions/TemplateEmbed.extension.js';
|
|
4
7
|
export * from './extensions/TemplateExtensionBase.js';
|
|
5
8
|
export * from './operations/TemplateRunOperation.js';
|
|
9
|
+
export * from './operations/TemplateRunAuthorization.js';
|
|
6
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iCAAiC,CAAC;AAChD,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,CAAC;AAChD,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,uCAAuC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export * from './TemplateEngine.js';
|
|
2
|
+
export * from './NunjucksSandbox.js';
|
|
3
|
+
export * from './NunjucksCompileGuard.js';
|
|
4
|
+
export * from './TemplateSandboxError.js';
|
|
2
5
|
export * from './extensions/AIPrompt.extension.js';
|
|
3
6
|
export * from './extensions/TemplateEmbed.extension.js';
|
|
4
7
|
export * from './extensions/TemplateExtensionBase.js';
|
|
5
8
|
export * from './operations/TemplateRunOperation.js';
|
|
9
|
+
export * from './operations/TemplateRunAuthorization.js';
|
|
6
10
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iCAAiC,CAAC;AAChD,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,CAAC;AAChD,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,uCAAuC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Decides who may render a stored template on demand, through the `RunTemplate`
|
|
3
|
+
* mutation or the `Template.Run` remote operation.
|
|
4
|
+
* @module @memberjunction/templates
|
|
5
|
+
*/
|
|
6
|
+
import type { IMetadataProvider, UserInfo } from '@memberjunction/core';
|
|
7
|
+
/**
|
|
8
|
+
* Checks whether a principal may render a stored template on demand. A run is refused for:
|
|
9
|
+
* - a missing principal
|
|
10
|
+
* - a scope-limited session (an anonymous magic-link or widget guest, or a resource-scoped
|
|
11
|
+
* magic-link session), whose confinement exists only as row-level security on entity reads
|
|
12
|
+
* - a principal without read permission on `MJ: Templates` and `MJ: Template Contents`
|
|
13
|
+
*
|
|
14
|
+
* Row-level security on the requested template still applies when the caller loads it.
|
|
15
|
+
* @param user the acting principal
|
|
16
|
+
* @param metadata the source of entity permissions; a missing provider refuses the run
|
|
17
|
+
* @returns `null` when the run may proceed, otherwise the reason it is refused
|
|
18
|
+
*/
|
|
19
|
+
export declare function GetTemplateRunRefusal(user: UserInfo | null | undefined, metadata: Pick<IMetadataProvider, 'EntityByName'> | null | undefined): string | null;
|
|
20
|
+
//# sourceMappingURL=TemplateRunAuthorization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateRunAuthorization.d.ts","sourceRoot":"","sources":["../../src/operations/TemplateRunAuthorization.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAKxE;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACjC,IAAI,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,EACjC,QAAQ,EAAE,IAAI,CAAC,iBAAiB,EAAE,cAAc,CAAC,GAAG,IAAI,GAAG,SAAS,GACrE,MAAM,GAAG,IAAI,CAaf"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** The entities a template run reads: the template, and the content it renders. */
|
|
2
|
+
const TEMPLATE_RUN_ENTITIES = ['MJ: Templates', 'MJ: Template Contents'];
|
|
3
|
+
/**
|
|
4
|
+
* Checks whether a principal may render a stored template on demand. A run is refused for:
|
|
5
|
+
* - a missing principal
|
|
6
|
+
* - a scope-limited session (an anonymous magic-link or widget guest, or a resource-scoped
|
|
7
|
+
* magic-link session), whose confinement exists only as row-level security on entity reads
|
|
8
|
+
* - a principal without read permission on `MJ: Templates` and `MJ: Template Contents`
|
|
9
|
+
*
|
|
10
|
+
* Row-level security on the requested template still applies when the caller loads it.
|
|
11
|
+
* @param user the acting principal
|
|
12
|
+
* @param metadata the source of entity permissions; a missing provider refuses the run
|
|
13
|
+
* @returns `null` when the run may proceed, otherwise the reason it is refused
|
|
14
|
+
*/
|
|
15
|
+
export function GetTemplateRunRefusal(user, metadata) {
|
|
16
|
+
if (!user) {
|
|
17
|
+
return 'Unable to determine current user';
|
|
18
|
+
}
|
|
19
|
+
if (isScopeLimited(user)) {
|
|
20
|
+
return 'Running templates is not permitted for scope-limited sessions';
|
|
21
|
+
}
|
|
22
|
+
for (const entityName of TEMPLATE_RUN_ENTITIES) {
|
|
23
|
+
if (!metadata?.EntityByName(entityName)?.GetUserPermisions(user)?.CanRead) {
|
|
24
|
+
return `You do not have permission to read ${entityName}`;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* True for a session confined by per-session scope rather than by its roles. Matches
|
|
31
|
+
* `IsScopeLimitedPrincipal` in `@memberjunction/server`, which this package cannot import.
|
|
32
|
+
*/
|
|
33
|
+
function isScopeLimited(user) {
|
|
34
|
+
const scope = user.MagicLinkScope;
|
|
35
|
+
return user.IsMagicLinkAnonymous || !!(scope?.ResourceID || scope?.ResourceType);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=TemplateRunAuthorization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateRunAuthorization.js","sourceRoot":"","sources":["../../src/operations/TemplateRunAuthorization.ts"],"names":[],"mappings":"AAOA,mFAAmF;AACnF,MAAM,qBAAqB,GAAG,CAAC,eAAe,EAAE,uBAAuB,CAAC,CAAC;AAEzE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,qBAAqB,CACjC,IAAiC,EACjC,QAAoE;IAEpE,IAAI,CAAC,IAAI,EAAE,CAAC;QACR,OAAO,kCAAkC,CAAC;IAC9C,CAAC;IACD,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,+DAA+D,CAAC;IAC3E,CAAC;IACD,KAAK,MAAM,UAAU,IAAI,qBAAqB,EAAE,CAAC;QAC7C,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC,EAAE,iBAAiB,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;YACxE,OAAO,sCAAsC,UAAU,EAAE,CAAC;QAC9D,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAS,cAAc,CAAC,IAAc;IAClC,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC;IAClC,OAAO,IAAI,CAAC,oBAAoB,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,UAAU,IAAI,KAAK,EAAE,YAAY,CAAC,CAAC;AACrF,CAAC"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { IMetadataProvider, UserInfo } from '@memberjunction/core';
|
|
2
2
|
import { TemplateRunOperation, type TemplateRunInput, type TemplateRunOutput } from '@memberjunction/core-entities';
|
|
3
3
|
export declare class TemplateRunServerOperation extends TemplateRunOperation {
|
|
4
|
+
/**
|
|
5
|
+
* Refuses scope-limited sessions and callers who cannot read templates and their content.
|
|
6
|
+
* The remote-operation resolver checks only API-key scope, which JWT, magic-link and widget
|
|
7
|
+
* sessions do not carry.
|
|
8
|
+
*/
|
|
9
|
+
protected Authorize(_input: TemplateRunInput, user: UserInfo): Promise<boolean>;
|
|
4
10
|
protected InternalExecute(input: TemplateRunInput, provider: IMetadataProvider, user: UserInfo): Promise<TemplateRunOutput>;
|
|
5
11
|
}
|
|
6
12
|
//# sourceMappingURL=TemplateRunOperation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateRunOperation.d.ts","sourceRoot":"","sources":["../../src/operations/TemplateRunOperation.ts"],"names":[],"mappings":"AAUA,OAAO,EAA0B,iBAAiB,
|
|
1
|
+
{"version":3,"file":"TemplateRunOperation.d.ts","sourceRoot":"","sources":["../../src/operations/TemplateRunOperation.ts"],"names":[],"mappings":"AAUA,OAAO,EAA0B,iBAAiB,EAAqB,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE9G,OAAO,EAAE,oBAAoB,EAAE,KAAK,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAIpH,qBACa,0BAA2B,SAAQ,oBAAoB;IAChE;;;;OAIG;cACsB,SAAS,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;cAI9E,eAAe,CAAC,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,iBAAiB,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAqCpI"}
|
|
@@ -14,10 +14,19 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
14
14
|
* @module @memberjunction/templates
|
|
15
15
|
*/
|
|
16
16
|
import { RegisterClass } from '@memberjunction/global';
|
|
17
|
-
import { BaseRemotableOperation, RunView } from '@memberjunction/core';
|
|
17
|
+
import { BaseRemotableOperation, Metadata, RunView } from '@memberjunction/core';
|
|
18
18
|
import { TemplateRunOperation } from '@memberjunction/core-entities';
|
|
19
19
|
import { TemplateEngineServer } from '../TemplateEngine.js';
|
|
20
|
+
import { GetTemplateRunRefusal } from './TemplateRunAuthorization.js';
|
|
20
21
|
let TemplateRunServerOperation = class TemplateRunServerOperation extends TemplateRunOperation {
|
|
22
|
+
/**
|
|
23
|
+
* Refuses scope-limited sessions and callers who cannot read templates and their content.
|
|
24
|
+
* The remote-operation resolver checks only API-key scope, which JWT, magic-link and widget
|
|
25
|
+
* sessions do not carry.
|
|
26
|
+
*/
|
|
27
|
+
async Authorize(_input, user) {
|
|
28
|
+
return GetTemplateRunRefusal(user, Metadata.Provider) === null; // global-provider-ok: Authorize receives no provider; entity permissions are process-global metadata
|
|
29
|
+
}
|
|
21
30
|
async InternalExecute(input, provider, user) {
|
|
22
31
|
if (!input?.templateID) {
|
|
23
32
|
throw new Error('templateID is required');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateRunOperation.js","sourceRoot":"","sources":["../../src/operations/TemplateRunOperation.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAqB,OAAO,EAAY,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"TemplateRunOperation.js","sourceRoot":"","sources":["../../src/operations/TemplateRunOperation.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM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AC;YACV,UAAU,EAAE,eAAe;SAC9B,EAAE,IAAI,CAAC,CAAC;QACT,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,0CAA0C,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC;QACrF,CAAC;QAED,MAAM,oBAAoB,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,qCAAqC,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QACvG,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,QAAQ,CAAC,cAAc,CAC7D,cAAc,EACd,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,EACxB,KAAK,CAAC,IAAI,IAAI,EAAE,EAChB,IAAI,CAAC,mCAAmC,CAC3C,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,IAAI,wBAAwB,CAAC,CAAC;QAChE,CAAC;QAED,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,EAAE,EAAE,eAAe,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,EAAE,CAAC;IACpF,CAAC;CACJ,CAAA;AA/CY,0BAA0B;IADtC,aAAa,CAAC,sBAAsB,EAAE,cAAc,CAAC;GACzC,0BAA0B,CA+CtC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/templates",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.2.0-edge.
|
|
4
|
+
"version": "6.2.0-edge.4",
|
|
5
5
|
"description": "MemberJunction Templating Engine and Utilities - Used for any application that requires templating utility functionality. NOTE: this package does use Angular Universal for compilation but is not marked with the usual ng prefix because it is a server-side library and not used within Angular apps.",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
"typescript": "^5.9.3"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@memberjunction/core": "6.2.0-edge.
|
|
18
|
-
"@memberjunction/templates-base-types": "6.2.0-edge.
|
|
19
|
-
"@memberjunction/ai": "6.2.0-edge.
|
|
20
|
-
"@memberjunction/ai-core-plus": "6.2.0-edge.
|
|
21
|
-
"@memberjunction/aiengine": "6.2.0-edge.
|
|
22
|
-
"@memberjunction/ai-provider-bundle": "6.2.0-edge.
|
|
23
|
-
"@memberjunction/core-entities": "6.2.0-edge.
|
|
24
|
-
"@memberjunction/global": "6.2.0-edge.
|
|
17
|
+
"@memberjunction/core": "6.2.0-edge.4",
|
|
18
|
+
"@memberjunction/templates-base-types": "6.2.0-edge.4",
|
|
19
|
+
"@memberjunction/ai": "6.2.0-edge.4",
|
|
20
|
+
"@memberjunction/ai-core-plus": "6.2.0-edge.4",
|
|
21
|
+
"@memberjunction/aiengine": "6.2.0-edge.4",
|
|
22
|
+
"@memberjunction/ai-provider-bundle": "6.2.0-edge.4",
|
|
23
|
+
"@memberjunction/core-entities": "6.2.0-edge.4",
|
|
24
|
+
"@memberjunction/global": "6.2.0-edge.4",
|
|
25
25
|
"nunjucks": "3.2.4"
|
|
26
26
|
},
|
|
27
27
|
"repository": {
|