mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-09-14 11:06:15 +05:00
fix: reject unsafe restore path metacharacters
This commit is contained in:
parent
6faf01ec3c
commit
54893f0dee
@ -8,15 +8,22 @@ import {
|
||||
paths,
|
||||
} from "../..";
|
||||
|
||||
const UNSAFE_BACKUP_PATH_CHARS = /[\0\r\n;&|`$<>]/;
|
||||
|
||||
export const normalizeVolumeBackupFilePath = (value: string) => {
|
||||
const normalized = value.trim().replace(/\\/g, "/");
|
||||
if (!normalized || normalized.startsWith("/") || normalized.endsWith("/")) {
|
||||
if (
|
||||
!normalized ||
|
||||
normalized.startsWith("/") ||
|
||||
normalized.endsWith("/") ||
|
||||
UNSAFE_BACKUP_PATH_CHARS.test(normalized)
|
||||
) {
|
||||
throw new Error("Invalid volume backup file path");
|
||||
}
|
||||
const segments = normalized.split("/");
|
||||
if (
|
||||
segments.some(
|
||||
(segment) => !segment || segment === "." || segment === ".." || segment.includes("\0"),
|
||||
(segment) => !segment || segment === "." || segment === "..",
|
||||
)
|
||||
) {
|
||||
throw new Error("Invalid volume backup file path");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user