mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-27 22:41:16 -07:00
Chore: add proxmox param validation
Docker CI / Docker Build & Push (push) Has been cancelled
Lint / Linting Checks (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Release Drafter / Auto Label PR (push) Has been cancelled
Tests / vitest (1) (push) Has been cancelled
Tests / vitest (2) (push) Has been cancelled
Tests / vitest (3) (push) Has been cancelled
Tests / vitest (4) (push) Has been cancelled
Docker CI / Docker Build & Push (push) Has been cancelled
Lint / Linting Checks (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Release Drafter / Auto Label PR (push) Has been cancelled
Tests / vitest (1) (push) Has been cancelled
Tests / vitest (2) (push) Has been cancelled
Tests / vitest (3) (push) Has been cancelled
Tests / vitest (4) (push) Has been cancelled
This commit is contained in:
@@ -3,11 +3,14 @@ import createLogger from "utils/logger";
|
||||
import { httpProxy } from "utils/proxy/http";
|
||||
|
||||
const logger = createLogger("proxmoxStatsService");
|
||||
const VALID_VM_TYPES = new Set(["qemu", "lxc"]);
|
||||
const VALID_NODE = /^[A-Za-z0-9._-]+$/;
|
||||
const VALID_VMID = /^\d+$/;
|
||||
|
||||
export default async function handler(req, res) {
|
||||
const { service, type: vmType } = req.query;
|
||||
|
||||
const [node, vmid] = service;
|
||||
const [node, vmid] = service || [];
|
||||
|
||||
if (!node) {
|
||||
return res.status(400).send({
|
||||
@@ -15,6 +18,24 @@ export default async function handler(req, res) {
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof node !== "string" || !VALID_NODE.test(node) || node.includes("..")) {
|
||||
return res.status(400).send({
|
||||
error: "Invalid Proxmox node parameter",
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof vmid !== "string" || !VALID_VMID.test(vmid)) {
|
||||
return res.status(400).send({
|
||||
error: "Invalid Proxmox VMID parameter",
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof vmType !== "string" || !VALID_VM_TYPES.has(vmType)) {
|
||||
return res.status(400).send({
|
||||
error: "Invalid Proxmox type parameter",
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
const proxmoxConfig = getProxmoxConfig();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user