Apply envVarExcludes setting to RED.util.getSetting into the function node

This commit is contained in:
GogoVega 2024-10-23 12:15:24 +02:00
parent c363f375b6
commit 7555e0644f
No known key found for this signature in database
GPG Key ID: E1E048B63AC5AC2B

View File

@ -111,8 +111,6 @@ module.exports = function(RED) {
throw new Error(RED._("function.error.externalModuleNotAllowed")); throw new Error(RED._("function.error.externalModuleNotAllowed"));
} }
var functionText = "var results = null;"+ var functionText = "var results = null;"+
"results = (async function(msg,__send__,__done__){ "+ "results = (async function(msg,__send__,__done__){ "+
"var __msgid__ = msg._msgid;"+ "var __msgid__ = msg._msgid;"+
@ -160,13 +158,26 @@ module.exports = function(RED) {
node.outstandingIntervals = []; node.outstandingIntervals = [];
node.clearStatus = false; node.clearStatus = false;
const envVarExcludes = {};
if (RED.settings.envVarExcludes && Array.isArray(RED.settings.envVarExcludes)) {
RED.settings.envVarExcludes.forEach((e) => envVarExcludes[e] = true);
}
var sandbox = { var sandbox = {
console:console, console:console,
util:util, util:util,
Buffer:Buffer, Buffer:Buffer,
Date: Date, Date: Date,
RED: { RED: {
util: RED.util util: {
...RED.util,
getSetting: function (node, name, flow) {
if (envVarExcludes[name]) {
return undefined;
}
return RED.util.getSetting(node, name, flow);
}
}
}, },
__node__: { __node__: {
id: node.id, id: node.id,