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 for PKI discovery
Carlos Monastyrskidb267ab7bb2a
diff --git a/backend/src/ee/routes/v1/pki-discovery-router.ts b/backend/src/ee/routes/v1/pki-discovery-router.tsindex 8193bbff89..3aed8c7536 100644--- a/backend/src/ee/routes/v1/pki-discovery-router.ts+++ b/backend/src/ee/routes/v1/pki-discovery-router.ts@@ -208,7 +208,8 @@ export const registerPkiDiscoveryRouter = async (server: FastifyZodProvider) =>}),response: {200: PkiDiscoveryConfigsSchema.extend({- linkedInstallationsCount: z.number().optional()+ linkedInstallationsCount: z.number().optional(),+ gatewayName: z.string().nullable().optional()})}},diff --git a/backend/src/ee/services/pki-discovery/pki-discovery-service.ts b/backend/src/ee/services/pki-discovery/pki-discovery-service.tsindex 1497567c9d..748b0ba632 100644--- a/backend/src/ee/services/pki-discovery/pki-discovery-service.ts+++ b/backend/src/ee/services/pki-discovery/pki-discovery-service.ts@@ -7,7 +7,7 @@ import {ProjectPermissionPkiDiscoveryActions,ProjectPermissionSub} from "@app/ee/services/permission/project-permission";-import { BadRequestError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";+import { BadRequestError, DatabaseError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";import { TProjectDALFactory } from "@app/services/project/project-dal";import { TGatewayV2DALFactory } from "../gateway-v2/gateway-v2-dal";@@ -154,7 +154,8 @@ export const pkiDiscoveryServiceFactory = ({return discovery;} catch (error) {- if (error && typeof error === "object" && "code" in error && (error as { code: string }).code === "23505") {+ const dbError = error instanceof DatabaseError ? (error.error as { code?: string }) : null;+ if (dbError?.code === "23505") {throw new BadRequestError({message: `A discovery configuration with name '${name}' already exists in this project`});@@ -237,7 +238,8 @@ export const pkiDiscoveryServiceFactory = ({return updatedDiscovery;} catch (error) {- if (error && typeof error === "object" && "code" in error && (error as { code: string }).code === "23505") {+ const dbError = error instanceof DatabaseError ? (error.error as { code?: string }) : null;+ if (dbError?.code === "23505") {throw new BadRequestError({message: `A discovery configuration with name '${name}' already exists in this project`});@@ -297,7 +299,15 @@ export const pkiDiscoveryServiceFactory = ({ProjectPermissionSub.PkiDiscovery);- return discovery;+ let gatewayName: string | null = null;+ if (discovery.gatewayId) {+ const gateway = await gatewayV2DAL.findOne({ id: discovery.gatewayId });+ if (gateway) {+ gatewayName = gateway.name;+ }+ }++ return { ...discovery, gatewayName };};const listDiscoveries = async ({diff --git a/docs/docs.json b/docs/docs.jsonindex ffa979f738..511f19b8f7 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -732,6 +732,13 @@"documentation/platform/pki/enrollment-methods/est"]},+ {+ "group": "Discovery",+ "pages": [+ "documentation/platform/pki/discovery/overview",+ "documentation/platform/pki/discovery/network"+ ]+ },{"group": "Alerting","pages": [@@ -741,14 +748,7 @@"documentation/platform/pki/alerting/pagerduty-alerts"]},- "documentation/platform/pki/approvals",- {- "group": "Discovery",- "pages": [- "documentation/platform/pki/discovery/overview",- "documentation/platform/pki/discovery/network"- ]- }+ "documentation/platform/pki/approvals"]},{diff --git a/docs/documentation/platform/pki/discovery/network.mdx b/docs/documentation/platform/pki/discovery/network.mdxindex 1632443a8b..44aba032d4 100644--- a/docs/documentation/platform/pki/discovery/network.mdx+++ b/docs/documentation/platform/pki/discovery/network.mdx@@ -72,11 +72,8 @@ Network discovery scans network endpoints over TLS to discover certificates serv## Limits-<Note>- The following limits apply to Network discovery jobs:- - **Max individual IPs**: 256- - **Max domains**: 20- - **Max ports**: 5- - **Minimum CIDR prefix**: `/24` (256 hosts)- - **Default TLS ports**: 443, 8443, 636, 993, 995-</Note>+The following limits apply to Network discovery jobs:+- **Max individual IPs**: 256+- **Max domains**: 20+- **Max ports**: 5+- **Minimum CIDR prefix**: `/24` (256 hosts)diff --git a/docs/documentation/platform/pki/discovery/overview.mdx b/docs/documentation/platform/pki/discovery/overview.mdxindex a3f254e408..b7257481f2 100644--- a/docs/documentation/platform/pki/discovery/overview.mdx+++ b/docs/documentation/platform/pki/discovery/overview.mdx@@ -3,7 +3,7 @@ sidebarTitle: "Overview"description: "Learn how to discover certificates across your infrastructure with Infisical"----Certificate Discovery enables automated scanning of your infrastructure to find certificates that may not be managed by Infisical. By configuring discovery jobs, you can continuously monitor for certificates deployed across your environment, giving you full visibility into your organization's certificate landscape.+Certificate Discovery enables automated scanning of your infrastructure to find certificates. By configuring discovery jobs, you can continuously monitor for certificates deployed across your environment, giving you full visibility into your organization's certificate landscape.## Conceptdiff --git a/docs/documentation/platform/pki/overview.mdx b/docs/documentation/platform/pki/overview.mdxindex ab0f56b9c0..af6a13530d 100644--- a/docs/documentation/platform/pki/overview.mdx+++ b/docs/documentation/platform/pki/overview.mdx@@ -16,4 +16,5 @@ Core capabilities include:- Certificate Inventory: Track and monitor issued X.509 certificates, maintaining a comprehensive inventory of all active and expired certificates.- Certificate Lifecycle Automation: Automate issuance, [renewal](/documentation/platform/pki/certificates/certificates#guide-to-renewing-certificates), and [revocation](/documentation/platform/pki/certificates/certificates#guide-to-revoking-certificates) with policy-based workflows, ensuring certificates remain valid, compliant, and up to date across your infrastructure.- [Certificate Syncs](/documentation/platform/pki/certificate-syncs/overview): Push certificates to cloud certificate managers like [AWS Certificate Manager](/documentation/platform/pki/certificate-syncs/aws-certificate-manager) and [Azure Key Vault](/documentation/platform/pki/certificate-syncs/azure-key-vault).+- [Certificate Discovery](/documentation/platform/pki/discovery/overview): Discover and map certificates deployed across your infrastructure, providing full visibility into your organization's certificate landscape.- [Certificate Alerts](/documentation/platform/pki/alerting/overview): Receive alerts and webhook events for certificate lifecycle changes such as certificate expiration.diff --git a/frontend/src/pages/cert-manager/CertificateDetailsByIDPage/components/CertificateInstallationsSection.tsx b/frontend/src/pages/cert-manager/CertificateDetailsByIDPage/components/CertificateInstallationsSection.tsxindex b5e5f7d2f6..ffcb87d3f1 100644--- a/frontend/src/pages/cert-manager/CertificateDetailsByIDPage/components/CertificateInstallationsSection.tsx+++ b/frontend/src/pages/cert-manager/CertificateDetailsByIDPage/components/CertificateInstallationsSection.tsx@@ -80,7 +80,7 @@ export const CertificateInstallationsSection = ({ certificateId }: Props) => {<UnstableTable><UnstableTableHeader><UnstableTableRow>- <UnstableTableHead>Endpoint</UnstableTableHead>+ <UnstableTableHead>Name</UnstableTableHead><UnstableTableHead>Gateway</UnstableTableHead><UnstableTableHead>Last Seen</UnstableTableHead></UnstableTableRow>@@ -100,7 +100,9 @@ export const CertificateInstallationsSection = ({ certificateId }: Props) => {})}>- <UnstableTableCell>{getEndpoint(installation)}</UnstableTableCell>+ <UnstableTableCell>+ {installation.name || getEndpoint(installation)}+ </UnstableTableCell><UnstableTableCell>{getGatewayLabel(installation) || "N/A"}</UnstableTableCell><UnstableTableCell>{format(new Date(installation.lastSeenAt), "MMM dd, yyyy HH:mm")}diff --git a/frontend/src/pages/cert-manager/CertificateDetailsByIDPage/components/CertificateOverviewSection.tsx b/frontend/src/pages/cert-manager/CertificateDetailsByIDPage/components/CertificateOverviewSection.tsxindex b46e834799..fe1bc3f565 100644--- a/frontend/src/pages/cert-manager/CertificateDetailsByIDPage/components/CertificateOverviewSection.tsx+++ b/frontend/src/pages/cert-manager/CertificateDetailsByIDPage/components/CertificateOverviewSection.tsx@@ -98,8 +98,12 @@ export const CertificateOverviewSection = ({ certificateId }: Props) => {<Detail><DetailLabel>Serial Number</DetailLabel><DetailValue className="flex items-center gap-2 font-mono text-xs">- {certificate.serialNumber}- <CopyButton value={certificate.serialNumber} size="xs" variant="plain" />+ {certificate.serialNumber.toUpperCase()}+ <CopyButton+ value={certificate.serialNumber.toUpperCase()}+ size="xs"+ variant="plain"+ /></DetailValue></Detail><Detail>diff --git a/frontend/src/pages/cert-manager/DiscoveryDetailsByIDPage/components/DiscoveryDetailsSection.tsx b/frontend/src/pages/cert-manager/DiscoveryDetailsByIDPage/components/DiscoveryDetailsSection.tsxindex 772244ebc9..7fb80d13e5 100644--- a/frontend/src/pages/cert-manager/DiscoveryDetailsByIDPage/components/DiscoveryDetailsSection.tsx+++ b/frontend/src/pages/cert-manager/DiscoveryDetailsByIDPage/components/DiscoveryDetailsSection.tsx@@ -58,6 +58,12 @@ export const DiscoveryDetailsSection = ({ discovery }: Props) => {</DetailValue></Detail>)}+ {discovery.gatewayName && (+ <Detail>+ <DetailLabel>Gateway</DetailLabel>+ <DetailValue>{discovery.gatewayName}</DetailValue>+ </Detail>+ )}<Detail><DetailLabel>Last Scanned</DetailLabel><DetailValue>diff --git a/frontend/src/pages/cert-manager/DiscoveryPage/components/DiscoveryJobModal.tsx b/frontend/src/pages/cert-manager/DiscoveryPage/components/DiscoveryJobModal.tsxindex 7107485384..b7585ccc7c 100644--- a/frontend/src/pages/cert-manager/DiscoveryPage/components/DiscoveryJobModal.tsx+++ b/frontend/src/pages/cert-manager/DiscoveryPage/components/DiscoveryJobModal.tsx@@ -112,14 +112,11 @@ const validateTargets = (targetsStr: string): { valid: boolean; error?: string }};}- let totalIpCount = singleIps.length;-const invalidCidr = cidrRanges.find((cidr) => {const prefixMatch = cidr.match(/\/(\d+)$/);if (prefixMatch) {const prefix = parseInt(prefixMatch[1], 10);- if (prefix < MIN_CIDR_PREFIX) return true;- totalIpCount += 2 ** (32 - prefix);+ return prefix < MIN_CIDR_PREFIX;}return false;});@@ -127,10 +124,18 @@ const validateTargets = (targetsStr: string): { valid: boolean; error?: string }if (invalidCidr) {return {valid: false,- error: `CIDR range too large. Maximum is /${MIN_CIDR_PREFIX} (256 IPs)`+ error: `CIDR range too large: ${invalidCidr}. Maximum is /${MIN_CIDR_PREFIX} (256 IPs)`};}+ const totalIpCount = cidrRanges.reduce((count, cidr) => {+ const prefixMatch = cidr.match(/\/(\d+)$/);+ if (prefixMatch) {+ return count + 2 ** (32 - parseInt(prefixMatch[1], 10));+ }+ return count;+ }, singleIps.length);+if (totalIpCount > MAX_IPS) {return {valid: false,@@ -156,14 +161,20 @@ const formSchema = z.object({targets: z.string().min(1, "At least one target is required")- .refine((val) => validateTargets(val).valid, {- message: "Invalid targets"+ .superRefine((val, ctx) => {+ const result = validateTargets(val);+ if (!result.valid) {+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: result.error });+ }}),ports: z.string().min(1, "Ports are required")- .refine((val) => validatePorts(val).valid, {- message: "Invalid ports"+ .superRefine((val, ctx) => {+ const result = validatePorts(val);+ if (!result.valid) {+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: result.error });+ }}),gatewayId: z.string().optional(),isAutoScanEnabled: z.boolean(),@@ -217,7 +228,7 @@ export const DiscoveryJobModal = ({ isOpen, onClose, projectId, discovery }: ProhandleSubmit,reset,watch,- formState: { errors, isSubmitting }+ formState: { isSubmitting }} = useForm<FormData>({resolver: zodResolver(formSchema),defaultValues: {@@ -328,8 +339,13 @@ export const DiscoveryJobModal = ({ isOpen, onClose, projectId, discovery }: Pro<Controllername="name"control={control}- render={({ field }) => (- <FormControl label="Name" isRequired errorText={errors.name?.message}>+ render={({ field, fieldState: { error } }) => (+ <FormControl+ label="Name"+ isRequired+ isError={Boolean(error)}+ errorText={error?.message}+ ><Input {...field} placeholder="my-discovery-job" /></FormControl>)}@@ -338,8 +354,8 @@ export const DiscoveryJobModal = ({ isOpen, onClose, projectId, discovery }: Pro<Controllername="description"control={control}- render={({ field }) => (- <FormControl label="Description" errorText={errors.description?.message}>+ render={({ field, fieldState: { error } }) => (+ <FormControl label="Description" isError={Boolean(error)} errorText={error?.message}><TextArea{...field}placeholder="Optional description for this discovery job"@@ -352,16 +368,13 @@ export const DiscoveryJobModal = ({ isOpen, onClose, projectId, discovery }: Pro<Controllername="targets"control={control}- render={({ field }) => (+ render={({ field, fieldState: { error } }) => (<FormControllabel="Targets"isRequired- tooltipText={`Domains or IP addresses to scan for TLS certificates. Up to ${MAX_DOMAINS} domains or ${MAX_IPS} IPs. Supports one CIDR range (max /${MIN_CIDR_PREFIX}). Cannot mix CIDR ranges with individual IPs.`}- errorText={- errors.targets?.message- ? validateTargets(field.value).error || errors.targets.message- : undefined- }+ isError={Boolean(error)}+ tooltipText={`Domains or IP addresses to scan for TLS certificates. Up to ${MAX_DOMAINS} domains or ${MAX_IPS} IPs. Supports individual IPs, CIDR ranges (max /${MIN_CIDR_PREFIX} each), or a mix of both.`}+ errorText={error?.message}><TextArea{...field}@@ -375,16 +388,13 @@ export const DiscoveryJobModal = ({ isOpen, onClose, projectId, discovery }: Pro<Controllername="ports"control={control}- render={({ field }) => (+ render={({ field, fieldState: { error } }) => (<FormControllabel="Ports"isRequired+ isError={Boolean(error)}tooltipText={`TCP ports to scan for TLS certificates. Specify up to ${MAX_PORTS} ports as comma-separated values (e.g. 443, 8443) or ranges (e.g. 8000-8010). Common TLS ports: 443 (HTTPS), 8443, 636 (LDAPS), 993 (IMAPS), 995 (POP3S), 465 (SMTPS).`}- errorText={- errors.ports?.message- ? validatePorts(field.value).error || errors.ports.message- : undefined- }+ errorText={error?.message}><Input {...field} placeholder={DEFAULT_TLS_PORTS} /></FormControl>diff --git a/frontend/src/pages/cert-manager/DiscoveryPage/components/DiscoveryJobsTab.tsx b/frontend/src/pages/cert-manager/DiscoveryPage/components/DiscoveryJobsTab.tsxindex 89d8de0776..924f6352d6 100644--- a/frontend/src/pages/cert-manager/DiscoveryPage/components/DiscoveryJobsTab.tsx+++ b/frontend/src/pages/cert-manager/DiscoveryPage/components/DiscoveryJobsTab.tsx@@ -156,8 +156,7 @@ export const DiscoveryJobsTab = ({ projectId }: Props) => {<div><h2 className="text-lg font-semibold">Discovery Jobs</h2><p className="text-sm text-mineshaft-400">- Configure and manage scheduled scans to discover certificates across your- infrastructure.+ Configure and manage scans to discover certificates across your infrastructure.</p></div><ProjectPermissionCan@@ -194,17 +193,15 @@ export const DiscoveryJobsTab = ({ projectId }: Props) => {<Th>Target</Th><Th>Ports</Th><Th>Status</Th>- <Th>Certs Found</Th>- <Th>Installations</Th><Th>Last Scan</Th><Th className="w-5" /></Tr></THead><TBody>- {isPending && <TableSkeleton columns={8} innerKey="discovery-jobs" />}+ {isPending && <TableSkeleton columns={6} innerKey="discovery-jobs" />}{!isPending && discoveries.length === 0 && (<Tr>- <Td colSpan={8}>+ <Td colSpan={6}><EmptyState title="No jobs found" /></Td></Tr>@@ -235,8 +232,6 @@ export const DiscoveryJobsTab = ({ projectId }: Props) => {Boolean(discovery.lastScanMessage))}</Td>- <Td>{discovery.certificatesFound}</Td>- <Td>{discovery.installationsFound}</Td><Td>{discovery.lastScannedAt? format(new Date(discovery.lastScannedAt), "MMM dd, yyyy HH:mm")diff --git a/frontend/src/pages/cert-manager/DiscoveryPage/components/InstallationsTab.tsx b/frontend/src/pages/cert-manager/DiscoveryPage/components/InstallationsTab.tsxindex 18062027d7..5fc68184dd 100644--- a/frontend/src/pages/cert-manager/DiscoveryPage/components/InstallationsTab.tsx+++ b/frontend/src/pages/cert-manager/DiscoveryPage/components/InstallationsTab.tsx@@ -105,6 +105,7 @@ export const InstallationsTab = ({ projectId }: Props) => {<THead><Tr><Th>Name</Th>+ <Th>Certificate</Th><Th>Gateway</Th><Th>Certs</Th><Th>Last Seen</Th>@@ -112,10 +113,10 @@ export const InstallationsTab = ({ projectId }: Props) => {</Tr></THead><TBody>- {isPending && <TableSkeleton columns={5} innerKey="installations" />}+ {isPending && <TableSkeleton columns={6} innerKey="installations" />}{!isPending && installations.length === 0 && (<Tr>- <Td colSpan={5}>+ <Td colSpan={6}><EmptyState title="No installations found" /></Td></Tr>@@ -137,6 +138,9 @@ export const InstallationsTab = ({ projectId }: Props) => {}><Td>{installation.name || getEndpoint(installation)}</Td>+ <Td>+ {installation.primaryCertName || <span className="text-mineshaft-400">-</span>}+ </Td><Td>{getGatewayLabel(installation) || "N/A"}</Td><Td>{installation.certificatesCount ?? installation.certificates?.length ?? 0}