From ec5208e5f427d3b74a9c27f5a3e4d109809b65ef Mon Sep 17 00:00:00 2001 From: Dragoi Stefan Date: Thu, 11 Sep 2025 15:54:11 +0300 Subject: [PATCH] Add null checks on connection commands array --- lib/connections.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/connections.js b/lib/connections.js index 8bf26811..10a062a3 100644 --- a/lib/connections.js +++ b/lib/connections.js @@ -308,8 +308,10 @@ class ConnectionWrapper { // redisConnection.options.port); const extraROCmds = require('config').get('redis.extraAllowedReadOnlyCommands'); redisConnection.options.commandList = { - all: p[0].value.map((item) => (item[0].toLowerCase())), - ro: p[0].value.filter((item) => (item[2].indexOf('readonly') >= 0 || extraROCmds.indexOf(item[0]) >= 0)) + all: p[0].value.filter(item => item && Array.isArray(item) && item.length > 0) + .map((item) => (item[0].toLowerCase())), + ro: p[0].value.filter((item) => item && Array.isArray(item) && item.length > 2 && + (item[2].indexOf('readonly') >= 0 || extraROCmds.indexOf(item[0]) >= 0)) .map((item) => (item[0].toLowerCase())) }; }