mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 10:24:02 +00:00
Keep panel requests on the app's server and bounded
panel_request resolved paths with a check for a leading //, but URL parsing also reads /\host as another host, so it could request other servers. It now resolves the path against the app's address, refuses any other origin, matches refused routes decoded as well, and does not follow redirects. Responses are capped at 64 MiB while reading, with a deadline; held responses make room on arrival and expire by time only, so a response being read keeps its parts. The panel keeps converted images only for its build files, so live camera frames no longer accumulate, and failed build loads are retried. The dev server answers a malformed /panel/ path with 400 instead of crashing.
This commit is contained in:
1 parent
efdee8d255
commit
abca609708
5 files changed
+187
-38
No files matched your search
+8
-1
@@ -74,7 +74,14 @@ export function panelBuildPlugin({ outDir = PANEL_OUT_DIR } = {}) {
|
||||
const { readFile } = await import('node:fs/promises');
|
||||
const { extname, resolve, sep } = await import('node:path');
|
||||
const root = resolve(server.config.root, outDir);
|
||||
const relative = decodeURIComponent(pathname.slice(PANEL_BASE.length));
|
||||
let relative;
|
||||
try {
|
||||
relative = decodeURIComponent(pathname.slice(PANEL_BASE.length));
|
||||
} catch {
|
||||
res.statusCode = 400;
|
||||
res.end('Bad path');
|
||||
return;
|
||||
}
|
||||
const file = resolve(root, relative || 'index.html');
|
||||
if (file !== root && !file.startsWith(root + sep)) return next();
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user