Skip to content

Commit

Permalink
Potential fix for code scanning alert no. 32: Server-side request for…
Browse files Browse the repository at this point in the history
…gery

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 123067f commit 5da5e76
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions express/backend/src/api/weblate-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ import { Router } from "express";
import { env } from "../common";

const WEBLATE_API = "https://weblate.iobroker.net/api/";
const ALLOWED_PATHS = ["/projects/", "/components/", "/languages/"];

const router = Router();

router.get<any>("/api/weblate/*", async function (req, res) {
try {
const userPath = `/${req.params["0"]}`;
if (!ALLOWED_PATHS.some(path => userPath.startsWith(path))) {
return res.status(400).send("Invalid path");
}
const url = new URL(`${WEBLATE_API}${req.params["0"]}`);
const q = req.query;
if (q.page) {
Expand Down

0 comments on commit 5da5e76

Please sign in to comment.