From 7555e0644f3bc78cfa87f930ecbe9f7e99d3cb6c Mon Sep 17 00:00:00 2001 From: GogoVega <92022724+GogoVega@users.noreply.github.com> Date: Wed, 23 Oct 2024 12:15:24 +0200 Subject: [PATCH] Apply `envVarExcludes` setting to `RED.util.getSetting` into the function node --- .../nodes/core/function/10-function.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/node_modules/@node-red/nodes/core/function/10-function.js b/packages/node_modules/@node-red/nodes/core/function/10-function.js index 0120d8c92..8d365722f 100644 --- a/packages/node_modules/@node-red/nodes/core/function/10-function.js +++ b/packages/node_modules/@node-red/nodes/core/function/10-function.js @@ -111,8 +111,6 @@ module.exports = function(RED) { throw new Error(RED._("function.error.externalModuleNotAllowed")); } - - var functionText = "var results = null;"+ "results = (async function(msg,__send__,__done__){ "+ "var __msgid__ = msg._msgid;"+ @@ -160,13 +158,26 @@ module.exports = function(RED) { node.outstandingIntervals = []; node.clearStatus = false; + const envVarExcludes = {}; + if (RED.settings.envVarExcludes && Array.isArray(RED.settings.envVarExcludes)) { + RED.settings.envVarExcludes.forEach((e) => envVarExcludes[e] = true); + } + var sandbox = { console:console, util:util, Buffer:Buffer, Date: Date, 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__: { id: node.id,