Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

refactor: implement centralized SMB validation utilities and enhance Windows local account schemas for improved security and consistency

Victor Santosb4701c7a27d4
diff --git a/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-schemas.ts b/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-schemas.ts
index 14057589ba..dd11e6b153 100644
--- a/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-schemas.ts
+++ b/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-schemas.ts
@@ -8,7 +8,11 @@ import {
} from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-schemas";
import { PasswordRequirementsSchema } from "@app/ee/services/secret-rotation-v2/shared/general";
import { SecretRotations } from "@app/lib/api-docs";
-import { CharacterType, characterValidator } from "@app/lib/validator/validate-string";
+import {
+ containsDangerousSmbChars,
+ SMB_VALIDATION_LIMITS,
+ validateWindowsUsername
+} from "@app/lib/validator/validate-smb";
import { SecretNameSchema } from "@app/server/lib/schemas";
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
@@ -26,28 +30,12 @@ export const WindowsLocalAccountRotationGeneratedCredentialsSchema = z
.min(1)
.max(2);
-// Username validation for Windows local accounts
-const validateWindowsUsername = characterValidator([
- CharacterType.AlphaNumeric,
- CharacterType.Hyphen,
- CharacterType.Underscore,
- CharacterType.Period
-]);
-
-// Dangerous characters that could enable command/RPC injection in Windows/SMB context
-// These are blocked to prevent security issues when executing SMB/RPC commands:
-// - Command separators: ; | &
-// - Command substitution: ` $ ( )
-// - Newlines: \n \r (auth file directive injection)
-// - Null bytes: \0 (string termination attacks)
-const DANGEROUS_SMB_PASSWORD_CHARS = [";", "|", "&", "`", "$", "(", ")", "\n", "\r", "\0"];
-
// Windows-specific password requirements schema that validates allowedSymbols
// doesn't contain dangerous characters that could cause command injection
const WindowsPasswordRequirementsSchema = PasswordRequirementsSchema.refine(
(data) => {
if (!data.allowedSymbols) return true;
- return !DANGEROUS_SMB_PASSWORD_CHARS.some((char) => data.allowedSymbols?.includes(char));
+ return !containsDangerousSmbChars(data.allowedSymbols);
},
{
message: "Allowed symbols cannot contain dangerous characters: ; | & ` $ ( )",
@@ -60,7 +48,10 @@ const WindowsLocalAccountRotationParametersSchema = z.object({
.string()
.trim()
.min(1, "Username required")
- .max(20, "Username too long - Windows local accounts are limited to 20 characters")
+ .max(
+ SMB_VALIDATION_LIMITS.MAX_WINDOWS_USERNAME_LENGTH,
+ "Username too long - Windows local accounts are limited to 20 characters"
+ )
.refine((val) => validateWindowsUsername(val), {
message: "Username can only contain alphanumeric characters, underscores, hyphens, and periods"
})
diff --git a/backend/src/lib/smb-rpc/smb-rpc-client.ts b/backend/src/lib/smb-rpc/smb-rpc-client.ts
index 05affb3091..869f1b7c3a 100644
--- a/backend/src/lib/smb-rpc/smb-rpc-client.ts
+++ b/backend/src/lib/smb-rpc/smb-rpc-client.ts
@@ -5,7 +5,13 @@ import * as path from "path";
import RE2 from "re2";
import { logger } from "@app/lib/logger";
-import { CharacterType, characterValidator } from "@app/lib/validator/validate-string";
+import {
+ SMB_VALIDATION_LIMITS,
+ validateDomain,
+ validateHostname,
+ validateSmbPassword,
+ validateWindowsUsername
+} from "@app/lib/validator/validate-smb";
export interface SmbRpcConfig {
host: string;
@@ -17,36 +23,6 @@ export interface SmbRpcConfig {
const SMB3_SECURITY_OPTIONS = ["--option=client min protocol=SMB3", "--option=client smb encrypt=required"];
-// Validation functions using RE2-based characterValidator for security (prevents ReDoS attacks)
-const validateHostname = characterValidator([CharacterType.AlphaNumeric, CharacterType.Period, CharacterType.Hyphen]);
-
-const validateDomain = characterValidator([
- CharacterType.AlphaNumeric,
- CharacterType.Period,
- CharacterType.Hyphen,
- CharacterType.Underscore
-]);
-
-const validateUsername = characterValidator([
- CharacterType.AlphaNumeric,
- CharacterType.Hyphen,
- CharacterType.Underscore,
- CharacterType.Period
-]);
-
-const MAX_USERNAME_LENGTH = 20;
-const MAX_ADMIN_USERNAME_LENGTH = 104;
-const MAX_HOST_LENGTH = 253;
-const MAX_DOMAIN_LENGTH = 255;
-
-// Dangerous characters that could enable command/RPC injection
-// These are blocked to prevent:
-// - Command separators: ; | &
-// - Command substitution: ` $ ( )
-// - Newlines: \n \r (auth file directive injection)
-// - Null bytes: \0 (string termination attacks)
-const DANGEROUS_PASSWORD_CHARS = [";", "|", "&", "`", "$", "(", ")", "\n", "\r", "\0"];
-
/**
* Validate host to prevent command injection
*/
@@ -54,7 +30,7 @@ const validateHost = (host: string): void => {
if (!host || host.length === 0) {
throw new Error("Host is required");
}
- if (host.length > MAX_HOST_LENGTH) {
+ if (host.length > SMB_VALIDATION_LIMITS.MAX_HOST_LENGTH) {
throw new Error("Host too long");
}
if (!validateHostname(host)) {
@@ -71,7 +47,7 @@ const validateHost = (host: string): void => {
const validateDomainInput = (domain: string | undefined): void => {
if (!domain) return;
- if (domain.length > MAX_DOMAIN_LENGTH) {
+ if (domain.length > SMB_VALIDATION_LIMITS.MAX_DOMAIN_LENGTH) {
throw new Error("Domain too long");
}
if (!validateDomain(domain)) {
@@ -98,10 +74,10 @@ const validateAdminUsername = (username: string): void => {
if (!username || username.length === 0) {
throw new Error("Admin username is required");
}
- if (username.length > MAX_ADMIN_USERNAME_LENGTH) {
+ if (username.length > SMB_VALIDATION_LIMITS.MAX_ADMIN_USERNAME_LENGTH) {
throw new Error("Admin username too long");
}
- if (!validateUsername(username)) {
+ if (!validateWindowsUsername(username)) {
throw new Error("Admin username can only contain alphanumeric characters, underscores, hyphens, and periods");
}
if (username.startsWith("-") || username.startsWith(".") || username.endsWith(".")) {
@@ -116,8 +92,7 @@ const validatePassword = (password: string): void => {
if (!password || password.length === 0) {
throw new Error("Password is required");
}
- // Disallow dangerous characters that could enable injection attacks
- if (DANGEROUS_PASSWORD_CHARS.some((char) => password.includes(char))) {
+ if (!validateSmbPassword(password)) {
throw new Error("Password cannot contain dangerous characters: ; | & ` $ ( ) or newlines");
}
};
@@ -290,14 +265,14 @@ const escapePasswordForRpc = (password: string): string => {
* - Max 20 characters for local accounts
*/
export const isValidWindowsUsername = (username: string): boolean => {
- if (!username || username.length === 0 || username.length > MAX_USERNAME_LENGTH) {
+ if (!username || username.length === 0 || username.length > SMB_VALIDATION_LIMITS.MAX_WINDOWS_USERNAME_LENGTH) {
return false;
}
// Cannot start with period or hyphen, cannot end with period
if (username.startsWith(".") || username.startsWith("-") || username.endsWith(".")) {
return false;
}
- return validateUsername(username);
+ return validateWindowsUsername(username);
};
/**
diff --git a/backend/src/lib/validator/index.ts b/backend/src/lib/validator/index.ts
index 2400af8ee1..1033c07ed7 100644
--- a/backend/src/lib/validator/index.ts
+++ b/backend/src/lib/validator/index.ts
@@ -1,4 +1,13 @@
export { isDisposableEmail } from "./validate-email";
export { isValidFolderName, isValidSecretPath } from "./validate-folder-name";
+export {
+ containsDangerousSmbChars,
+ DANGEROUS_SMB_CHARS,
+ SMB_VALIDATION_LIMITS,
+ validateDomain,
+ validateHostname,
+ validateSmbPassword,
+ validateWindowsUsername
+} from "./validate-smb";
export { blockLocalAndPrivateIpAddresses } from "./validate-url";
export { isUuidV4 } from "./validate-uuid";
diff --git a/backend/src/lib/validator/validate-smb.ts b/backend/src/lib/validator/validate-smb.ts
new file mode 100644
index 0000000000..3ca9a4b2a5
--- /dev/null
+++ b/backend/src/lib/validator/validate-smb.ts
@@ -0,0 +1,63 @@
+import { CharacterType, characterValidator } from "./validate-string";
+
+/**
+ * Windows/SMB validation utilities
+ * Shared validation functions for SMB connections and Windows local account operations
+ */
+
+// Windows username validation: alphanumeric, underscores, hyphens, periods
+// Used for both SMB connection admin users and Windows local account target users
+export const validateWindowsUsername = characterValidator([
+ CharacterType.AlphaNumeric,
+ CharacterType.Hyphen,
+ CharacterType.Underscore,
+ CharacterType.Period
+]);
+
+// Hostname validation: alphanumeric, dots, hyphens
+// Supports: hostnames (server.domain.com), IPv4 (192.168.1.1)
+export const validateHostname = characterValidator([
+ CharacterType.AlphaNumeric,
+ CharacterType.Period,
+ CharacterType.Hyphen
+]);
+
+// Domain validation: alphanumeric, dots, hyphens, underscores
+export const validateDomain = characterValidator([
+ CharacterType.AlphaNumeric,
+ CharacterType.Period,
+ CharacterType.Hyphen,
+ CharacterType.Underscore
+]);
+
+// Dangerous characters that could enable command/RPC injection in Windows/SMB context
+// These are blocked to prevent security issues:
+// - Command separators: ; | &
+// - Command substitution: ` $ ( )
+// - Newlines: \n \r (auth file directive injection)
+// - Null bytes: \0 (string termination attacks)
+export const DANGEROUS_SMB_CHARS = [";", "|", "&", "`", "$", "(", ")", "\n", "\r", "\0"];
+
+/**
+ * Validate password doesn't contain dangerous SMB characters
+ * Used for SMB connection passwords
+ */
+export const validateSmbPassword = (password: string): boolean => {
+ return !DANGEROUS_SMB_CHARS.some((char) => password.includes(char));
+};
+
+/**
+ * Check if string contains dangerous SMB characters
+ * Used for validating allowedSymbols in password requirements
+ */
+export const containsDangerousSmbChars = (value: string): boolean => {
+ return DANGEROUS_SMB_CHARS.some((char) => value.includes(char));
+};
+
+// Constants for field length limits
+export const SMB_VALIDATION_LIMITS = {
+ MAX_WINDOWS_USERNAME_LENGTH: 20,
+ MAX_ADMIN_USERNAME_LENGTH: 104,
+ MAX_HOST_LENGTH: 253,
+ MAX_DOMAIN_LENGTH: 255
+} as const;
diff --git a/backend/src/services/app-connection/smb/smb-connection-schemas.ts b/backend/src/services/app-connection/smb/smb-connection-schemas.ts
index 14d52bde59..163d39d3e2 100644
--- a/backend/src/services/app-connection/smb/smb-connection-schemas.ts
+++ b/backend/src/services/app-connection/smb/smb-connection-schemas.ts
@@ -1,7 +1,13 @@
import { z } from "zod";
import { AppConnections } from "@app/lib/api-docs";
-import { CharacterType, characterValidator } from "@app/lib/validator/validate-string";
+import {
+ SMB_VALIDATION_LIMITS,
+ validateDomain,
+ validateHostname,
+ validateSmbPassword,
+ validateWindowsUsername
+} from "@app/lib/validator/validate-smb";
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
import {
BaseAppConnectionSchema,
@@ -12,45 +18,12 @@ import {
import { APP_CONNECTION_NAME_MAP } from "../app-connection-maps";
import { SmbConnectionMethod } from "./smb-connection-enums";
-// Hostname validation: alphanumeric, dots, hyphens (cannot start with hyphen or period)
-// Supports: hostnames (server.domain.com), IPv4 (192.168.1.1)
-const validateHostname = characterValidator([CharacterType.AlphaNumeric, CharacterType.Period, CharacterType.Hyphen]);
-
-// Domain validation: alphanumeric, dots, hyphens, underscores (cannot start with hyphen or period)
-const validateDomain = characterValidator([
- CharacterType.AlphaNumeric,
- CharacterType.Period,
- CharacterType.Hyphen,
- CharacterType.Underscore
-]);
-
-// Username validation for SMB admin user
-// Windows usernames: alphanumeric, underscores, hyphens, periods (cannot start with period or hyphen, cannot end with period)
-const validateSmbUsername = characterValidator([
- CharacterType.AlphaNumeric,
- CharacterType.Hyphen,
- CharacterType.Underscore,
- CharacterType.Period
-]);
-
-// Dangerous characters that could enable command/RPC injection
-// These are blocked to prevent:
-// - Command separators: ; | &
-// - Command substitution: ` $ ( )
-// - Newlines: \n \r (auth file directive injection)
-// - Null bytes: \0 (string termination attacks)
-const DANGEROUS_PASSWORD_CHARS = [";", "|", "&", "`", "$", "(", ")", "\n", "\r", "\0"];
-
-const validateSmbPassword = (password: string): boolean => {
- return !DANGEROUS_PASSWORD_CHARS.some((char) => password.includes(char));
-};
-
export const SmbConnectionCredentialsSchema = z.object({
host: z
.string()
.trim()
.min(1, "Host required")
- .max(253, "Host too long")
+ .max(SMB_VALIDATION_LIMITS.MAX_HOST_LENGTH, "Host too long")
.refine((val) => validateHostname(val), {
message: "Host can only contain alphanumeric characters, dots, and hyphens"
})
@@ -62,7 +35,7 @@ export const SmbConnectionCredentialsSchema = z.object({
domain: z
.string()
.trim()
- .max(255, "Domain too long")
+ .max(SMB_VALIDATION_LIMITS.MAX_DOMAIN_LENGTH, "Domain too long")
.refine((val) => val === "" || validateDomain(val), {
message: "Domain can only contain alphanumeric characters, dots, hyphens, and underscores"
})
@@ -75,8 +48,8 @@ export const SmbConnectionCredentialsSchema = z.object({
.string()
.trim()
.min(1, "Username required")
- .max(104, "Username too long")
- .refine((val) => validateSmbUsername(val), {
+ .max(SMB_VALIDATION_LIMITS.MAX_ADMIN_USERNAME_LENGTH, "Username too long")
+ .refine((val) => validateWindowsUsername(val), {
message: "Username can only contain alphanumeric characters, underscores, hyphens, and periods"
})
.refine((val) => !val.startsWith("-") && !val.startsWith(".") && !val.endsWith("."), {
diff --git a/frontend/src/components/secret-rotations-v2/forms/schemas/windows-local-account-rotation-schema.ts b/frontend/src/components/secret-rotations-v2/forms/schemas/windows-local-account-rotation-schema.ts
index 8d73f18bac..59f83ff89d 100644
--- a/frontend/src/components/secret-rotations-v2/forms/schemas/windows-local-account-rotation-schema.ts
+++ b/frontend/src/components/secret-rotations-v2/forms/schemas/windows-local-account-rotation-schema.ts
@@ -2,28 +2,19 @@ import { z } from "zod";
import { BaseSecretRotationSchema } from "@app/components/secret-rotations-v2/forms/schemas/base-secret-rotation-v2-schema";
import { PasswordRequirementsSchema } from "@app/components/secret-rotations-v2/forms/schemas/shared";
+import {
+ containsDangerousSmbChars,
+ SMB_USERNAME_REGEX,
+ SMB_VALIDATION_LIMITS
+} from "@app/helpers/smb";
import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
import { WindowsLocalAccountRotationMethod } from "@app/hooks/api/secretRotationsV2/types/windows-local-account-rotation";
-// Windows local account username validation:
-// - Cannot start with a period or hyphen
-// - Cannot end with a period
-// - Can contain alphanumeric, underscore, hyphen, and period
-// - Max 20 characters for local accounts
-const WINDOWS_USERNAME_REGEX = /^[a-zA-Z0-9_][a-zA-Z0-9_.-]*$/;
-
-// Dangerous characters that could enable command/RPC injection in Windows/SMB context
-// - Command separators: ; | &
-// - Command substitution: ` $ ( )
-// - Newlines: \n \r (auth file directive injection)
-// - Null bytes: \0 (string termination attacks)
-const DANGEROUS_SMB_PASSWORD_CHARS = [";", "|", "&", "`", "$", "(", ")", "\n", "\r", "\0"];
-
// Windows-specific password requirements schema that filters dangerous characters from allowedSymbols
const WindowsPasswordRequirementsSchema = PasswordRequirementsSchema.refine(
(data) => {
if (!data.allowedSymbols) return true;
- return !DANGEROUS_SMB_PASSWORD_CHARS.some((char) => data.allowedSymbols?.includes(char));
+ return !containsDangerousSmbChars(data.allowedSymbols);
},
{
message: "Allowed symbols cannot contain the characters: ; | & ` $ ( ) or newlines",
@@ -39,8 +30,11 @@ export const WindowsLocalAccountRotationSchema = z
.string()
.trim()
.min(1, "Username required")
- .max(20, "Username too long - Windows local accounts are limited to 20 characters")
- .refine((val) => WINDOWS_USERNAME_REGEX.test(val), {
+ .max(
+ SMB_VALIDATION_LIMITS.MAX_WINDOWS_USERNAME_LENGTH,
+ "Username too long - Windows local accounts are limited to 20 characters"
+ )
+ .refine((val) => SMB_USERNAME_REGEX.test(val), {
message:
"Username can only contain alphanumeric characters, underscores, hyphens, and periods"
})
diff --git a/frontend/src/helpers/smb.ts b/frontend/src/helpers/smb.ts
new file mode 100644
index 0000000000..ba7366ad78
--- /dev/null
+++ b/frontend/src/helpers/smb.ts
@@ -0,0 +1,47 @@
+/**
+ * Windows/SMB validation utilities
+ * Shared validation functions for SMB connections and Windows local account operations
+ * These must stay in sync with backend/src/lib/validator/validate-smb.ts
+ */
+
+// Regex patterns for character validation
+// Hostname: alphanumeric, dots, hyphens
+export const SMB_HOSTNAME_REGEX = /^[a-zA-Z0-9.-]+$/;
+
+// Domain: alphanumeric, dots, hyphens, underscores
+export const SMB_DOMAIN_REGEX = /^[a-zA-Z0-9._-]+$/;
+
+// Windows username: alphanumeric, underscores, hyphens, periods
+// First character must be alphanumeric or underscore (no hyphen or period)
+export const SMB_USERNAME_REGEX = /^[a-zA-Z0-9_][a-zA-Z0-9._-]*$/;
+
+// Dangerous characters that could enable command/RPC injection in Windows/SMB context
+// These are blocked to prevent security issues:
+// - Command separators: ; | &
+// - Command substitution: ` $ ( )
+// - Newlines: \n \r (auth file directive injection)
+// - Null bytes: \0 (string termination attacks)
+export const DANGEROUS_SMB_CHARS = [";", "|", "&", "`", "$", "(", ")", "\n", "\r", "\0"];
+
+/**
+ * Validate password doesn't contain dangerous SMB characters
+ */
+export const validateSmbPassword = (password: string): boolean => {
+ return !DANGEROUS_SMB_CHARS.some((char) => password.includes(char));
+};
+
+/**
+ * Check if string contains dangerous SMB characters
+ * Used for validating allowedSymbols in password requirements
+ */
+export const containsDangerousSmbChars = (value: string): boolean => {
+ return DANGEROUS_SMB_CHARS.some((char) => value.includes(char));
+};
+
+// Constants for field length limits (must match backend)
+export const SMB_VALIDATION_LIMITS = {
+ MAX_WINDOWS_USERNAME_LENGTH: 20,
+ MAX_ADMIN_USERNAME_LENGTH: 104,
+ MAX_HOST_LENGTH: 253,
+ MAX_DOMAIN_LENGTH: 255
+} as const;
diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/SmbConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/SmbConnectionForm.tsx
index babceb029e..368db6036e 100644
--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/SmbConnectionForm.tsx
+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/SmbConnectionForm.tsx
@@ -17,6 +17,13 @@ import {
import { OrgPermissionSubjects, useSubscription } from "@app/context";
import { OrgGatewayPermissionActions } from "@app/context/OrgPermissionContext/types";
import { APP_CONNECTION_MAP } from "@app/helpers/appConnections";
+import {
+ SMB_DOMAIN_REGEX,
+ SMB_HOSTNAME_REGEX,
+ SMB_USERNAME_REGEX,
+ SMB_VALIDATION_LIMITS,
+ validateSmbPassword
+} from "@app/helpers/smb";
import { gatewaysQueryKeys } from "@app/hooks/api";
import { SmbConnectionMethod, TSmbConnection } from "@app/hooks/api/appConnections";
import { AppConnection } from "@app/hooks/api/appConnections/enums";
@@ -31,18 +38,6 @@ type Props = {
onSubmit: (formData: FormData) => Promise<void>;
};
-// Character validation regex patterns (must match backend validation)
-const HOSTNAME_REGEX = /^[a-zA-Z0-9.-]+$/;
-const DOMAIN_REGEX = /^[a-zA-Z0-9._-]+$/;
-const USERNAME_REGEX = /^[a-zA-Z0-9._-]+$/;
-
-// Dangerous characters that could enable command/RPC injection
-const DANGEROUS_PASSWORD_CHARS = [";", "|", "&", "`", "$", "(", ")", "\n", "\r", "\0"];
-
-const validatePassword = (password: string): boolean => {
- return !DANGEROUS_PASSWORD_CHARS.some((char) => password.includes(char));
-};
-
const formSchema = genericAppConnectionFieldsSchema.extend({
app: z.literal(AppConnection.SMB),
method: z.literal(SmbConnectionMethod.Credentials),
@@ -51,8 +46,8 @@ const formSchema = genericAppConnectionFieldsSchema.extend({
.string()
.trim()
.min(1, "Host required")
- .max(253, "Host too long")
- .refine((val) => HOSTNAME_REGEX.test(val), {
+ .max(SMB_VALIDATION_LIMITS.MAX_HOST_LENGTH, "Host too long")
+ .refine((val) => SMB_HOSTNAME_REGEX.test(val), {
message: "Host can only contain alphanumeric characters, dots, and hyphens"
})
.refine((val) => !val.startsWith("-") && !val.startsWith("."), {
@@ -62,8 +57,8 @@ const formSchema = genericAppConnectionFieldsSchema.extend({
domain: z
.string()
.trim()
- .max(255, "Domain too long")
- .refine((val) => val === "" || DOMAIN_REGEX.test(val), {
+ .max(SMB_VALIDATION_LIMITS.MAX_DOMAIN_LENGTH, "Domain too long")
+ .refine((val) => val === "" || SMB_DOMAIN_REGEX.test(val), {
message: "Domain can only contain alphanumeric characters, dots, hyphens, and underscores"
})
.refine((val) => val === "" || (!val.startsWith("-") && !val.startsWith(".")), {
@@ -74,9 +69,10 @@ const formSchema = genericAppConnectionFieldsSchema.extend({
.string()
.trim()
.min(1, "Username required")
- .max(104, "Username too long")
- .refine((val) => USERNAME_REGEX.test(val), {
- message: "Username can only contain alphanumeric characters, underscores, hyphens, and periods"
+ .max(SMB_VALIDATION_LIMITS.MAX_ADMIN_USERNAME_LENGTH, "Username too long")
+ .refine((val) => SMB_USERNAME_REGEX.test(val), {
+ message:
+ "Username can only contain alphanumeric characters, underscores, hyphens, and periods"
})
.refine((val) => !val.startsWith("-") && !val.startsWith(".") && !val.endsWith("."), {
message: "Username cannot start with a hyphen or period, and cannot end with a period"
@@ -84,7 +80,7 @@ const formSchema = genericAppConnectionFieldsSchema.extend({
password: z
.string()
.min(1, "Password required")
- .refine((val) => validatePassword(val), {
+ .refine((val) => validateSmbPassword(val), {
message: "Password cannot contain the following characters: ; | & ` $ ( ) or newlines"
})
})