@@ -4,6 +4,7 @@ const _path = require("path");
4
4
const process = require("process");
5
5
const JSONbig = require("json-bigint")({ storeAsString: false });
6
6
7
+ const KeysVars = new Set(["key", "value"]);
7
8
const KeysFunction = new Set(["path", "$id", "execute", "name", "enabled", "logging", "runtime", "scopes", "events", "schedule", "timeout", "entrypoint", "commands", "vars"]);
8
9
const KeysDatabase = new Set(["$id", "name", "enabled"]);
9
10
const KeysCollection = new Set(["$id", "$permissions", "databaseId", "name", "enabled", "documentSecurity", "attributes", "indexes"]);
@@ -38,10 +39,10 @@ const KeysAttributes = new Set([
38
39
const KeyIndexes = new Set(["key", "type", "status", "attributes", "orders"]);
39
40
40
41
function whitelistKeys(value, keys, nestedKeys = {}) {
41
- if(Array.isArray(value)) {
42
+ if (Array.isArray(value)) {
42
43
const newValue = [];
43
44
44
- for(const item of value) {
45
+ for (const item of value) {
45
46
newValue.push(whitelistKeys(item, keys, nestedKeys));
46
47
}
47
48
@@ -50,8 +51,8 @@ function whitelistKeys(value, keys, nestedKeys = {}) {
50
51
51
52
const newValue = {};
52
53
Object.keys(value).forEach((key) => {
53
- if(keys.has(key)) {
54
- if(nestedKeys[key]) {
54
+ if (keys.has(key)) {
55
+ if (nestedKeys[key]) {
55
56
newValue[key] = whitelistKeys(value[key], nestedKeys[key]);
56
57
} else {
57
58
newValue[key] = value[key];
@@ -151,7 +152,9 @@ class Local extends Config {
151
152
}
152
153
153
154
addFunction(props) {
154
- props = whitelistKeys(props, KeysFunction);
155
+ props = whitelistKeys(props, KeysFunction, {
156
+ vars: KeysVars
157
+ });
155
158
156
159
if (!this.has("functions")) {
157
160
this.set("functions", []);
0 commit comments