Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Address PR comments
Carlos Monastyrski488f81ecd6fb
diff --git a/frontend/src/pages/cert-manager/CertificatePolicyDetailsByIDPage/CertificatePolicyDetailsByIDPage.tsx b/frontend/src/pages/cert-manager/CertificatePolicyDetailsByIDPage/CertificatePolicyDetailsByIDPage.tsxindex 4e53c0cd87..3b46e4202d 100644--- a/frontend/src/pages/cert-manager/CertificatePolicyDetailsByIDPage/CertificatePolicyDetailsByIDPage.tsx+++ b/frontend/src/pages/cert-manager/CertificatePolicyDetailsByIDPage/CertificatePolicyDetailsByIDPage.tsx@@ -64,14 +64,10 @@ const Page = () => {const projectId = currentProject?.id || "";const hasAnyEnforcement = Boolean(- policy?.subject?.length ||- policy?.sans?.length ||- policy?.keyUsages?.required?.length ||- policy?.keyUsages?.allowed?.length ||- policy?.keyUsages?.denied?.length ||- policy?.extendedKeyUsages?.required?.length ||- policy?.extendedKeyUsages?.allowed?.length ||- policy?.extendedKeyUsages?.denied?.length ||+ policy?.subject ||+ policy?.sans ||+ policy?.keyUsages ||+ policy?.extendedKeyUsages ||policy?.algorithms?.signature?.length ||policy?.algorithms?.keyAlgorithm?.length ||policy?.validity?.max ||diff --git a/frontend/src/pages/cert-manager/CertificatePolicyDetailsByIDPage/components/PolicyKeyUsagesSection.tsx b/frontend/src/pages/cert-manager/CertificatePolicyDetailsByIDPage/components/PolicyKeyUsagesSection.tsxindex da296a21ae..f329f38b99 100644--- a/frontend/src/pages/cert-manager/CertificatePolicyDetailsByIDPage/components/PolicyKeyUsagesSection.tsx+++ b/frontend/src/pages/cert-manager/CertificatePolicyDetailsByIDPage/components/PolicyKeyUsagesSection.tsx@@ -24,13 +24,13 @@ export const PolicyKeyUsagesSection = ({ policy }: Props) => {const ku = policy.keyUsages;const eku = policy.extendedKeyUsages;- const hasKu = ku && (ku.allowed?.length || ku.required?.length || ku.denied?.length);- const hasEku = eku && (eku.allowed?.length || eku.required?.length || eku.denied?.length);-- if (!hasKu && !hasEku) {+ if (!ku && !eku) {return null;}+ const kuEmpty = ku && !(ku.allowed?.length || ku.required?.length || ku.denied?.length);+ const ekuEmpty = eku && !(eku.allowed?.length || eku.required?.length || eku.denied?.length);+const formatKu = (v: string) => formatKeyUsage(v as CertKeyUsageType);const formatEku = (v: string) => formatExtendedKeyUsage(v as CertExtendedKeyUsageType);@@ -42,21 +42,39 @@ export const PolicyKeyUsagesSection = ({ policy }: Props) => {</CardHeader><CardContent><DetailGroup>- {hasKu && (+ {ku && (<div className="flex flex-col gap-y-3 border-b border-mineshaft-700 pb-3 last:border-b-0 last:pb-0"><div className="text-sm font-medium text-foreground">Key Usages</div>- <RuleList label="Allowed" values={ku?.allowed} formatter={formatKu} />- <RuleList label="Required" values={ku?.required} formatter={formatKu} />- <RuleList label="Denied" values={ku?.denied} formatter={formatKu} />+ {kuEmpty ? (+ <p className="text-sm text-muted">+ No key usages are allowed. Certificates issued under this policy cannot include+ any key usages.+ </p>+ ) : (+ <>+ <RuleList label="Allowed" values={ku.allowed} formatter={formatKu} />+ <RuleList label="Required" values={ku.required} formatter={formatKu} />+ <RuleList label="Denied" values={ku.denied} formatter={formatKu} />+ </>+ )}</div>)}- {hasEku && (+ {eku && (<div className="flex flex-col gap-y-3"><div className="text-sm font-medium text-foreground">Extended Key Usages</div>- <RuleList label="Allowed" values={eku?.allowed} formatter={formatEku} />- <RuleList label="Required" values={eku?.required} formatter={formatEku} />- <RuleList label="Denied" values={eku?.denied} formatter={formatEku} />+ {ekuEmpty ? (+ <p className="text-sm text-muted">+ No extended key usages are allowed. Certificates issued under this policy cannot+ include any extended key usages.+ </p>+ ) : (+ <>+ <RuleList label="Allowed" values={eku.allowed} formatter={formatEku} />+ <RuleList label="Required" values={eku.required} formatter={formatEku} />+ <RuleList label="Denied" values={eku.denied} formatter={formatEku} />+ </>+ )}</div>)}</DetailGroup>diff --git a/frontend/src/pages/cert-manager/CertificatePolicyDetailsByIDPage/components/PolicySansRulesSection.tsx b/frontend/src/pages/cert-manager/CertificatePolicyDetailsByIDPage/components/PolicySansRulesSection.tsxindex 3a01dc752a..dd3ba131b7 100644--- a/frontend/src/pages/cert-manager/CertificatePolicyDetailsByIDPage/components/PolicySansRulesSection.tsx+++ b/frontend/src/pages/cert-manager/CertificatePolicyDetailsByIDPage/components/PolicySansRulesSection.tsx@@ -19,17 +19,17 @@ type Props = {};export const PolicySansRulesSection = ({ policy }: Props) => {- const entries = (policy.sans ?? []).filter(+ if (!policy.sans) {+ return null;+ }++ const entries = policy.sans.filter((rule) =>(rule.allowed && rule.allowed.length > 0) ||(rule.required && rule.required.length > 0) ||(rule.denied && rule.denied.length > 0));- if (entries.length === 0) {- return null;- }-return (<Card className="w-full"><CardHeader className="border-b">@@ -37,22 +37,29 @@ export const PolicySansRulesSection = ({ policy }: Props) => {<CardDescription>Constraints on SAN entries in issued certificates</CardDescription></CardHeader><CardContent>- <DetailGroup>- {entries.map((rule, idx) => (- <div- // eslint-disable-next-line react/no-array-index-key- key={`${rule.type}-${idx}`}- className="flex flex-col gap-y-3 border-b border-mineshaft-700 pb-3 last:border-b-0 last:pb-0"- >- <div className="text-sm font-medium text-foreground">- {formatSANType(rule.type as CertSubjectAlternativeNameType)}+ {entries.length === 0 ? (+ <p className="text-sm text-muted">+ No subject alternative names are allowed. Certificates issued under this policy cannot+ include any SANs.+ </p>+ ) : (+ <DetailGroup>+ {entries.map((rule, idx) => (+ <div+ // eslint-disable-next-line react/no-array-index-key+ key={`${rule.type}-${idx}`}+ className="flex flex-col gap-y-3 border-b border-mineshaft-700 pb-3 last:border-b-0 last:pb-0"+ >+ <div className="text-sm font-medium text-foreground">+ {formatSANType(rule.type as CertSubjectAlternativeNameType)}+ </div>+ <RuleList label="Allowed" values={rule.allowed} />+ <RuleList label="Required" values={rule.required} />+ <RuleList label="Denied" values={rule.denied} /></div>- <RuleList label="Allowed" values={rule.allowed} />- <RuleList label="Required" values={rule.required} />- <RuleList label="Denied" values={rule.denied} />- </div>- ))}- </DetailGroup>+ ))}+ </DetailGroup>+ )}</CardContent></Card>);diff --git a/frontend/src/pages/cert-manager/CertificatePolicyDetailsByIDPage/components/PolicySubjectRulesSection.tsx b/frontend/src/pages/cert-manager/CertificatePolicyDetailsByIDPage/components/PolicySubjectRulesSection.tsxindex b4b61eae60..ede3c2aae1 100644--- a/frontend/src/pages/cert-manager/CertificatePolicyDetailsByIDPage/components/PolicySubjectRulesSection.tsx+++ b/frontend/src/pages/cert-manager/CertificatePolicyDetailsByIDPage/components/PolicySubjectRulesSection.tsx@@ -19,17 +19,17 @@ type Props = {};export const PolicySubjectRulesSection = ({ policy }: Props) => {- const entries = (policy.subject ?? []).filter(+ if (!policy.subject) {+ return null;+ }++ const entries = policy.subject.filter((rule) =>(rule.allowed && rule.allowed.length > 0) ||(rule.required && rule.required.length > 0) ||(rule.denied && rule.denied.length > 0));- if (entries.length === 0) {- return null;- }-return (<Card className="w-full"><CardHeader className="border-b">@@ -37,22 +37,29 @@ export const PolicySubjectRulesSection = ({ policy }: Props) => {<CardDescription>Constraints on the certificate subject distinguished name</CardDescription></CardHeader><CardContent>- <DetailGroup>- {entries.map((rule, idx) => (- <div- // eslint-disable-next-line react/no-array-index-key- key={`${rule.type}-${idx}`}- className="flex flex-col gap-y-3 border-b border-mineshaft-700 pb-3 last:border-b-0 last:pb-0"- >- <div className="text-sm font-medium text-foreground">- {formatSubjectAttributeType(rule.type as CertSubjectAttributeType)}+ {entries.length === 0 ? (+ <p className="text-sm text-muted">+ No subject attributes are allowed. Certificates issued under this policy cannot include+ any subject attributes.+ </p>+ ) : (+ <DetailGroup>+ {entries.map((rule, idx) => (+ <div+ // eslint-disable-next-line react/no-array-index-key+ key={`${rule.type}-${idx}`}+ className="flex flex-col gap-y-3 border-b border-mineshaft-700 pb-3 last:border-b-0 last:pb-0"+ >+ <div className="text-sm font-medium text-foreground">+ {formatSubjectAttributeType(rule.type as CertSubjectAttributeType)}+ </div>+ <RuleList label="Allowed" values={rule.allowed} />+ <RuleList label="Required" values={rule.required} />+ <RuleList label="Denied" values={rule.denied} /></div>- <RuleList label="Allowed" values={rule.allowed} />- <RuleList label="Required" values={rule.required} />- <RuleList label="Denied" values={rule.denied} />- </div>- ))}- </DetailGroup>+ ))}+ </DetailGroup>+ )}</CardContent></Card>);diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/useCertificatePolicy.ts b/frontend/src/pages/cert-manager/CertificatesPage/components/useCertificatePolicy.tsindex 361514c755..7f6ce491cf 100644--- a/frontend/src/pages/cert-manager/CertificatesPage/components/useCertificatePolicy.ts+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/useCertificatePolicy.ts@@ -59,6 +59,8 @@ export type TemplateConstraints = {allowedExtendedKeyUsages: string[];requiredKeyUsages: string[];requiredExtendedKeyUsages: string[];+ restrictKeyUsages: boolean;+ restrictExtendedKeyUsages: boolean;allowedSignatureAlgorithms: string[];allowedKeyAlgorithms: string[];allowedSanTypes: CertSubjectAlternativeNameType[];@@ -82,6 +84,8 @@ export const useCertificatePolicy = (allowedExtendedKeyUsages: [],requiredKeyUsages: [],requiredExtendedKeyUsages: [],+ restrictKeyUsages: false,+ restrictExtendedKeyUsages: false,allowedSignatureAlgorithms: [],allowedKeyAlgorithms: [],allowedSanTypes: [@@ -99,16 +103,16 @@ export const useCertificatePolicy = (});const filteredKeyUsages = useMemo(() => {- if (constraints.allowedKeyUsages.length === 0) return [...KEY_USAGES_OPTIONS];+ if (!constraints.restrictKeyUsages) return [...KEY_USAGES_OPTIONS];return KEY_USAGES_OPTIONS.filter(({ value }) => constraints.allowedKeyUsages.includes(value));- }, [constraints.allowedKeyUsages]);+ }, [constraints.allowedKeyUsages, constraints.restrictKeyUsages]);const filteredExtendedKeyUsages = useMemo(() => {- if (constraints.allowedExtendedKeyUsages.length === 0) return [...EXTENDED_KEY_USAGES_OPTIONS];+ if (!constraints.restrictExtendedKeyUsages) return [...EXTENDED_KEY_USAGES_OPTIONS];return EXTENDED_KEY_USAGES_OPTIONS.filter(({ value }) =>constraints.allowedExtendedKeyUsages.includes(value));- }, [constraints.allowedExtendedKeyUsages]);+ }, [constraints.allowedExtendedKeyUsages, constraints.restrictExtendedKeyUsages]);const availableSignatureAlgorithms = useMemo(() => {if (constraints.allowedSignatureAlgorithms.length === 0) {@@ -142,6 +146,8 @@ export const useCertificatePolicy = (allowedExtendedKeyUsages: [],requiredKeyUsages: [],requiredExtendedKeyUsages: [],+ restrictKeyUsages: false,+ restrictExtendedKeyUsages: false,allowedSignatureAlgorithms: [],allowedKeyAlgorithms: [],allowedSanTypes: [@@ -187,6 +193,8 @@ export const useCertificatePolicy = (],requiredKeyUsages: templateData.keyUsages?.required || [],requiredExtendedKeyUsages: templateData.extendedKeyUsages?.required || [],+ restrictKeyUsages: Boolean(templateData.keyUsages),+ restrictExtendedKeyUsages: Boolean(templateData.extendedKeyUsages),allowedSanTypes: [],allowedSubjectAttributeTypes: [],shouldShowSanSection: true,diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/CreatePolicyModal.tsx b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/CreatePolicyModal.tsxindex b91ec3c9de..19e9a4e7e2 100644--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/CreatePolicyModal.tsx+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/CreatePolicyModal.tsx@@ -425,14 +425,8 @@ export const CreatePolicyModal = ({setRestrictSans(Boolean(source?.sans));setRestrictSignature(Boolean(source?.algorithms?.signature?.length));setRestrictKeyAlg(Boolean(source?.algorithms?.keyAlgorithm?.length));- setRestrictKeyUsages(- Boolean(source?.keyUsages?.required?.length || source?.keyUsages?.allowed?.length)- );- setRestrictExtendedKeyUsages(- Boolean(- source?.extendedKeyUsages?.required?.length || source?.extendedKeyUsages?.allowed?.length- )- );+ setRestrictKeyUsages(Boolean(source?.keyUsages));+ setRestrictExtendedKeyUsages(Boolean(source?.extendedKeyUsages));setRestrictValidity(Boolean(source?.validity?.max));setConfigureBasicConstraints(Boolean(source?.basicConstraints?.isCA));setErrors({});@@ -779,20 +773,11 @@ export const CreatePolicyModal = ({const stepErrors: Record<string, string> = {};if (step === 1) {- if (restrictSubject) {- if (!watchedAttributes.length) {- stepErrors.subject = "Add at least one subject attribute, or turn off the restriction.";- } else if (watchedAttributes.some((a) => !a.value?.[0]?.trim())) {- stepErrors.subject = "Every subject attribute needs a value (use * for any).";- }+ if (restrictSubject && watchedAttributes.some((a) => !a.value?.[0]?.trim())) {+ stepErrors.subject = "Every subject attribute needs a value (use * for any).";}- if (restrictSans) {- if (!watchedSans.length) {- stepErrors.sans =- "Add at least one subject alternative name, or turn off the restriction.";- } else if (watchedSans.some((s) => !s.value?.[0]?.trim())) {- stepErrors.sans = "Every subject alternative name needs a value (use * for any).";- }+ if (restrictSans && watchedSans.some((s) => !s.value?.[0]?.trim())) {+ stepErrors.sans = "Every subject alternative name needs a value (use * for any).";}}@@ -806,25 +791,6 @@ export const CreatePolicyModal = ({}}- if (step === 3) {- if (- restrictKeyUsages &&- watchedKeyUsages.requiredUsages.length === 0 &&- watchedKeyUsages.optionalUsages.length === 0- ) {- stepErrors.keyUsages =- "Set at least one key usage to Require or Allow, or turn off the restriction.";- }- if (- restrictExtendedKeyUsages &&- watchedExtendedKeyUsages.requiredUsages.length === 0 &&- watchedExtendedKeyUsages.optionalUsages.length === 0- ) {- stepErrors.extendedKeyUsages =- "Set at least one extended key usage to Require or Allow, or turn off the restriction.";- }- }-setErrors(stepErrors);return Object.keys(stepErrors).length === 0;};diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsx b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsxindex ebe432a018..d9945c2e51 100644--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsx+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsx@@ -564,17 +564,12 @@ export const CreateProfileModal = ({ isOpen, onClose, profile, mode = "create" }const templateAllowsCA =isCaPolicy === CertPolicyState.ALLOWED || isCaPolicy === CertPolicyState.REQUIRED;- const hasKeyUsagePolicy = Boolean(- templateData.keyUsages?.required?.length || templateData.keyUsages?.allowed?.length- );+ const hasKeyUsagePolicy = Boolean(templateData.keyUsages);const allowedKeyUsages = hasKeyUsagePolicy? [...(templateData.keyUsages?.required || []), ...(templateData.keyUsages?.allowed || [])]: KEY_USAGES_OPTIONS.map((option) => option.value);- const hasExtendedKeyUsagePolicy = Boolean(- templateData.extendedKeyUsages?.required?.length ||- templateData.extendedKeyUsages?.allowed?.length- );+ const hasExtendedKeyUsagePolicy = Boolean(templateData.extendedKeyUsages);const allowedExtendedKeyUsages = hasExtendedKeyUsagePolicy? [...(templateData.extendedKeyUsages?.required || []),@@ -600,15 +595,14 @@ export const CreateProfileModal = ({ isOpen, onClose, profile, mode = "create" }: certKeyAlgorithms.map((option) => ({ value: option.value as string, label: option.label }));let allowedSubjectAttributeTypes: CertSubjectAttributeType[];- if (templateData.subject && templateData.subject.length > 0) {+ if (templateData.subject) {const subjectTypes: CertSubjectAttributeType[] = [];templateData.subject.forEach((subjectPolicy: { type: string }) => {if (!subjectTypes.includes(subjectPolicy.type as CertSubjectAttributeType)) {subjectTypes.push(subjectPolicy.type as CertSubjectAttributeType);}});- allowedSubjectAttributeTypes =- subjectTypes.length > 0 ? subjectTypes : [CertSubjectAttributeType.COMMON_NAME];+ allowedSubjectAttributeTypes = subjectTypes;} else {allowedSubjectAttributeTypes = Object.values(CertSubjectAttributeType@@ -617,7 +611,7 @@ export const CreateProfileModal = ({ isOpen, onClose, profile, mode = "create" }const shouldShowSubjectSection = true;let allowedSanTypes: CertSubjectAlternativeNameType[];- if (templateData.sans && templateData.sans.length > 0) {+ if (templateData.sans) {const sanTypes: CertSubjectAlternativeNameType[] = [];templateData.sans.forEach((sanPolicy: { type: string }) => {if (!sanTypes.includes(sanPolicy.type as CertSubjectAlternativeNameType)) {