From b6706efe6f913a0cdb6a130ec01734fd9a108807 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 7 Oct 2023 17:49:24 -0400 Subject: [PATCH] Add validation to require protocol on urls in env Related #5961 --- server/env.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/server/env.ts b/server/env.ts index 4708e769e..3d0a2efaa 100644 --- a/server/env.ts +++ b/server/env.ts @@ -123,7 +123,11 @@ export class Environment { * The fully qualified, external facing domain name of the server. */ @IsNotEmpty() - @IsUrl({ require_tld: false }) + @IsUrl({ + protocols: ["http", "https"], + require_protocol: true, + require_tld: false, + }) public URL = process.env.URL || ""; /** @@ -133,14 +137,22 @@ export class Environment { * should be set to the same as URL. */ @IsOptional() - @IsUrl() + @IsUrl({ + protocols: ["http", "https"], + require_protocol: true, + require_tld: false, + }) public CDN_URL = this.toOptionalString(process.env.CDN_URL); /** * The fully qualified, external facing domain name of the collaboration * service, if different (unlikely) */ - @IsUrl({ require_tld: false, protocols: ["http", "https", "ws", "wss"] }) + @IsUrl({ + require_tld: false, + require_protocol: true, + protocols: ["http", "https", "ws", "wss"], + }) @IsOptional() public COLLABORATION_URL = this.toOptionalString( process.env.COLLABORATION_URL @@ -661,6 +673,7 @@ export class Environment { @IsOptional() @IsUrl({ require_tld: false, + require_protocol: true, allow_underscores: true, protocols: ["http", "https"], })