π A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!
Vue awesomedashboarddockerhomelabhomepagemitnodejsorganizationproductivitypwaself-hostedstartpagevue
π Implements max response size safeguard
Alicia Sykes6d1ad131cdd3
diff --git a/services/cors-proxy.js b/services/cors-proxy.jsindex 474d5767..510a719e 100644--- a/services/cors-proxy.js+++ b/services/cors-proxy.js@@ -89,6 +89,7 @@ module.exports = (req, res) => {data: req.body,headers,timeout: 30000,+ maxResponseSize: 10 * 1024 * 1024, // 10 MB};// Make the request, and respond with resultdiff --git a/services/request.js b/services/request.jsindex 90ff8254..0e1d11a0 100644--- a/services/request.js+++ b/services/request.js@@ -57,6 +57,7 @@ function request(config) {json,maxRedirects = 5,timeout = 0,+ maxResponseSize = 0,httpsAgent,} = config;@@ -134,11 +135,28 @@ function request(config) {}const chunks = [];- stream.on('data', (chunk) => chunks.push(chunk));+ let totalSize = 0;+ let aborted = false;+ stream.on('data', (chunk) => {+ if (aborted) return;+ totalSize += chunk.length;+ if (maxResponseSize > 0 && totalSize > maxResponseSize) {+ aborted = true;+ req.destroy();+ reject(new RequestError(+ `Response exceeds maximum size of ${maxResponseSize} bytes`,+ { code: 'E_RESPONSE_TOO_LARGE' },+ ));+ return;+ }+ chunks.push(chunk);+ });stream.on('error', (err) => {+ if (aborted) return;reject(new RequestError(`Decompression failed: ${err.message}`, { code: err.code }));});stream.on('end', () => {+ if (aborted) return;const raw = Buffer.concat(chunks).toString('utf8');let responseData;try { responseData = JSON.parse(raw); } catch (_) { responseData = raw; }