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
misc: addressed feedback
Sheen Capadngan4a4ef310aa89
diff --git a/backend/src/services/alert/providers/cert-manager-alert-fns.ts b/backend/src/services/alert/providers/cert-manager-alert-fns.tsindex fc32c7abbd..2e7935c3e4 100644--- a/backend/src/services/alert/providers/cert-manager-alert-fns.ts+++ b/backend/src/services/alert/providers/cert-manager-alert-fns.ts@@ -44,16 +44,15 @@ const MAX_CERTIFICATE_ALERT_FILTER_IDS = 100;export const filterIdsSchema = (field: string, noun: string) =>z- .array(z.string().uuid())- .min(1, `${field} must list at least one ${noun}. Omit it to cover every ${noun}.`)- .max(MAX_CERTIFICATE_ALERT_FILTER_IDS)+ .array(z.string().toLowerCase().uuid())+ .min(1, `${field} must list at least one ${noun}. To cover them all, leave ${field} out.`)+ .max(MAX_CERTIFICATE_ALERT_FILTER_IDS, `${field} can list at most ${MAX_CERTIFICATE_ALERT_FILTER_IDS} ${noun}s`).superRefine((ids, ctx) => {const seen = new Set<string>();const duplicates = new Set<string>();ids.forEach((id) => {- const key = id.toLowerCase();- if (seen.has(key)) duplicates.add(id);- seen.add(key);+ if (seen.has(id)) duplicates.add(id);+ seen.add(id);});if (duplicates.size) {ctx.addIssue({diff --git a/backend/src/services/alert/providers/cert-manager-alert-provider.test.ts b/backend/src/services/alert/providers/cert-manager-alert-provider.test.tsindex d31c5d9f88..325104af41 100644--- a/backend/src/services/alert/providers/cert-manager-alert-provider.test.ts+++ b/backend/src/services/alert/providers/cert-manager-alert-provider.test.ts@@ -158,17 +158,23 @@ describe("cert manager alert provider", () => {});});- test("filters must be non-empty UUID lists and are stored as sent", () => {+ test("filters must be non-empty UUID lists and are stored lowercased", () => {const schema = expiryConditionSchema(buildProvider().provider);expect(schema.safeParse({ alertBefore: "30d", applicationIds: [APPLICATION_ID], profileIds: [PROFILE_ID] }).success).toBe(true);expect(schema.safeParse({ alertBefore: "30d", applicationIds: ["not-a-uuid"] }).success).toBe(false);- expect(schema.safeParse({ alertBefore: "30d", applicationIds: [] }).success).toBe(false);+ expect(schema.safeParse({ alertBefore: "30d", applicationIds: [] }).error?.issues[0].message).toBe(+ "applicationIds must list at least one application. To cover them all, leave applicationIds out."+ );+ expect(+ schema.safeParse({+ alertBefore: "30d",+ applicationIds: Array.from({ length: 101 }, (_, i) => `00000000-0000-4000-8000-${String(i).padStart(12, "0")}`)+ }).error?.issues[0].message+ ).toBe("applicationIds can list at most 100 applications");const upper = schema.safeParse({ alertBefore: "30d", applicationIds: [APPLICATION_ID.toUpperCase()] });- expect(upper.success && (upper.data as { applicationIds: string[] }).applicationIds).toEqual([- APPLICATION_ID.toUpperCase()- ]);+ expect(upper.success && (upper.data as { applicationIds: string[] }).applicationIds).toEqual([APPLICATION_ID]);});test("filters reject an ID listed twice, in any case, instead of storing the duplicate", () => {@@ -179,7 +185,7 @@ describe("cert manager alert provider", () => {});expect(duplicated.success).toBe(false);expect(duplicated.error?.issues[0].message).toBe(- `applicationIds lists the same ID more than once: '${APPLICATION_ID.toUpperCase()}'`+ `applicationIds lists the same ID more than once: '${APPLICATION_ID}'`);expect(schema.safeParse({ alertBefore: "30d", profileIds: [PROFILE_ID, PROFILE_ID] }).success).toBe(false);});@@ -208,7 +214,7 @@ describe("cert manager alert provider", () => {alerts: [{ id: "alert-1", condition: { applicationIds: [APPLICATION_ID.toUpperCase()] } }]});expect(names?.get("alert-1")).toEqual({- applications: [{ id: APPLICATION_ID.toUpperCase(), name: "payments-api" }],+ applications: [{ id: APPLICATION_ID, name: "payments-api" }],profiles: []});});diff --git a/backend/src/services/alert/providers/cert-manager-alert-provider.ts b/backend/src/services/alert/providers/cert-manager-alert-provider.tsindex 132ac0a869..3e9f8ee484 100644--- a/backend/src/services/alert/providers/cert-manager-alert-provider.ts+++ b/backend/src/services/alert/providers/cert-manager-alert-provider.ts@@ -63,7 +63,7 @@ const CertificateFilterSchema = z.object({profileIds: filterIdsSchema("profileIds", "profile"),sources: z.array(z.nativeEnum(CertificateSource))- .min(1, "sources must list at least one source. Omit it to cover every source.")+ .min(1, "sources must list at least one source. To cover them all, leave sources out.").refine((sources) => new Set(sources).size === sources.length, "sources lists the same source more than once").optional()});diff --git a/frontend/src/pages/cert-manager/components/CertificateAlerts/CertificateFilterSelects.tsx b/frontend/src/pages/cert-manager/components/CertificateAlerts/CertificateFilterSelects.tsxindex f7805e3692..f50d311aa8 100644--- a/frontend/src/pages/cert-manager/components/CertificateAlerts/CertificateFilterSelects.tsx+++ b/frontend/src/pages/cert-manager/components/CertificateAlerts/CertificateFilterSelects.tsx@@ -1,21 +1,26 @@-import { useMemo, useState } from "react";+import { ReactNode, useMemo, useState } from "react";-import { Combobox } from "@app/components/v3";+import { Badge, Combobox } from "@app/components/v3";+import { useProject } from "@app/context";import { useDebounce } from "@app/hooks";import { MAX_CERTIFICATE_ALERT_FILTER_IDS } from "@app/hooks/api/alerts";import { useListCertificateProfiles } from "@app/hooks/api/certificateProfiles";import { CertSource } from "@app/hooks/api/certificates/enums";import { useListPkiApplications } from "@app/hooks/api/pkiApplications";-import { useListSigners } from "@app/hooks/api/signers";+import {+ getSignerStatusBadgeVariant,+ SignerStatus,+ signerStatusLabels,+ useListSigners+} from "@app/hooks/api/signers";import { CertificateFilterKind, getFilterName } from "./types";-type TFilterOption = { id: string; name: string };+type TFilterOption = { id: string; name: string; status?: SignerStatus };type Props = {value: string[];conditionNames: Record<string, string>;- projectId: string;onChange: (selected: TFilterOption[]) => void;};@@ -27,16 +32,18 @@ const FilterCombobox = ({options,isLoading,onSearchChange,- placeholder-}: Omit<Props, "projectId"> & {+ placeholder,+ renderOption+}: Props & {kind: CertificateFilterKind;options: TFilterOption[];isLoading: boolean;onSearchChange?: (search: string) => void;placeholder: string;+ renderOption?: (option: TFilterOption) => ReactNode;}) => {- const optionNames = useMemo(- () => new Map(options.map((option) => [option.id, option.name])),+ const optionsById = useMemo(+ () => new Map(options.map((option) => [option.id, option])),[options]);@@ -45,14 +52,14 @@ const FilterCombobox = ({multipleisClearableoptions={options}- value={value.map((id) => ({- id,- name: optionNames.get(id) ?? getFilterName(kind, id, conditionNames)- }))}+ value={value.map(+ (id) => optionsById.get(id) ?? { id, name: getFilterName(kind, id, conditionNames) }+ )}onValueChange={(selected) => onChange([...selected])}getOptionValue={(option) => option.id}getOptionLabel={(option) => option.name}onSearchChange={onSearchChange}+ renderOption={renderOption}isLoading={isLoading}placeholder={placeholder}/>@@ -107,7 +114,8 @@ export const ProfileFilterSelect = (props: Props) => {);};-export const SignerFilterSelect = ({ projectId, ...props }: Props) => {+export const SignerFilterSelect = (props: Props) => {+ const { projectId } = useProject();const [search, setSearch] = useState("");const [debouncedSearch] = useDebounce(search);const { data, isPending } = useListSigners({@@ -116,7 +124,7 @@ export const SignerFilterSelect = ({ projectId, ...props }: Props) => {...(debouncedSearch ? { search: debouncedSearch } : {})});const options = useMemo(- () => (data?.signers ?? []).map(({ id, name }) => ({ id, name })),+ () => (data?.signers ?? []).map(({ id, name, status }) => ({ id, name, status })),[data]);@@ -128,6 +136,16 @@ export const SignerFilterSelect = ({ projectId, ...props }: Props) => {isLoading={isPending}onSearchChange={setSearch}placeholder="Select signers"+ renderOption={({ name, status }) => (+ <span className="flex min-w-0 items-center gap-2">+ <span className="truncate">{name}</span>+ {status && status !== SignerStatus.Active && (+ <Badge variant={getSignerStatusBadgeVariant(status)}>+ {signerStatusLabels[status] ?? status}+ </Badge>+ )}+ </span>+ )}/>);};diff --git a/frontend/src/pages/cert-manager/components/CertificateAlerts/FiltersStep.tsx b/frontend/src/pages/cert-manager/components/CertificateAlerts/FiltersStep.tsxindex d1f0e59776..d1e93eb006 100644--- a/frontend/src/pages/cert-manager/components/CertificateAlerts/FiltersStep.tsx+++ b/frontend/src/pages/cert-manager/components/CertificateAlerts/FiltersStep.tsx@@ -30,6 +30,7 @@ import {} from "./CertificateFilterSelects";import {CERTIFICATE_FILTER_DEFINITIONS,+ CERTIFICATE_FILTER_KINDS,CertificateFilterKind,getFilterKinds,getNoFiltersDescription,@@ -39,12 +40,6 @@ import {const MATCHED_PAGE_SIZE = 20;-const CERTIFICATE_FILTER_KINDS = [- CertificateFilterKind.Applications,- CertificateFilterKind.Profiles,- CertificateFilterKind.Sources-] as const;-const FILTER_SELECTS = {[CertificateFilterKind.Applications]: ApplicationFilterSelect,[CertificateFilterKind.Profiles]: ProfileFilterSelect,@@ -207,7 +202,7 @@ export const FiltersStep = ({ form, projectId }: Props) => {<p className="text-sm font-medium text-foreground">Filters</p><p className="mt-0.5 text-xs text-muted">{isSignerEvent- ? "Only the certificates of the signers selected below are covered."+ ? "The alert covers only the signers selected below.": "A certificate is covered only when it matches every filter below."}</p></div>@@ -233,7 +228,6 @@ export const FiltersStep = ({ form, projectId }: Props) => {<Selectvalue={filters[kind] ?? []}conditionNames={conditionNames}- projectId={projectId}onChange={(selected) => {if (kind !== CertificateFilterKind.Sources) {form.setValue("conditionNames", {diff --git a/frontend/src/pages/cert-manager/components/CertificateAlerts/types.ts b/frontend/src/pages/cert-manager/components/CertificateAlerts/types.tsindex db5612bb5c..7e8fef25fe 100644--- a/frontend/src/pages/cert-manager/components/CertificateAlerts/types.ts+++ b/frontend/src/pages/cert-manager/components/CertificateAlerts/types.ts@@ -189,14 +189,14 @@ export enum CertificateFilterKind {Signers = "signerIds"}-export const getFilterKinds = (eventType: TCertificateAlertEventType) =>- isSignerEventType(eventType)- ? [CertificateFilterKind.Signers]- : [- CertificateFilterKind.Applications,- CertificateFilterKind.Profiles,- CertificateFilterKind.Sources- ];+export const CERTIFICATE_FILTER_KINDS = [+ CertificateFilterKind.Applications,+ CertificateFilterKind.Profiles,+ CertificateFilterKind.Sources+] as const;++export const getFilterKinds = (eventType: TCertificateAlertEventType): CertificateFilterKind[] =>+ isSignerEventType(eventType) ? [CertificateFilterKind.Signers] : [...CERTIFICATE_FILTER_KINDS];export const CERTIFICATE_FILTER_DEFINITIONS: Record<CertificateFilterKind,