From 3d95361c094c820d44de60b8163c4b2537607771 Mon Sep 17 00:00:00 2001 From: jj Date: Tue, 26 Nov 2024 13:51:49 +0000 Subject: [PATCH] api/cookie: validate cookie file format --- api/src/processing/cookie/manager.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/api/src/processing/cookie/manager.js b/api/src/processing/cookie/manager.js index bb36b9da..a738611e 100644 --- a/api/src/processing/cookie/manager.js +++ b/api/src/processing/cookie/manager.js @@ -35,9 +35,14 @@ const setupMain = async (cookiePath) => { for (const serviceName in cookies) { if (!VALID_SERVICES.has(serviceName)) { console.warn(`${Yellow('[!]')} ignoring unknown service in cookie file: ${serviceName}`); - invalidCookies[serviceName] = cookies[serviceName]; - delete cookies[serviceName]; - } + } else if (!Array.isArray(cookies[serviceName])) { + console.warn(`${Yellow('[!]')} ${serviceName} in cookies file is not an array, ignoring it`); + } else if (cookies[serviceName].some(c => typeof c !== 'string')) { + console.warn(`${Yellow('[!]')} cookies file contains non-string value for ${serviceName}`); + } else continue; + + invalidCookies[serviceName] = cookies[serviceName]; + delete cookies[serviceName]; } intervalId = setInterval(() => writeChanges(cookiePath), WRITE_INTERVAL);