Skip to content

Commit 2e03cf3

Browse files
committed
refactor: implement safe URL validation for whitelabeling settings in both client and server schemas
1 parent 33532d3 commit 2e03cf3

3 files changed

Lines changed: 24 additions & 37 deletions

File tree

apps/dokploy/components/proprietary/whitelabeling/whitelabeling-settings.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,21 @@ import { Textarea } from "@/components/ui/textarea";
3030
import { api } from "@/utils/api";
3131
import { WhitelabelingPreview } from "./whitelabeling-preview";
3232

33+
const safeUrlField = z
34+
.string()
35+
.refine((val) => val === "" || /^https?:\/\//i.test(val), {
36+
message: "Only http:// and https:// URLs are allowed",
37+
});
38+
3339
const formSchema = z.object({
3440
appName: z.string(),
3541
appDescription: z.string(),
36-
logoUrl: z.string(),
37-
faviconUrl: z.string(),
42+
logoUrl: safeUrlField,
43+
faviconUrl: safeUrlField,
3844
customCss: z.string(),
39-
loginLogoUrl: z.string(),
40-
supportUrl: z.string(),
41-
docsUrl: z.string(),
45+
loginLogoUrl: safeUrlField,
46+
supportUrl: safeUrlField,
47+
docsUrl: safeUrlField,
4248
errorPageTitle: z.string(),
4349
errorPageDescription: z.string(),
4450
metaTitle: z.string(),

packages/server/src/db/schema/web-server-settings.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,16 +187,23 @@ export const apiUpdateDockerCleanup = z.object({
187187
});
188188

189189
// Whitelabeling validation schemas
190+
const safeUrl = z
191+
.string()
192+
.refine((url) => /^https?:\/\//i.test(url), {
193+
message: "Only http:// and https:// URLs are allowed",
194+
})
195+
.nullable();
196+
190197
export const whitelabelingConfigSchema = z.object({
191198
appName: z.string().nullable(),
192199
appDescription: z.string().nullable(),
193-
logoUrl: z.string().nullable(),
194-
faviconUrl: z.string().nullable(),
200+
logoUrl: safeUrl,
201+
faviconUrl: safeUrl,
195202
primaryColor: z.string().nullable(),
196203
customCss: z.string().nullable(),
197-
loginLogoUrl: z.string().nullable(),
198-
supportUrl: z.string().nullable(),
199-
docsUrl: z.string().nullable(),
204+
loginLogoUrl: safeUrl,
205+
supportUrl: safeUrl,
206+
docsUrl: safeUrl,
200207
errorPageTitle: z.string().nullable(),
201208
errorPageDescription: z.string().nullable(),
202209
metaTitle: z.string().nullable(),
Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import {
2-
sendDiscordNotification,
3-
sendEmailNotification,
4-
} from "../utils/notifications/utils";
1+
import { sendEmailNotification } from "../utils/notifications/utils";
52
export const sendEmail = async ({
63
email,
74
subject,
@@ -26,26 +23,3 @@ export const sendEmail = async ({
2623

2724
return true;
2825
};
29-
30-
export const sendDiscordNotificationWelcome = async (email: string) => {
31-
await sendDiscordNotification(
32-
{
33-
webhookUrl: process.env.DISCORD_WEBHOOK_URL || "",
34-
},
35-
{
36-
title: "New User Registered",
37-
color: 0x00ff00,
38-
fields: [
39-
{
40-
name: "Email",
41-
value: email,
42-
inline: true,
43-
},
44-
],
45-
timestamp: new Date(),
46-
footer: {
47-
text: "Dokploy User Registration Notification",
48-
},
49-
},
50-
);
51-
};

0 commit comments

Comments
 (0)