@@ -4,6 +4,7 @@ const _path = require("path");
44const process = require("process");
55const JSONbig = require("json-bigint")({ storeAsString: false });
66
7+ const KeysVars = new Set(["key", "value"]);
78const KeysFunction = new Set(["path", "$id", "execute", "name", "enabled", "logging", "runtime", "scopes", "events", "schedule", "timeout", "entrypoint", "commands", "vars"]);
89const KeysDatabase = new Set(["$id", "name", "enabled"]);
910const KeysCollection = new Set(["$id", "$permissions", "databaseId", "name", "enabled", "documentSecurity", "attributes", "indexes"]);
@@ -38,10 +39,10 @@ const KeysAttributes = new Set([
3839const KeyIndexes = new Set(["key", "type", "status", "attributes", "orders"]);
3940
4041function whitelistKeys(value, keys, nestedKeys = {}) {
41- if(Array.isArray(value)) {
42+ if (Array.isArray(value)) {
4243 const newValue = [];
4344
44- for(const item of value) {
45+ for (const item of value) {
4546 newValue.push(whitelistKeys(item, keys, nestedKeys));
4647 }
4748
@@ -50,8 +51,8 @@ function whitelistKeys(value, keys, nestedKeys = {}) {
5051
5152 const newValue = {};
5253 Object.keys(value).forEach((key) => {
53- if(keys.has(key)) {
54- if(nestedKeys[key]) {
54+ if (keys.has(key)) {
55+ if (nestedKeys[key]) {
5556 newValue[key] = whitelistKeys(value[key], nestedKeys[key]);
5657 } else {
5758 newValue[key] = value[key];
@@ -151,7 +152,9 @@ class Local extends Config {
151152 }
152153
153154 addFunction(props) {
154- props = whitelistKeys(props, KeysFunction);
155+ props = whitelistKeys(props, KeysFunction, {
156+ vars: KeysVars
157+ });
155158
156159 if (!this.has("functions")) {
157160 this.set("functions", []);
0 commit comments