mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-09-14 11:06:15 +05:00
fix: use proper linting
This commit is contained in:
parent
fe0a84dde8
commit
f3c7edcfd6
@ -82,20 +82,29 @@ const sanitizeCommand = (command: string) => {
|
||||
);
|
||||
}
|
||||
|
||||
if (sanitizedCommand.includes("&")) {
|
||||
if (sanitizedCommand.includes("&")) {
|
||||
// Block single '&' (e.g., backgrounding tasks) or malformed chains like '&&&'
|
||||
if (/(?<!&)&(?!&)/.test(sanitizedCommand) || sanitizedCommand.includes("&&&")) {
|
||||
if (
|
||||
/(?<!&)&(?!&)/.test(sanitizedCommand) ||
|
||||
sanitizedCommand.includes("&&&")
|
||||
) {
|
||||
throw new Error("Single '&' is not allowed. Use '&&' for chaining.");
|
||||
}
|
||||
|
||||
// Split by '&&' and check that every chained command (skipping the first one) is safe
|
||||
const chains = sanitizedCommand.split("&&").map((cmd) => cmd.trim());
|
||||
const isSafeChain = chains.slice(1).every((cmd) =>
|
||||
cmd.startsWith("docker compose ") || cmd.startsWith("docker-compose ")
|
||||
);
|
||||
const isSafeChain = chains
|
||||
.slice(1)
|
||||
.every(
|
||||
(cmd) =>
|
||||
cmd.startsWith("docker compose ") ||
|
||||
cmd.startsWith("docker-compose "),
|
||||
);
|
||||
|
||||
if (!isSafeChain) {
|
||||
throw new Error("Chained commands must strictly start with 'docker compose '");
|
||||
throw new Error(
|
||||
"Chained commands must strictly start with 'docker compose '",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user