Skip to content

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

Address claude comments

Carlos Monastyrski7922c951e05c
diff --git a/backend/src/db/schemas/internal-certificate-authorities.ts b/backend/src/db/schemas/internal-certificate-authorities.ts
index 73b17c9423..d20fb52f91 100644
--- a/backend/src/db/schemas/internal-certificate-authorities.ts
+++ b/backend/src/db/schemas/internal-certificate-authorities.ts
@@ -31,7 +31,7 @@ export const InternalCertificateAuthoritiesSchema = z.object({
lastRenewalStatus: z.string().nullable().optional(),
lastRenewalMessage: z.string().nullable().optional(),
lastRenewalAt: z.date().nullable().optional(),
- crlDistributionPointUrls: z.string().array().default([])
+ crlDistributionPointUrls: z.string().array()
});
export type TInternalCertificateAuthorities = z.infer<typeof InternalCertificateAuthoritiesSchema>;
diff --git a/backend/src/services/certificate-authority/certificate-authority-fns.ts b/backend/src/services/certificate-authority/certificate-authority-fns.ts
index c90acb5436..c1cc076452 100644
--- a/backend/src/services/certificate-authority/certificate-authority-fns.ts
+++ b/backend/src/services/certificate-authority/certificate-authority-fns.ts
@@ -540,7 +540,17 @@ export const expandInternalCa = (
const TRAILING_SLASHES_REGEX = new RE2("/+$");
-export const normalizeUrlForComparison = (url: string) => url.trim().replace(TRAILING_SLASHES_REGEX, "").toLowerCase();
+// Per RFC 3986 §6.2.2.1 only scheme and host are case-insensitive; path/query/hash are case-sensitive.
+export const normalizeUrlForComparison = (url: string) => {
+ const trimmed = url.trim();
+ try {
+ const parsed = new URL(trimmed);
+ const pathname = parsed.pathname.replace(TRAILING_SLASHES_REGEX, "");
+ return `${parsed.protocol}//${parsed.host}${pathname}${parsed.search}${parsed.hash}`;
+ } catch {
+ return trimmed.replace(TRAILING_SLASHES_REGEX, "").toLowerCase();
+ }
+};
export const buildCrlDistributionPointUrls = (
managedUrl: string,
diff --git a/backend/src/services/certificate-authority/certificate-authority-validators.ts b/backend/src/services/certificate-authority/certificate-authority-validators.ts
index 93d0a098e5..7d340b8b71 100644
--- a/backend/src/services/certificate-authority/certificate-authority-validators.ts
+++ b/backend/src/services/certificate-authority/certificate-authority-validators.ts
@@ -10,9 +10,6 @@ const MAX_INTERNAL_CA_DISTRIBUTION_POINT_URLS = 4;
const MAX_DISTRIBUTION_POINT_URL_LENGTH = 2048;
const HTTP_URL_REGEX = new RE2("^https?://", "i");
-const validateDistributionPointUrl = (url: string) =>
- url.length > 0 && url.length <= MAX_DISTRIBUTION_POINT_URL_LENGTH && HTTP_URL_REGEX.test(url);
-
const dedupeNormalizedDistributionPointUrls = (urls: string[]) => {
const seen = new Set<string>();
return urls.every((url) => {
@@ -31,7 +28,8 @@ export const distributionPointUrlsSchema = z
.max(MAX_DISTRIBUTION_POINT_URL_LENGTH, {
message: `URL exceeds the maximum length of ${MAX_DISTRIBUTION_POINT_URL_LENGTH} characters`
})
- .refine(validateDistributionPointUrl, { message: "URL must use http:// or https://" })
+ .url({ message: "Must be a valid URL" })
+ .refine((url) => HTTP_URL_REGEX.test(url), { message: "URL must use http:// or https://" })
)
.max(MAX_INTERNAL_CA_DISTRIBUTION_POINT_URLS, {
message: `Up to ${MAX_INTERNAL_CA_DISTRIBUTION_POINT_URLS} URLs are allowed`
diff --git a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaDistributionPointsSection.tsx b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaDistributionPointsSection.tsx
index b9e38bed23..0911a2c52b 100644
--- a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaDistributionPointsSection.tsx
+++ b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaDistributionPointsSection.tsx
@@ -50,6 +50,7 @@ const distributionPointUrlEntrySchema = z.object({
.string()
.trim()
.max(2048, "URL is too long")
+ .url("Must be a valid URL")
.refine((url) => /^https?:\/\//i.test(url), { message: "URL must use http:// or https://" })
});
diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaModal.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaModal.tsx
index 8a0cb5d7d0..067974a627 100644
--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaModal.tsx
+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaModal.tsx
@@ -50,6 +50,7 @@ const distributionPointUrlEntrySchema = z.object({
.string()
.trim()
.max(2048, "URL is too long")
+ .url("Must be a valid URL")
.refine((url) => /^https?:\/\//i.test(url), { message: "URL must use http:// or https://" })
});