Skip to content

Commit 8c7bc82

Browse files
authored
Merge pull request #3323 from Dokploy/copilot/fix-shell-command-issue
fix: quote registry username in docker login to prevent shell variable expansion
2 parents 6772575 + 44645a6 commit 8c7bc82

File tree

7 files changed

+46
-12
lines changed

7 files changed

+46
-12
lines changed

apps/dokploy/__test__/cluster/upload.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,38 @@ describe("getRegistryTag", () => {
206206
expect(result).toBe("docker.io/myuser/repo");
207207
});
208208
});
209+
210+
describe("special characters in username", () => {
211+
it("should handle Harbor robot account username with $ (e.g. robot$library+dokploy)", () => {
212+
const registry = createMockRegistry({
213+
username: "robot$library+dokploy",
214+
});
215+
const result = getRegistryTag(registry, "nginx");
216+
expect(result).toBe("docker.io/robot$library+dokploy/nginx");
217+
});
218+
219+
it("should handle username with $ and other special characters", () => {
220+
const registry = createMockRegistry({
221+
username: "robot$test+app",
222+
});
223+
const result = getRegistryTag(registry, "myapp:latest");
224+
expect(result).toBe("docker.io/robot$test+app/myapp:latest");
225+
});
226+
227+
it("should handle username with multiple $ symbols", () => {
228+
const registry = createMockRegistry({
229+
username: "user$name$test",
230+
});
231+
const result = getRegistryTag(registry, "app");
232+
expect(result).toBe("docker.io/user$name$test/app");
233+
});
234+
235+
it("should handle username with + and - symbols", () => {
236+
const registry = createMockRegistry({
237+
username: "robot+test-user",
238+
});
239+
const result = getRegistryTag(registry, "nginx:latest");
240+
expect(result).toBe("docker.io/robot+test-user/nginx:latest");
241+
});
242+
});
209243
});

apps/dokploy/__test__/compose/domain/host-rule-format.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Domain } from "@dokploy/server";
22
import { createDomainLabels } from "@dokploy/server";
3-
import { parse, stringify } from "yaml";
43
import { describe, expect, it } from "vitest";
4+
import { parse, stringify } from "yaml";
55

66
/**
77
* Regression tests for Traefik Host rule label format.

apps/dokploy/components/dashboard/settings/servers/actions/show-server-actions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { Activity } from "lucide-react";
22
import { useState } from "react";
3+
import { Button } from "@/components/ui/button";
34
import {
45
Dialog,
56
DialogContent,
67
DialogDescription,
78
DialogTitle,
89
DialogTrigger,
910
} from "@/components/ui/dialog";
10-
import { Button } from "@/components/ui/button";
1111
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
1212
import { ShowStorageActions } from "./show-storage-actions";
1313
import { ShowTraefikActions } from "./show-traefik-actions";

apps/dokploy/components/dashboard/settings/servers/handle-servers.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { zodResolver } from "@hookform/resolvers/zod";
2-
import { PlusIcon, Pencil } from "lucide-react";
2+
import { Pencil, PlusIcon } from "lucide-react";
33
import Link from "next/link";
44
import { useTranslation } from "next-i18next";
55
import { useEffect, useState } from "react";

apps/dokploy/components/dashboard/settings/servers/show-servers.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import { format } from "date-fns";
22
import {
3+
Clock,
4+
Key,
35
KeyIcon,
46
Loader2,
57
MoreHorizontal,
6-
ServerIcon,
7-
Clock,
8-
User,
9-
Key,
108
Network,
11-
Terminal,
12-
Settings,
139
Pencil,
10+
ServerIcon,
11+
Settings,
12+
Terminal,
1413
Trash2,
14+
User,
1515
} from "lucide-react";
1616
import Link from "next/link";
1717
import { useRouter } from "next/router";

apps/dokploy/components/shared/breadcrumb-sidebar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
import { ChevronDown } from "lucide-react";
12
import Link from "next/link";
23
import { Fragment } from "react";
3-
import { ChevronDown } from "lucide-react";
44
import {
55
Breadcrumb,
66
BreadcrumbItem,
77
BreadcrumbLink,
88
BreadcrumbList,
9-
BreadcrumbSeparator,
109
BreadcrumbPage,
10+
BreadcrumbSeparator,
1111
} from "@/components/ui/breadcrumb";
1212
import {
1313
DropdownMenu,

packages/server/src/utils/cluster/upload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ const getRegistryCommands = (
117117
): string => {
118118
return `
119119
echo "📦 [Enabled Registry] Uploading image to '${registry.registryType}' | '${registryTag}'" ;
120-
echo "${registry.password}" | docker login ${registry.registryUrl} -u ${registry.username} --password-stdin || {
120+
echo "${registry.password}" | docker login ${registry.registryUrl} -u '${registry.username}' --password-stdin || {
121121
echo "❌ DockerHub Failed" ;
122122
exit 1;
123123
}

0 commit comments

Comments
 (0)