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
feat(pam): postgres account discovery
Andrey327bd523240b
diff --git a/backend/src/ee/services/pam-discovery/pam-discovery-enums.ts b/backend/src/ee/services/pam-discovery/pam-discovery-enums.tsindex cec493e4c6..686053516d 100644--- a/backend/src/ee/services/pam-discovery/pam-discovery-enums.ts+++ b/backend/src/ee/services/pam-discovery/pam-discovery-enums.ts@@ -1,6 +1,7 @@export enum PamDiscoveryType {ActiveDirectory = "active-directory",- Unix = "unix"+ Unix = "unix",+ Postgres = "postgres"}export enum PamDiscoverySchedule {diff --git a/backend/src/ee/services/pam-discovery/pam-discovery-factory.ts b/backend/src/ee/services/pam-discovery/pam-discovery-factory.tsindex 44d2fcac65..c667ada957 100644--- a/backend/src/ee/services/pam-discovery/pam-discovery-factory.ts+++ b/backend/src/ee/services/pam-discovery/pam-discovery-factory.ts@@ -1,9 +1,11 @@import { activeDirectoryDiscoveryFactory } from "./active-directory/active-directory-discovery-factory";import { PamDiscoveryType } from "./pam-discovery-enums";import { TPamDiscoveryFactory } from "./pam-discovery-types";+import { postgresDiscoveryFactory } from "./postgres/postgres-discovery-factory";import { unixDiscoveryFactory } from "./unix/unix-discovery-factory";export const PAM_DISCOVERY_FACTORY_MAP: Record<PamDiscoveryType, TPamDiscoveryFactory> = {[PamDiscoveryType.ActiveDirectory]: activeDirectoryDiscoveryFactory,- [PamDiscoveryType.Unix]: unixDiscoveryFactory+ [PamDiscoveryType.Unix]: unixDiscoveryFactory,+ [PamDiscoveryType.Postgres]: postgresDiscoveryFactory};diff --git a/backend/src/ee/services/pam-discovery/pam-discovery-schemas.ts b/backend/src/ee/services/pam-discovery/pam-discovery-schemas.tsindex 019df9487e..3d808ac769 100644--- a/backend/src/ee/services/pam-discovery/pam-discovery-schemas.ts+++ b/backend/src/ee/services/pam-discovery/pam-discovery-schemas.ts@@ -3,6 +3,7 @@ import { z } from "zod";import { PamAccountType } from "../pam/pam-enums";import { ActiveDirectoryDiscoveryConfigSchema } from "./active-directory/active-directory-discovery-schemas";import { PamDiscoveryType } from "./pam-discovery-enums";+import { PostgresDiscoveryConfigSchema } from "./postgres/postgres-discovery-schemas";import { UnixDiscoveryConfigSchema } from "./unix/unix-discovery-schemas";export const DISCOVERY_TYPE_CONFIGS = {@@ -17,6 +18,12 @@ export const DISCOVERY_TYPE_CONFIGS = {icon: "SSH.png",credentialAccountType: PamAccountType.SSH,configuration: UnixDiscoveryConfigSchema+ },+ [PamDiscoveryType.Postgres]: {+ name: "PostgreSQL",+ icon: "Postgres.png",+ credentialAccountType: PamAccountType.Postgres,+ configuration: PostgresDiscoveryConfigSchema}} as const satisfies Partial<Record<diff --git a/backend/src/ee/services/pam-discovery/pam-discovery-source-service.ts b/backend/src/ee/services/pam-discovery/pam-discovery-source-service.tsindex fb53ef5c69..2997a21612 100644--- a/backend/src/ee/services/pam-discovery/pam-discovery-source-service.ts+++ b/backend/src/ee/services/pam-discovery/pam-discovery-source-service.ts@@ -471,9 +471,9 @@ export const pamDiscoverySourceServiceFactory = (deps: TPamDiscoverySourceServicconst goneAccounts = storedAccounts.filter((a) => {if (seenFingerprints.has(a.fingerprint)) return false;if (a.accountType === PamAccountType.WindowsAd) return true;- if (a.accountType === PamAccountType.Windows) {- // local-account fingerprint is `${domain}:${computerObjectGUID}:${username}`; the machine key is the- // first two segments, matching what the provider reports as re-checked+ if (a.accountType === PamAccountType.Windows || a.accountType === PamAccountType.Postgres) {+ // fingerprints are `${domain}:${computerObjectGUID}:${username}` and `${host}:${port}:${rolname}`; in+ // both the machine key is the first two segments, matching what the provider reports as re-checkedconst machineKey = a.fingerprint.split(":").slice(0, 2).join(":");return scannedMachines.has(machineKey);}diff --git a/backend/src/ee/services/pam-discovery/unix/unix-discovery-fns.ts b/backend/src/ee/services/pam-discovery/pam-discovery-targets.tssimilarity index 51%rename from backend/src/ee/services/pam-discovery/unix/unix-discovery-fns.tsrename to backend/src/ee/services/pam-discovery/pam-discovery-targets.tsindex 95f938b17a..8296e5f1b7 100644--- a/backend/src/ee/services/pam-discovery/unix/unix-discovery-fns.ts+++ b/backend/src/ee/services/pam-discovery/pam-discovery-targets.ts@@ -1,11 +1,26 @@import net from "node:net";import { Netmask } from "netmask";+import RE2 from "re2";+import { z } from "zod";import { BadRequestError } from "@app/lib/errors";+import { isValidIpOrCidr } from "@app/lib/ip";export const MAX_TARGET_HOSTS = 65536;+const HOSTNAME_REGEX = new RE2(+ /^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/+);++const isValidIpv4Target = (value: string) => {+ const base = value.includes("/") ? value.split("/")[0] : value;+ return net.isIPv4(base) && isValidIpOrCidr(value);+};++const isValidTarget = (value: string) =>+ isValidIpv4Target(value) || (value.length <= 253 && HOSTNAME_REGEX.test(value));+// expands cidr ranges / bare ips / hostnames into the deduped set of target hosts. Enforces IPv4-only CIDRs and the host capexport const expandTargets = (cidrRanges: string[]): string[] => {const hosts = new Set<string>();@@ -31,3 +46,22 @@ export const expandTargets = (cidrRanges: string[]): string[] => {}return [...hosts];};++// shared by every host-range discovery source: validates each entry, then that the set expands within the cap+export const DiscoveryTargetsSchema = z+ .array(z.string().trim().min(1))+ .min(1)+ .max(50)+ .refine((ranges) => ranges.every(isValidTarget), {+ message: "Each target must be a valid IPv4 address, IPv4 CIDR range, or hostname"+ })+ .superRefine((ranges, ctx) => {+ try {+ expandTargets(ranges);+ } catch (err) {+ ctx.addIssue({+ code: z.ZodIssueCode.custom,+ message: err instanceof Error ? err.message : "Invalid targets"+ });+ }+ });diff --git a/backend/src/ee/services/pam-discovery/postgres/postgres-discovery-factory.ts b/backend/src/ee/services/pam-discovery/postgres/postgres-discovery-factory.tsnew file mode 100644index 0000000000..b0e5420cb0--- /dev/null+++ b/backend/src/ee/services/pam-discovery/postgres/postgres-discovery-factory.ts@@ -0,0 +1,224 @@+import slugify from "@sindresorhus/slugify";+import knex from "knex";+import pLimit from "p-limit";+import RE2 from "re2";++import { BadRequestError } from "@app/lib/errors";+import { logger } from "@app/lib/logger";++import { PamAccountType, PamPostgresAuthMethod } from "../../pam/pam-enums";+import { executeWithGateway, sweepReachableTargets } from "../pam-discovery-fns";+import { expandTargets } from "../pam-discovery-targets";+import {+ TDiscoveredAccount,+ TDiscoveryCredentialAccount,+ TDiscoveryMachineError,+ TDiscoveryScanResult,+ TPamDiscoveryFactory+} from "../pam-discovery-types";++const QUERY_TIMEOUT_MS = 20 * 1000;+const SCAN_CONCURRENCY = 32;+const SWEEP_DIAL_TIMEOUT_MS = 3 * 1000;+const MAX_SWEEP_TARGETS = 65536;+const MAX_ACCOUNTS_PER_HOST = 2000;+const MAX_ACCOUNTS_PER_SCAN = 50000;++const ENUMERATION_QUERY = `SELECT rolname FROM pg_roles WHERE rolcanlogin ORDER BY rolname LIMIT ${MAX_ACCOUNTS_PER_HOST}`;++const TRAILING_HYPHENS_REGEX = new RE2(/-+$/);++type TPostgresAccount = {+ host: string;+ port: number;+ database: string;+ sslEnabled: boolean;+ sslRejectUnauthorized: boolean;+ sslCertificate?: string;+ username: string;+ password?: string;+};++const toPostgresAccount = (account: TDiscoveryCredentialAccount): TPostgresAccount => {+ const connectionDetails = account.connectionDetails as {+ host: string;+ port: number;+ database: string;+ sslEnabled?: boolean;+ sslRejectUnauthorized?: boolean;+ sslCertificate?: string;+ };+ const credentials = account.credentials as { authMethod?: string; username: string; password?: string };+ return {+ host: connectionDetails.host,+ port: connectionDetails.port,+ database: connectionDetails.database,+ sslEnabled: Boolean(connectionDetails.sslEnabled),+ sslRejectUnauthorized: connectionDetails.sslRejectUnauthorized !== false,+ sslCertificate: connectionDetails.sslCertificate,+ username: credentials.username,+ password: credentials.authMethod === PamPostgresAuthMethod.AwsIam ? undefined : credentials.password+ };+};++// an IAM token is minted per host/port/user pair, which a sweep across arbitrary targets cannot do, so only password accounts can drive a scan+const isUsableAccount = (account: TPostgresAccount) => Boolean(account.password);++export const postgresDiscoveryFactory: TPamDiscoveryFactory = ({+ gatewayId,+ configuration,+ credentialAccounts,+ gatewayV2Service+}) => {+ const accounts = credentialAccounts.map(toPostgresAccount);+ const config = configuration as { cidrRanges: string[] };++ const orderAccountsForHost = (host: string) => [+ ...accounts.filter((a) => a.host === host),+ ...accounts.filter((a) => a.host !== host)+ ];++ const enumerateHost = (host: string, account: TPostgresAccount) =>+ executeWithGateway(host, account.port, gatewayId, gatewayV2Service, async (proxyPort) => {+ const db = knex({+ client: "pg",+ connection: {+ host: "localhost",+ port: proxyPort,+ database: account.database,+ user: account.username,+ password: account.password,+ connectionTimeoutMillis: QUERY_TIMEOUT_MS,+ ssl: account.sslEnabled+ ? {+ rejectUnauthorized: account.sslRejectUnauthorized,+ servername: host,+ ...(account.sslCertificate ? { ca: account.sslCertificate } : {})+ }+ : false+ },+ acquireConnectionTimeout: QUERY_TIMEOUT_MS,+ pool: { min: 0, max: 1 }+ });++ try {+ const result = await db.raw<{ rows: { rolname: string }[] }>(ENUMERATION_QUERY);+ return result.rows.map((row) => row.rolname);+ } finally {+ await db.destroy();+ }+ });++ const scanHost = async (+ host: string,+ open: Set<string>,+ signal: AbortSignal+ ): Promise<{ accounts: TDiscoveredAccount[]; error?: TDiscoveryMachineError; scannedMachine?: string }> => {+ if (signal.aborted) return { accounts: [] };+ const isKnownHost = accounts.some((a) => a.host === host);+ const candidates = orderAccountsForHost(host).filter(+ (account) => isUsableAccount(account) && (isKnownHost || open.has(`${host}:${account.port}`))+ );++ let lastError = "no credential account could authenticate";+ for (const account of candidates) {+ try {+ // eslint-disable-next-line no-await-in-loop+ const rolnames = await enumerateHost(host, account);+ return {+ scannedMachine: `${host}:${account.port}`,+ accounts: rolnames.map((rolname) => ({+ accountType: PamAccountType.Postgres,+ name: slugify(`${host} ${rolname}`, { lowercase: true }).slice(0, 64).replace(TRAILING_HYPHENS_REGEX, ""),+ fingerprint: `${host}:${account.port}:${rolname}`,+ details: {+ connectionDetails: {+ host,+ port: account.port,+ database: account.database,+ sslEnabled: account.sslEnabled,+ sslRejectUnauthorized: account.sslRejectUnauthorized,+ ...(account.sslCertificate ? { sslCertificate: account.sslCertificate } : {})+ },+ credentials: { authMethod: PamPostgresAuthMethod.Password, username: rolname }+ }+ }))+ };+ } catch (err) {+ lastError = err instanceof Error ? err.message : "PostgreSQL enumeration failed";+ }+ }++ if (candidates.length) {+ logger.warn(`PAM PostgreSQL discovery failed to scan host [host=${host}] [error=${lastError}]`);+ return { accounts: [], error: { machine: host, error: lastError } };+ }+ return { accounts: [] };+ };++ const validateConnection = async () => {+ const account = accounts.find(isUsableAccount);+ if (!account) {+ throw new BadRequestError({+ message:+ "No credential account has a password. PostgreSQL discovery requires password authentication; AWS IAM accounts cannot be used to scan."+ });+ }+ await enumerateHost(account.host, account).catch((err) => {+ throw new BadRequestError({+ message: `Unable to connect to PostgreSQL: ${err instanceof Error ? err.message : "unknown error"}`+ });+ });+ };++ const scan = async (signal: AbortSignal): Promise<TDiscoveryScanResult> => {+ if (!accounts.some(isUsableAccount)) {+ throw new BadRequestError({+ message:+ "No credential account has a password. PostgreSQL discovery requires password authentication; AWS IAM accounts cannot be used to scan."+ });+ }++ const targets = expandTargets(config.cidrRanges);+ const usablePorts = [...new Set(accounts.filter(isUsableAccount).map((a) => a.port))];++ const sweepTargets = targets.flatMap((host) => usablePorts.map((port) => ({ host, port })));+ if (sweepTargets.length > MAX_SWEEP_TARGETS) {+ throw new BadRequestError({+ message: `Scan expands to ${sweepTargets.length} host-port combinations, exceeding the limit of ${MAX_SWEEP_TARGETS}. Reduce the target ranges or the number of distinct credential ports.`+ });+ }+ const open = await sweepReachableTargets(sweepTargets, gatewayId, gatewayV2Service, SWEEP_DIAL_TIMEOUT_MS, signal);++ const hostsToScan = targets.filter(+ (host) => accounts.some((a) => a.host === host) || usablePorts.some((port) => open.has(`${host}:${port}`))+ );++ if (!hostsToScan.length) {+ throw new BadRequestError({+ message:+ "No hosts were reachable on the credential ports in the target range. Check the targets, that the gateway can reach them, and that PostgreSQL is listening."+ });+ }++ const limit = pLimit(SCAN_CONCURRENCY);+ const results = await Promise.all(hostsToScan.map((host) => limit(() => scanHost(host, open, signal))));++ const discovered = results.flatMap((r) => r.accounts);+ if (discovered.length > MAX_ACCOUNTS_PER_SCAN) {+ logger.warn(+ `PAM PostgreSQL discovery truncating discovered accounts to the per-scan limit [found=${discovered.length}] [limit=${MAX_ACCOUNTS_PER_SCAN}]`+ );+ }++ return {+ accounts: discovered.slice(0, MAX_ACCOUNTS_PER_SCAN),+ machineErrors: results.flatMap((r) => (r.error ? [r.error] : [])),+ dependencies: [],+ scannedDependencyMachines: [],+ scannedAccountMachines: results.flatMap((r) => (r.scannedMachine ? [r.scannedMachine] : []))+ };+ };++ return { validateConnection, scan };+};diff --git a/backend/src/ee/services/pam-discovery/postgres/postgres-discovery-schemas.ts b/backend/src/ee/services/pam-discovery/postgres/postgres-discovery-schemas.tsnew file mode 100644index 0000000000..38e3bc8fbf--- /dev/null+++ b/backend/src/ee/services/pam-discovery/postgres/postgres-discovery-schemas.ts@@ -0,0 +1,8 @@+import { z } from "zod";++import { DiscoveryTargetsSchema } from "../pam-discovery-targets";++export const PostgresDiscoveryConfigSchema = z.object({+ cidrRanges: DiscoveryTargetsSchema,+ credentialAccountIds: z.array(z.string().uuid()).min(1).max(50)+});diff --git a/backend/src/ee/services/pam-discovery/unix/unix-discovery-factory.ts b/backend/src/ee/services/pam-discovery/unix/unix-discovery-factory.tsindex 83705b5b81..68560c511e 100644--- a/backend/src/ee/services/pam-discovery/unix/unix-discovery-factory.ts+++ b/backend/src/ee/services/pam-discovery/unix/unix-discovery-factory.ts@@ -8,6 +8,7 @@ import { logger } from "@app/lib/logger";import { PamAccountType, PamSshAuthMethod } from "../../pam/pam-enums";import { sshExecWithGateway, sweepReachableTargets } from "../pam-discovery-fns";+import { expandTargets } from "../pam-discovery-targets";import {TDiscoveredAccount,TDiscoveryCredentialAccount,@@ -15,7 +16,6 @@ import {TDiscoveryScanResult,TPamDiscoveryFactory} from "../pam-discovery-types";-import { expandTargets } from "./unix-discovery-fns";const SSH_EXEC_TIMEOUT_MS = 20 * 1000;const SCAN_CONCURRENCY = 64;diff --git a/backend/src/ee/services/pam-discovery/unix/unix-discovery-schemas.ts b/backend/src/ee/services/pam-discovery/unix/unix-discovery-schemas.tsindex 105011bf75..930f5c97d6 100644--- a/backend/src/ee/services/pam-discovery/unix/unix-discovery-schemas.ts+++ b/backend/src/ee/services/pam-discovery/unix/unix-discovery-schemas.ts@@ -1,44 +1,8 @@-import net from "node:net";--import RE2 from "re2";import { z } from "zod";-import { isValidIpOrCidr } from "@app/lib/ip";--import { expandTargets } from "./unix-discovery-fns";--const HOSTNAME_REGEX = new RE2(- /^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/-);--// only IPv4 addresses and IPv4 CIDR ranges are supported-const isValidIpv4Target = (value: string) => {- const base = value.includes("/") ? value.split("/")[0] : value;- return net.isIPv4(base) && isValidIpOrCidr(value);-};--const isValidTarget = (value: string) =>- isValidIpv4Target(value) || (value.length <= 253 && HOSTNAME_REGEX.test(value));+import { DiscoveryTargetsSchema } from "../pam-discovery-targets";-export const UnixDiscoveryConfigSchema = z- .object({- cidrRanges: z- .array(z.string().trim().min(1))- .min(1)- .max(50)- .refine((ranges) => ranges.every(isValidTarget), {- message: "Each target must be a valid IPv4 address, IPv4 CIDR range, or hostname"- }),- credentialAccountIds: z.array(z.string().uuid()).min(1).max(50)- })- .superRefine((config, ctx) => {- try {- expandTargets(config.cidrRanges);- } catch (err) {- ctx.addIssue({- code: z.ZodIssueCode.custom,- path: ["cidrRanges"],- message: err instanceof Error ? err.message : "Invalid targets"- });- }- });+export const UnixDiscoveryConfigSchema = z.object({+ cidrRanges: DiscoveryTargetsSchema,+ credentialAccountIds: z.array(z.string().uuid()).min(1).max(50)+});diff --git a/docs/docs.json b/docs/docs.jsonindex afbda7a845..22f750980a 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -1179,7 +1179,8 @@"pages": ["documentation/platform/pam/discovery/overview","documentation/platform/pam/discovery/active-directory",- "documentation/platform/pam/discovery/unix"+ "documentation/platform/pam/discovery/unix",+ "documentation/platform/pam/discovery/postgres"]},{diff --git a/docs/documentation/platform/pam/discovery/overview.mdx b/docs/documentation/platform/pam/discovery/overview.mdxindex 37aa25a27c..d86ce72c1d 100644--- a/docs/documentation/platform/pam/discovery/overview.mdx+++ b/docs/documentation/platform/pam/discovery/overview.mdx@@ -36,6 +36,9 @@ Discovery is available to **Product Admins**. See [Access Control](/documentatio<Card title="Linux/Unix" icon="terminal" href="/documentation/platform/pam/discovery/unix">Scan Linux and Unix hosts over SSH for local accounts.</Card>+ <Card title="PostgreSQL" icon="database" href="/documentation/platform/pam/discovery/postgres">+ Scan PostgreSQL instances for login roles.+ </Card></CardGroup><Note>@@ -94,6 +97,9 @@ Scheduled scans are evaluated once a day, so a source runs on its next scheduled<Card title="Linux/Unix" icon="terminal" href="/documentation/platform/pam/discovery/unix">Configure a Linux/Unix discovery source.</Card>+ <Card title="PostgreSQL" icon="database" href="/documentation/platform/pam/discovery/postgres">+ Configure a PostgreSQL discovery source.+ </Card><Card title="Accounts" icon="user-lock" href="/documentation/platform/pam/accounts/overview">Manage the accounts you import.</Card>diff --git a/docs/documentation/platform/pam/discovery/postgres.mdx b/docs/documentation/platform/pam/discovery/postgres.mdxnew file mode 100644index 0000000000..df4c1650ba--- /dev/null+++ b/docs/documentation/platform/pam/discovery/postgres.mdx@@ -0,0 +1,95 @@+---+title: "PostgreSQL discovery"+sidebarTitle: "PostgreSQL"+description: "Scan PostgreSQL instances for login roles and import them into PAM."+---++PostgreSQL discovery scans a set of PostgreSQL instances, enumerates the roles that can log in, stages them for review, and lets you import them into PAM as [PostgreSQL accounts](/documentation/platform/pam/accounts/postgresql). You point a source at the instances to scan and the [PostgreSQL accounts](/documentation/platform/pam/accounts/postgresql) to scan with.++All scan traffic is tunneled through an Infisical [Gateway](/documentation/platform/gateways/overview).++## How it works++A PostgreSQL scan connects entirely through the Gateway:++1. Each **CIDR range** is expanded into a list of target hosts; individual IPs and hostnames are used as-is (hostnames are resolved by the gateway in the target network).+2. Each host is probed on the ports of your credential accounts, so unreachable hosts are skipped before any login is attempted.+3. For each reachable host, discovery picks a credential account: it first tries an account whose stored host matches the target, otherwise it tries each account in turn until one connects.+4. It reads the cluster's roles from `pg_roles`.+5. Each role that can log in is staged as a **PostgreSQL** account scoped to that instance. `postgres` on two instances becomes two separate staged accounts.++Hosts that no credential can reach or authenticate to are reported on the run and skipped; the rest of the scan still completes.++## Prerequisites++Before creating a PostgreSQL discovery source, make sure you have:++- A [Gateway](/documentation/platform/gateways/overview) (or Gateway pool) with network access to the instances you want to scan.+- One or more [PostgreSQL accounts](/documentation/platform/pam/accounts/postgresql) in PAM to use as **credential accounts**. Discovery connects to each instance as one of these accounts, using its port, database, and TLS settings.+- The **Product Admin** role. See [Access Control](/documentation/platform/pam/concepts/access-control).++<Note>+The scanning account needs no special grant. `pg_roles` is readable by any role, so a low-privilege login is enough to enumerate an instance.+</Note>++<Warning>+Only password authentication can drive a scan. An AWS IAM account's token is minted for one host, port, and user, which a scan across a range of hosts cannot do, so IAM accounts are skipped as credential accounts.+</Warning>++## Creating a source++<Steps>+ <Step title="Start adding a source">+ Go to **Privileged Access Manager → Discovery** and click **Add Source**, then choose **PostgreSQL**.+ </Step>+ <Step title="Configure the source">+ | Field | Description |+ |-------|-------------|+ | **Name** | A descriptive name (e.g., `prod-databases`) |+ | **Credential Accounts** | One or more [PostgreSQL accounts](/documentation/platform/pam/accounts/postgresql) used to connect and scan |+ | **Gateway** | The [Gateway](/documentation/platform/gateways/overview) or Gateway pool that scan traffic tunnels through |+ | **Scan Schedule** | How often to scan automatically: **Manual**, **Daily**, or **Weekly** |+ | **Targets** | IP addresses, IPv4 CIDR ranges, or hostnames to scan, one per line or comma-separated. Hostnames are resolved by the gateway in the target network |+ </Step>+ <Step title="Save">+ Click **Add Source**. The source appears in the Discovery table.+ </Step>+</Steps>++## Account filtering++Discovery surfaces only roles that can be logged into, meaning those with the `LOGIN` attribute. Group roles used purely to hold privileges cannot open a session, so they are not accounts and are dropped. This also excludes the built-in `pg_` roles, none of which can log in.++Roles are cluster-wide rather than per-database, so the database your credential account connects to does not change which roles are found.++## Running a scan++Trigger a scan manually with **Scan Now** from the source's row menu or its detail panel. Scans run in the background, and a source can only have one scan running at a time.++If the source is on a **Daily** or **Weekly** schedule, Infisical also scans it automatically when its interval has elapsed. **Manual** sources are only scanned when you trigger them.++## Importing accounts++From the **Staged Accounts** tab, select the accounts you want and click **Import Accounts**. Then choose:++| Field | Description |+|-------|-------------|+| **Destination Folder** | The [folder](/documentation/platform/pam/folders/overview) to import the accounts into |+| **Template** | A [PostgreSQL account template](/documentation/platform/pam/templates/overview) to apply |++Once imported, the accounts become regular PAM PostgreSQL accounts in the chosen folder and inherit their template's rules.++<Warning>+Imported accounts arrive without a credential because discovery finds roles with a name but no password. Open each imported account and add a credential before connecting.+</Warning>++## Next steps++<CardGroup cols={2}>+ <Card title="Discovery Overview" icon="radar" href="/documentation/platform/pam/discovery/overview">+ Understand staging, importing, and schedules.+ </Card>+ <Card title="PostgreSQL Accounts" icon="database" href="/documentation/platform/pam/accounts/postgresql">+ Learn about the account type used to authenticate scans.+ </Card>+</CardGroup>diff --git a/frontend/package-lock.json b/frontend/package-lock.jsonindex 083e43529f..7bef20596d 100644--- a/frontend/package-lock.json+++ b/frontend/package-lock.json@@ -210,7 +210,6 @@"integrity": "sha512-2BCOP7TN8M+gVDj7/ht3hsaO/B/n5oDbiAyyvnRlNOs+u1o+JWNYTQrmpuNp1/Wq2gcFrI01JAW+paEKDMx/CA==","dev": true,"license": "MIT",- "peer": true,"dependencies": {"@babel/code-frame": "^7.27.1","@babel/generator": "^7.28.3",@@ -587,7 +586,6 @@"resolved": "https://registry.npmjs.org/@casl/ability/-/ability-6.8.0.tgz","integrity": "sha512-Ipt4mzI4gSgnomFdaPjaLgY2MWuXqAEZLrU6qqWBB7khGiBBuuEp6ytYDnq09bRXqcjaeeHiaCvCGFbBA2SpvA==","license": "MIT",- "peer": true,"dependencies": {"@ucast/mongo2js": "^1.3.0"},@@ -751,7 +749,6 @@"resolved": "https://registry.npmjs.org/@dnd-kit/core/-/core-6.3.1.tgz","integrity": "sha512-xkGBRQQab4RLwgXxoqETICr6S5JlogafbhNsidmrkVv2YRs5MLwpjoF2qpiGjQt8S9AoxtIV603s0GIUpY5eYQ==","license": "MIT",- "peer": true,"dependencies": {"@dnd-kit/accessibility": "^3.1.1","@dnd-kit/utilities": "^3.2.2",@@ -1611,7 +1608,6 @@"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-6.7.1.tgz","integrity": "sha512-8dBIHbfsKlCk2jHQ9PoRBg2Z+4TwyE3vZICSnoDlnsHA6SiMlTwfmW6yX0lHsRmWJugkeb92sA0hZdkXJhuz+g==","license": "MIT",- "peer": true,"dependencies": {"@fortawesome/fontawesome-common-types": "6.7.1"},@@ -2346,7 +2342,6 @@"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.0.tgz","integrity": "sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==","license": "Apache-2.0",- "peer": true,"engines": {"node": ">=8.0.0"}@@ -5170,7 +5165,6 @@"integrity": "sha512-RnO1SaiCFHn666wNz2QfZEFxvmiNRqhzaMXHXxXXKt+MEP7aajlPxUSMIQpKAaJfverpovEYqjBOXDq6dDcaOQ==","dev": true,"license": "MIT",- "peer": true,"dependencies": {"@typescript-eslint/utils": "^8.13.0","eslint-visitor-keys": "^4.2.0",@@ -5826,7 +5820,6 @@"resolved": "https://registry.npmjs.org/@tanstack/react-router/-/react-router-1.95.1.tgz","integrity": "sha512-P5x4yNhcdkYsCEoYeGZP8Q9Jlxf0WXJa4G/xvbmM905seZc9FqJqvCSRvX3dWTPOXRABhl4g+8DHqfft0c/AvQ==","license": "MIT",- "peer": true,"dependencies": {"@tanstack/history": "1.95.0","@tanstack/react-store": "^0.7.0",@@ -6048,6 +6041,7 @@"integrity": "sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"@babel/code-frame": "^7.10.4","@babel/runtime": "^7.12.5",@@ -6068,6 +6062,7 @@"integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==","dev": true,"license": "Apache-2.0",+ "peer": true,"dependencies": {"dequal": "^2.0.3"}@@ -6118,7 +6113,8 @@"resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz","integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==","dev": true,- "license": "MIT"+ "license": "MIT",+ "peer": true},"node_modules/@types/babel__core": {"version": "7.20.5",@@ -6416,7 +6412,6 @@"resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.16.tgz","integrity": "sha512-oh8AMIC4Y2ciKufU8hnKgs+ufgbA/dhPTACaZPM86AbwX9QwnFtSoPWEeRUj8fge+v6kFt78BXcDhAU1SrrAsw==","license": "MIT",- "peer": true,"dependencies": {"@types/prop-types": "*","csstype": "^3.0.2"@@ -6428,7 +6423,6 @@"integrity": "sha512-P4t6saawp+b/dFrUr2cvkVsfvPguwsxtH6dNIYRllMsefqFzkZk5UIjzyDOv5g1dXIPdG4Sp1yCR4Z6RCUsG/Q==","devOptional": true,"license": "MIT",- "peer": true,"peerDependencies": {"@types/react": "^18.0.0"}@@ -6482,7 +6476,6 @@"integrity": "sha512-QXwAlHlbcAwNlEEMKQS2RCgJsgXrTJdjXT08xEgbPFa2yYQgVjBymxP5DrfrE7X7iodSzd9qBUHUycdyVJTW1w==","dev": true,"license": "MIT",- "peer": true,"dependencies": {"@eslint-community/regexpp": "^4.10.0","@typescript-eslint/scope-manager": "8.34.0",@@ -6523,7 +6516,6 @@"integrity": "sha512-vxXJV1hVFx3IXz/oy2sICsJukaBrtDEQSBiV48/YIV5KWjX1dO+bcIr/kCPrW6weKXvsaGKFNlwH0v2eYdRRbA==","dev": true,"license": "MIT",- "peer": true,"dependencies": {"@typescript-eslint/scope-manager": "8.34.0","@typescript-eslint/types": "8.34.0",@@ -6877,8 +6869,7 @@"version": "5.5.0","resolved": "https://registry.npmjs.org/@xterm/xterm/-/xterm-5.5.0.tgz","integrity": "sha512-hqJHYaQb5OptNunnyAnkHyM8aCjZ1MEIDTQu1iIbbTD/xops91NB5yq1ZK/dC2JDbVWtF23zUtl9JE2NqwT87A==",- "license": "MIT",- "peer": true+ "license": "MIT"},"node_modules/@xyflow/react": {"version": "12.4.4",@@ -6944,7 +6935,6 @@"integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==","dev": true,"license": "MIT",- "peer": true,"bin": {"acorn": "bin/acorn"},@@ -7115,6 +7105,7 @@"integrity": "sha512-CVvd6FHg1Z3POpBLxO6E6zr+rSKEQ9L6rZHAaY7lLfhKsWYUBBOuMs0e9o24oopj6H+geRCX0YJ+TJLBK2eHyQ==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"call-bind": "^1.0.7","define-properties": "^1.2.1",@@ -7195,6 +7186,7 @@"integrity": "sha512-p6Fx8B7b7ZhL/gmUsAy0D15WhvDccw3mnGNbZpi3pmeJdxtWsj2jEaI4Y6oo3XiHfzuSgPwKc04MYt6KgvC/wA==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"call-bind": "^1.0.7","define-properties": "^1.2.1",@@ -7304,7 +7296,8 @@"resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.8.tgz","integrity": "sha512-OH/2E5Fg20h2aPrbe+QL8JZQFko0YZaF+j4mnQ7BGhfavO7OpSLa8a0y9sBwomHdSbkhTS8TQNayBfnW5DwbvQ==","dev": true,- "license": "MIT"+ "license": "MIT",+ "peer": true},"node_modules/asynckit": {"version": "0.4.0",@@ -7356,6 +7349,7 @@"integrity": "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==","dev": true,"license": "Apache-2.0",+ "peer": true,"engines": {"node": ">= 0.4"}@@ -7661,7 +7655,6 @@}],"license": "MIT",- "peer": true,"dependencies": {"baseline-browser-mapping": "^2.8.9","caniuse-lite": "^1.0.30001746",@@ -8420,7 +8413,6 @@"resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz","integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==","license": "ISC",- "peer": true,"engines": {"node": ">=12"}@@ -8510,7 +8502,8 @@"resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz","integrity": "sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==","dev": true,- "license": "BSD-2-Clause"+ "license": "BSD-2-Clause",+ "peer": true},"node_modules/data-view-buffer": {"version": "1.0.1",@@ -8797,7 +8790,8 @@"resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz","integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==","dev": true,- "license": "MIT"+ "license": "MIT",+ "peer": true},"node_modules/dom-helpers": {"version": "5.2.1",@@ -9017,6 +9011,7 @@"integrity": "sha512-tpxqxncxnpw3c93u8n3VOzACmRFoVmWJqbWXvX/JfKbkhBw1oslgPrUfeSt2psuqyEJFD6N/9lg5i7bsKpoq+Q==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"call-bind": "^1.0.7","define-properties": "^1.2.1",@@ -9110,7 +9105,6 @@"dev": true,"hasInstallScript": true,"license": "MIT",- "peer": true,"bin": {"esbuild": "bin/esbuild"},@@ -9188,7 +9182,6 @@"deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.","dev": true,"license": "MIT",- "peer": true,"dependencies": {"@eslint-community/eslint-utils": "^4.2.0","@eslint-community/regexpp": "^4.6.1",@@ -9245,7 +9238,6 @@"integrity": "sha512-T75QYQVQX57jiNgpF9r1KegMICE94VYwoFQyMGhrvc+lB8YF2E/M/PYDaQe1AJcWaEgqLE+ErXV1Og/+6Vyzew==","dev": true,"license": "MIT",- "peer": true,"dependencies": {"eslint-config-airbnb-base": "^15.0.0","object.assign": "^4.1.2",@@ -9268,7 +9260,6 @@"integrity": "sha512-xaX3z4ZZIcFLvh2oUNvcX5oEofXda7giYmuplVxoOg5A7EXJMrUyqRgR+mhDhPK8LZ4PttFOBvCYDbX3sUoUig==","dev": true,"license": "MIT",- "peer": true,"dependencies": {"confusing-browser-globals": "^1.0.10","object.assign": "^4.1.2",@@ -9299,7 +9290,6 @@"integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==","dev": true,"license": "MIT",- "peer": true,"bin": {"eslint-config-prettier": "bin/cli.js"},@@ -9399,7 +9389,6 @@"integrity": "sha512-ixmkI62Rbc2/w8Vfxyh1jQRTdRTF52VxwRVHl/ykPAmqG+Nb7/kNn+byLP0LxPgI7zWA16Jt82SybJInmMia3A==","dev": true,"license": "MIT",- "peer": true,"dependencies": {"@rtsao/scc": "^1.1.0","array-includes": "^3.1.8",@@ -9491,6 +9480,7 @@"integrity": "sha512-scB3nz4WmG75pV8+3eRUQOHZlNSUhFNq37xnpgRkCCELU3XMvXAxLk1eqWWyE22Ki4Q01Fnsw9BA3cJHDPgn2Q==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"aria-query": "^5.3.2","array-includes": "^3.1.8",@@ -9521,6 +9511,7 @@"integrity": "sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"balanced-match": "^1.0.0","concat-map": "0.0.1"@@ -9532,6 +9523,7 @@"integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==","dev": true,"license": "ISC",+ "peer": true,"dependencies": {"brace-expansion": "^1.1.7"},@@ -9576,6 +9568,7 @@"integrity": "sha512-EsTAnj9fLVr/GZleBLFbj/sSuXeWmp1eXIN60ceYnZveqEaUCyW4X+Vh4WTdUhCkW4xutXYqTXCUSyqD4rB75w==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"array-includes": "^3.1.8","array.prototype.findlast": "^1.2.5",@@ -9609,7 +9602,6 @@"integrity": "sha512-QzliNJq4GinDBcD8gPB5v0wh6g8q3SUi6EFF0x8N/BL9PoVs0atuGc47ozMRyOWAKdwaZ5OnbOEa3WR+dSGKuQ==","dev": true,"license": "MIT",- "peer": true,"engines": {"node": ">=10"},@@ -9633,6 +9625,7 @@"integrity": "sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"balanced-match": "^1.0.0","concat-map": "0.0.1"@@ -9644,6 +9637,7 @@"integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==","dev": true,"license": "Apache-2.0",+ "peer": true,"dependencies": {"esutils": "^2.0.2"},@@ -9657,6 +9651,7 @@"integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==","dev": true,"license": "ISC",+ "peer": true,"dependencies": {"brace-expansion": "^1.1.7"},@@ -9670,6 +9665,7 @@"integrity": "sha512-U7WjGVG9sH8tvjW5SmGbQuui75FiyjAX72HX15DwBBwF9dNiQZRQAg9nnPhYy+TUnE0+VcrttuvNI8oSxZcocA==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"is-core-module": "^2.13.0","path-parse": "^1.0.7",@@ -9688,6 +9684,7 @@"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==","dev": true,"license": "ISC",+ "peer": true,"bin": {"semver": "bin/semver.js"}@@ -10845,7 +10842,6 @@}],"license": "MIT",- "peer": true,"dependencies": {"@babel/runtime": "^7.23.2"},@@ -10903,7 +10899,6 @@"resolved": "https://registry.npmjs.org/immer/-/immer-10.2.0.tgz","integrity": "sha512-d/+XTN3zfODyjr89gM3mPq1WNX2B8pYsu7eORitdwyA2sBubnTl3laYlBk4sXY5FUa5qTZGBDPJICVbvqzjlbw==","license": "MIT",- "peer": true,"funding": {"type": "opencollective","url": "https://opencollective.com/immer"@@ -11570,6 +11565,7 @@"resolved": "https://registry.npmjs.org/isomorphic.js/-/isomorphic.js-0.2.5.tgz","integrity": "sha512-PIeMbHqMt4DnUP3MA/Flc0HElYjMXArsw1qwJZcm9sqR8mq3l8NYizFMty0pWwE/tzIGH3EKK5+jes5mAr85yw==","license": "MIT",+ "peer": true,"funding": {"type": "GitHub Sponsors ❤","url": "https://github.com/sponsors/dmonad"@@ -11581,6 +11577,7 @@"integrity": "sha512-x4WH0BWmrMmg4oHHl+duwubhrvczGlyuGAZu3nvrf0UXOfPu8IhZObFEr7DE/iv01YgVZrsOiRcqw2srkKEDIA==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"define-data-property": "^1.1.4","es-object-atoms": "^1.0.0",@@ -11696,6 +11693,7 @@"integrity": "sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"array-includes": "^3.1.6","array.prototype.flat": "^1.3.1",@@ -11730,7 +11728,8 @@"resolved": "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.23.tgz","integrity": "sha512-0K65Lea881pHotoGEa5gDlMxt3pctLi2RplBb7Ezh4rRdLEOtgi7n4EwK9lamnUCkKBqaeKRVebTq6BAxSkpXQ==","dev": true,- "license": "CC0-1.0"+ "license": "CC0-1.0",+ "peer": true},"node_modules/language-tags": {"version": "1.0.9",@@ -11738,6 +11737,7 @@"integrity": "sha512-MbjN408fEndfiQXbFQ1vnd+1NoLDsnQW41410oQBXiyXDMYH5z505juWa4KUE1LqxRC7DgOgZDbKLxHIwm27hA==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"language-subtag-registry": "^0.3.20"},@@ -11770,6 +11770,7 @@"resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.102.tgz","integrity": "sha512-g70kydI0I1sZU0ChO8mBbhw0oUW/8U0GHzygpvEIx8k+jgOpqnTSb/E+70toYVqHxBhrERD21TwD5QcZJQ40ZQ==","license": "MIT",+ "peer": true,"dependencies": {"isomorphic.js": "^0.2.4"},@@ -12113,6 +12114,7 @@"integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==","dev": true,"license": "MIT",+ "peer": true,"bin": {"lz-string": "bin/bin.js"}@@ -13549,7 +13551,6 @@"integrity": "sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==","dev": true,"license": "MIT",- "peer": true,"bin": {"prettier": "bin/prettier.cjs"},@@ -13666,6 +13667,7 @@"integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"ansi-regex": "^5.0.1","ansi-styles": "^5.0.0",@@ -13681,6 +13683,7 @@"integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==","dev": true,"license": "MIT",+ "peer": true,"engines": {"node": ">=10"},@@ -13693,7 +13696,8 @@"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz","integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==","dev": true,- "license": "MIT"+ "license": "MIT",+ "peer": true},"node_modules/prismjs": {"version": "1.30.0",@@ -14009,7 +14013,6 @@"resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz","integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==","license": "MIT",- "peer": true,"dependencies": {"loose-envify": "^1.1.0"},@@ -14097,7 +14100,6 @@"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz","integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==","license": "MIT",- "peer": true,"dependencies": {"loose-envify": "^1.1.0","scheduler": "^0.23.2"@@ -14148,7 +14150,6 @@"resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.56.3.tgz","integrity": "sha512-IK18V6GVbab4TAo1/cz3kqajxbDPGofdF0w7VHdCo0Nt8PrPlOZcuuDq9YYIV1BtjcX78x0XsldbQRQnQXWXmw==","license": "MIT",- "peer": true,"engines": {"node": ">=18.0.0"},@@ -14195,8 +14196,7 @@"version": "16.13.1","resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz","integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==",- "license": "MIT",- "peer": true+ "license": "MIT"},"node_modules/react-markdown": {"version": "10.0.1",@@ -14229,7 +14229,6 @@"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.2.0.tgz","integrity": "sha512-ROY9fvHhwOD9ySfrF0wmvu//bKCQ6AeZZq1nJNtbDC+kk5DuSuNX/n6YWYF/SYy7bSba4D4FSz8DJeKY/S/r+g==","license": "MIT",- "peer": true,"dependencies": {"@types/use-sync-external-store": "^0.0.6","use-sync-external-store": "^1.4.0"@@ -14492,8 +14491,7 @@"version": "5.0.1","resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz","integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==",- "license": "MIT",- "peer": true+ "license": "MIT"},"node_modules/redux-thunk": {"version": "3.1.0",@@ -14763,7 +14761,6 @@"integrity": "sha512-VmtB2rFU/GroZ4oL8+ZqXgSA38O6GR8KSIvWmEFv63pQ0G6KaBH9s07PO8XTXP4vI+3UJUEypOfjkGfmSBBR0w==","dev": true,"license": "MIT",- "peer": true,"dependencies": {"@types/estree": "1.0.8"},@@ -15277,6 +15274,7 @@"integrity": "sha512-o7+c9bW6zpAdJHTtujeePODAhkuicdAryFsfVKwA+wGw89wJ4GTY484WTucM9hLtDEOpOvI+aHnzqnC5lHp4Rg==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"call-bind": "^1.0.7","define-properties": "^1.2.1",@@ -15292,6 +15290,7 @@"integrity": "sha512-NUdh0aDavY2og7IbBPenWqR9exH+E26Sv8e0/eTe1tltDGZL+GtBkDAnnyBtmekfK6/Dq3MkcGtzXFEd1LQrtg==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"call-bind": "^1.0.7","define-properties": "^1.2.1",@@ -15319,6 +15318,7 @@"integrity": "sha512-0u/TldDbKD8bFCQ/4f5+mNRrXwZ8hg2w7ZR8wa16e8z9XpePWl3eGEcUD0OXpEH/VJH/2G3gjUtR3ZOiBe2S/w==","dev": true,"license": "MIT",+ "peer": true,"dependencies": {"define-properties": "^1.1.3","es-abstract": "^1.17.5"@@ -15923,7 +15923,6 @@"integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==","devOptional": true,"license": "Apache-2.0",- "peer": true,"bin": {"tsc": "bin/tsc","tsserver": "bin/tsserver"@@ -16315,7 +16314,6 @@"integrity": "sha512-2N/55r4JDJ4gdrCvGgINMy+HH3iRpNIz8K6SFwVsA+JbQScLiC+clmAxBgwiSPgcG9U15QmvqCGWzMbqda5zGQ==","dev": true,"license": "MIT",- "peer": true,"dependencies": {"esbuild": "^0.25.0","fdir": "^6.4.4",@@ -16815,7 +16813,6 @@"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.3.tgz","integrity": "sha512-AvbaCLOO2Otw/lW5bmh9d/WEdcDFdQp2Z2ZUH3pX9U2ihyUY0nvLv7J6TrWowklRGPYbB/IuIMfYgxaCPg5Bpg==","license": "ISC",- "peer": true,"bin": {"yaml": "bin.mjs"},@@ -16969,7 +16966,6 @@"resolved": "https://registry.npmjs.org/zod/-/zod-3.24.1.tgz","integrity": "sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==","license": "MIT",- "peer": true,"funding": {"url": "https://github.com/sponsors/colinhacks"}diff --git a/frontend/src/hooks/api/pam/enums.ts b/frontend/src/hooks/api/pam/enums.tsindex 2c5ce30e90..261fe22a7d 100644--- a/frontend/src/hooks/api/pam/enums.ts+++ b/frontend/src/hooks/api/pam/enums.ts@@ -16,7 +16,8 @@ export enum PamAccountType {export enum PamDiscoveryType {ActiveDirectory = "active-directory",- Unix = "unix"+ Unix = "unix",+ Postgres = "postgres"}export enum PamDiscoverySchedule {diff --git a/frontend/src/hooks/api/pam/queries.tsx b/frontend/src/hooks/api/pam/queries.tsxindex dc2f110d2b..48d6018910 100644--- a/frontend/src/hooks/api/pam/queries.tsx+++ b/frontend/src/hooks/api/pam/queries.tsx@@ -531,7 +531,9 @@ export const useListPamDiscoverySources = (params?: { search?: string }) => {);return data.sources;},- placeholderData: (prev) => prev+ placeholderData: (prev) => prev,+ refetchInterval: (query) =>+ query.state.data?.some((source) => source.lastRunStatus === "running") ? 5000 : false});};diff --git a/frontend/src/pages/pam/PamDiscoveryPage/components/AddDiscoverySourceSheet.tsx b/frontend/src/pages/pam/PamDiscoveryPage/components/AddDiscoverySourceSheet.tsxindex 02ce196c57..d25e92538d 100644--- a/frontend/src/pages/pam/PamDiscoveryPage/components/AddDiscoverySourceSheet.tsx+++ b/frontend/src/pages/pam/PamDiscoveryPage/components/AddDiscoverySourceSheet.tsx@@ -41,18 +41,21 @@ import {import {buildDiscoveryConfiguration,- buildUnixDiscoveryConfiguration,+ buildHostRangeDiscoveryConfiguration,CredentialAccountField,+ CredentialAccountsField,DISCOVERY_CONFIG_DEFAULTS,DiscoveryConfigFields,discoveryConfigFormShape,+ HOST_RANGE_DISCOVERY_CONFIG_DEFAULTS,+ HOST_RANGE_SOURCES,+ HostRangeDiscoveryConfigFields,+ hostRangeDiscoveryConfigFormShape,+ isHostRangeDiscoveryType,ScheduleField,- SshCredentialAccountsField,TDiscoveryConfigFields,- TUnixDiscoveryConfigFields,- UNIX_DISCOVERY_CONFIG_DEFAULTS,- UnixDiscoveryConfigFields,- unixDiscoveryConfigFormShape+ THostRangeDiscoveryConfigFields,+ THostRangeDiscoveryType} from "./DiscoveryConfigFields";type FormProps = {@@ -214,26 +217,32 @@ const ActiveDirectorySourceForm = ({ onBack, onClose, onDirtyChange }: FormProps);};-const unixSchema = z.object({+const hostRangeSchema = z.object({name: z.string().min(1, "Name is required").max(64),schedule: z.nativeEnum(PamDiscoverySchedule),- ...unixDiscoveryConfigFormShape+ ...hostRangeDiscoveryConfigFormShape});-const UnixSourceForm = ({ onBack, onClose, onDirtyChange }: FormProps) => {+const HostRangeSourceForm = ({+ discoveryType,+ onBack,+ onClose,+ onDirtyChange+}: FormProps & { discoveryType: THostRangeDiscoveryType }) => {const createSource = useCreatePamDiscoverySource();const { gateway, setGateway, gatewayError, setGatewayError } = useGatewaySelection();+ const source = HOST_RANGE_SOURCES[discoveryType];const {handleSubmit,control,formState: { isDirty }- } = useForm<z.infer<typeof unixSchema>>({- resolver: zodResolver(unixSchema),+ } = useForm<z.infer<typeof hostRangeSchema>>({+ resolver: zodResolver(hostRangeSchema),defaultValues: {name: "",schedule: PamDiscoverySchedule.Manual,- ...UNIX_DISCOVERY_CONFIG_DEFAULTS+ ...HOST_RANGE_DISCOVERY_CONFIG_DEFAULTS}});@@ -242,18 +251,18 @@ const UnixSourceForm = ({ onBack, onClose, onDirtyChange }: FormProps) => {return () => onDirtyChange(false);}, [isDirty, onDirtyChange]);- const onSubmit = (data: z.infer<typeof unixSchema>) => {+ const onSubmit = (data: z.infer<typeof hostRangeSchema>) => {if (!gateway.gatewayId && !gateway.gatewayPoolId) {setGatewayError(true);return;}createSource.mutate({- discoveryType: PamDiscoveryType.Unix,+ discoveryType,name: data.name,credentialAccountId: data.credentialAccountIds[0],schedule: data.schedule,- configuration: buildUnixDiscoveryConfiguration(data),+ configuration: buildHostRangeDiscoveryConfiguration(data),...(gateway.gatewayId ? { gatewayId: gateway.gatewayId } : {}),...(gateway.gatewayPoolId ? { gatewayPoolId: gateway.gatewayPoolId } : {})},@@ -281,8 +290,11 @@ const UnixSourceForm = ({ onBack, onClose, onDirtyChange }: FormProps) => {}><NameField control={control as unknown as Control<{ name: string }>} />- <SshCredentialAccountsField+ <CredentialAccountsFieldcontrol={control as unknown as Control<{ credentialAccountIds: string[] }>}+ accountType={source.accountType}+ placeholder={source.placeholder}+ warning={source.warning}/><GatewayFieldvalue={gateway}@@ -295,8 +307,8 @@ const UnixSourceForm = ({ onBack, onClose, onDirtyChange }: FormProps) => {<ScheduleFieldcontrol={control as unknown as Control<{ schedule: PamDiscoverySchedule }>}/>- <UnixDiscoveryConfigFields- control={control as unknown as Control<TUnixDiscoveryConfigFields>}+ <HostRangeDiscoveryConfigFields+ control={control as unknown as Control<THostRangeDiscoveryConfigFields>}/></FormShell></form>@@ -408,8 +420,9 @@ export const AddDiscoverySourceSheet = ({ isOpen, onOpenChange }: Props) => {/>)}{step === 2 &&- (selectedType === PamDiscoveryType.Unix ? (- <UnixSourceForm+ (isHostRangeDiscoveryType(selectedType) ? (+ <HostRangeSourceForm+ discoveryType={selectedType}onBack={() => setStep(1)}onClose={close}onDirtyChange={setIsFormDirty}diff --git a/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoveryConfigFields.tsx b/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoveryConfigFields.tsxindex 8260b04b31..b5289d93c8 100644--- a/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoveryConfigFields.tsx+++ b/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoveryConfigFields.tsx@@ -20,7 +20,12 @@ import {Switch,TextArea} from "@app/components/v3";-import { PamAccountType, PamDiscoverySchedule, useListPamAccounts } from "@app/hooks/api/pam";+import {+ PamAccountType,+ PamDiscoverySchedule,+ PamDiscoveryType,+ useListPamAccounts+} from "@app/hooks/api/pam";export const discoveryConfigFormShape = {scanLocalAccounts: z.boolean(),@@ -161,14 +166,38 @@ export const DiscoveryConfigFields = ({);};-export const unixDiscoveryConfigFormShape = {+// Sources that scan a host range with a set of credential accounts+export const HOST_RANGE_SOURCES = {+ [PamDiscoveryType.Unix]: {+ accountType: PamAccountType.SSH,+ placeholder: "Select SSH accounts",+ warning:+ "Password accounts send their password to every host scanned in the range, including hosts you don't control. We recommend a key or certificate account for scanning."+ },+ [PamDiscoveryType.Postgres]: {+ accountType: PamAccountType.Postgres,+ placeholder: "Select PostgreSQL accounts",+ warning:+ "The account password is sent to every host scanned in the range, including hosts you don't control. Only scan ranges you trust."+ }+} as const;++export type THostRangeDiscoveryType = keyof typeof HOST_RANGE_SOURCES;++export const isHostRangeDiscoveryType = (+ type: PamDiscoveryType | null | undefined+): type is THostRangeDiscoveryType => Boolean(type && type in HOST_RANGE_SOURCES);++export const hostRangeDiscoveryConfigFormShape = {cidrRanges: z.string().min(1, "At least one target is required"),credentialAccountIds: z.array(z.string()).min(1, "Select at least one account")};-export type TUnixDiscoveryConfigFields = z.infer<z.ZodObject<typeof unixDiscoveryConfigFormShape>>;+export type THostRangeDiscoveryConfigFields = z.infer<+ z.ZodObject<typeof hostRangeDiscoveryConfigFormShape>+>;-export const UNIX_DISCOVERY_CONFIG_DEFAULTS: TUnixDiscoveryConfigFields = {+export const HOST_RANGE_DISCOVERY_CONFIG_DEFAULTS: THostRangeDiscoveryConfigFields = {cidrRanges: "",credentialAccountIds: []};@@ -179,29 +208,35 @@ const parseCidrRanges = (value: string): string[] =>.map((v) => v.trim()).filter(Boolean);-export const unixDiscoveryConfigFromSource = (+export const hostRangeDiscoveryConfigFromSource = (config: Record<string, unknown>-): TUnixDiscoveryConfigFields => ({+): THostRangeDiscoveryConfigFields => ({cidrRanges: Array.isArray(config.cidrRanges) ? (config.cidrRanges as string[]).join("\n") : "",credentialAccountIds: Array.isArray(config.credentialAccountIds)? (config.credentialAccountIds as string[]): []});-export const buildUnixDiscoveryConfiguration = (- data: TUnixDiscoveryConfigFields+export const buildHostRangeDiscoveryConfiguration = (+ data: THostRangeDiscoveryConfigFields): Record<string, unknown> => ({cidrRanges: parseCidrRanges(data.cidrRanges),credentialAccountIds: data.credentialAccountIds});-export const SshCredentialAccountsField = ({- control+export const CredentialAccountsField = ({+ control,+ accountType,+ placeholder,+ warning}: {control: Control<{ credentialAccountIds: string[] }>;+ accountType: PamAccountType;+ placeholder: string;+ warning: string;}) => {const { data: accounts = [] } = useListPamAccounts();- const sshAccounts = accounts.filter((a) => a.accountType === PamAccountType.SSH);+ const matchingAccounts = accounts.filter((a) => a.accountType === accountType);return (<Controller@@ -213,14 +248,14 @@ export const SshCredentialAccountsField = ({<FieldContent><FilterableSelectisMulti- value={sshAccounts.filter((a) => field.value?.includes(a.id))}+ value={matchingAccounts.filter((a) => field.value?.includes(a.id))}onChange={(val) =>- field.onChange(((val as typeof sshAccounts | null) ?? []).map((a) => a.id))+ field.onChange(((val as typeof matchingAccounts | null) ?? []).map((a) => a.id))}- options={sshAccounts}+ options={matchingAccounts}getOptionValue={(a) => a.id}getOptionLabel={(a) => (a.folderName ? `${a.folderName} / ${a.name}` : a.name)}- placeholder="Select SSH accounts"+ placeholder={placeholder}/><FieldDescription>A target is matched to an account by host, otherwise each account is tried until one@@ -229,11 +264,7 @@ export const SshCredentialAccountsField = ({<FieldError>{fieldState.error?.message}</FieldError><Alert variant="warning" className="mt-1"><AlertTriangle />- <AlertDescription>- Password accounts send their password to every host scanned in the range, including- hosts you don't control. We recommend a key or certificate account for- scanning.- </AlertDescription>+ <AlertDescription>{warning}</AlertDescription></Alert></FieldContent></Field>@@ -242,10 +273,10 @@ export const SshCredentialAccountsField = ({);};-export const UnixDiscoveryConfigFields = ({+export const HostRangeDiscoveryConfigFields = ({control}: {- control: Control<TUnixDiscoveryConfigFields>;+ control: Control<THostRangeDiscoveryConfigFields>;}) => (<Controllercontrol={control}diff --git a/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoverySourceDetailSheet.tsx b/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoverySourceDetailSheet.tsxindex bac48904ff..d8b4a618c4 100644--- a/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoverySourceDetailSheet.tsx+++ b/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoverySourceDetailSheet.tsx@@ -47,7 +47,6 @@ import {import {PamAccountType,PamDiscoverySchedule,- PamDiscoveryType,pamKeys,TPamDiscoveredAccount,TPamDiscoverySource,@@ -69,18 +68,21 @@ import { PAM_DISCOVERY_TABS } from "../../components/pamResourceTabs";import { SheetSaveBar } from "../../components/SheetSaveBar";import {buildDiscoveryConfiguration,- buildUnixDiscoveryConfiguration,+ buildHostRangeDiscoveryConfiguration,CredentialAccountField,+ CredentialAccountsField,DiscoveryConfigFields,discoveryConfigFormShape,discoveryConfigFromSource,+ HOST_RANGE_SOURCES,+ HostRangeDiscoveryConfigFields,+ hostRangeDiscoveryConfigFormShape,+ hostRangeDiscoveryConfigFromSource,+ isHostRangeDiscoveryType,ScheduleField,- SshCredentialAccountsField,TDiscoveryConfigFields,- TUnixDiscoveryConfigFields,- UnixDiscoveryConfigFields,- unixDiscoveryConfigFormShape,- unixDiscoveryConfigFromSource+ THostRangeDiscoveryConfigFields,+ THostRangeDiscoveryType} from "./DiscoveryConfigFields";import { DiscoveryStatusBadge } from "./DiscoveryStatusBadge";import { ImportDiscoveredModal } from "./ImportDiscoveredModal";@@ -229,29 +231,32 @@ const ActiveDirectoryConfigForm = ({);};-const unixConfigSchema = z.object({+const hostRangeConfigSchema = z.object({name: z.string().min(1, "Name is required").max(64),schedule: z.nativeEnum(PamDiscoverySchedule),gatewayId: z.string().nullable(),gatewayPoolId: z.string().nullable(),- ...unixDiscoveryConfigFormShape+ ...hostRangeDiscoveryConfigFormShape});-const UnixConfigForm = ({+const HostRangeConfigForm = ({source,+ discoveryType,onDirtyChange}: {source: TPamDiscoverySource;+ discoveryType: THostRangeDiscoveryType;onDirtyChange: (isDirty: boolean) => void;}) => {const updateSource = useUpdatePamDiscoverySource();+ const sourceMeta = HOST_RANGE_SOURCES[discoveryType];- const defaults: z.infer<typeof unixConfigSchema> = {+ const defaults: z.infer<typeof hostRangeConfigSchema> = {name: source.name,schedule: source.schedule,gatewayId: source.gatewayId ?? null,gatewayPoolId: source.gatewayPoolId ?? null,- ...unixDiscoveryConfigFromSource(source.discoveryConfiguration)+ ...hostRangeDiscoveryConfigFromSource(source.discoveryConfiguration)};const {@@ -261,7 +266,7 @@ const UnixConfigForm = ({watch,setValue,formState: { isDirty }- } = useForm({ resolver: zodResolver(unixConfigSchema), defaultValues: defaults });+ } = useForm({ resolver: zodResolver(hostRangeConfigSchema), defaultValues: defaults });useEffect(() => {onDirtyChange(isDirty);@@ -273,7 +278,7 @@ const UnixConfigForm = ({// eslint-disable-next-line react-hooks/exhaustive-deps}, [source, reset]);- const onSubmit = (data: z.infer<typeof unixConfigSchema>) => {+ const onSubmit = (data: z.infer<typeof hostRangeConfigSchema>) => {updateSource.mutate({sourceId: source.id,@@ -283,7 +288,7 @@ const UnixConfigForm = ({schedule: data.schedule,gatewayId: data.gatewayId,gatewayPoolId: data.gatewayPoolId,- configuration: buildUnixDiscoveryConfiguration(data)+ configuration: buildHostRangeDiscoveryConfiguration(data)},{ onSuccess: () => createNotification({ type: "success", text: "Discovery source updated" }) });@@ -293,8 +298,11 @@ const UnixConfigForm = ({<form onSubmit={handleSubmit(onSubmit)} className="flex flex-1 flex-col gap-4 p-4"><ConfigCard><NameField control={control as unknown as Control<{ name: string }>} />- <SshCredentialAccountsField+ <CredentialAccountsFieldcontrol={control as unknown as Control<{ credentialAccountIds: string[] }>}+ accountType={sourceMeta.accountType}+ placeholder={sourceMeta.placeholder}+ warning={sourceMeta.warning}/><GatewayFieldgatewayId={watch("gatewayId")}@@ -307,8 +315,8 @@ const UnixConfigForm = ({<ScheduleFieldcontrol={control as unknown as Control<{ schedule: PamDiscoverySchedule }>}/>- <UnixDiscoveryConfigFields- control={control as unknown as Control<TUnixDiscoveryConfigFields>}+ <HostRangeDiscoveryConfigFields+ control={control as unknown as Control<THostRangeDiscoveryConfigFields>}/></ConfigCard>@@ -325,8 +333,12 @@ const ConfigurationTab = ({source: TPamDiscoverySource;onDirtyChange: (isDirty: boolean) => void;}) =>- source.discoveryType === PamDiscoveryType.Unix ? (- <UnixConfigForm source={source} onDirtyChange={onDirtyChange} />+ isHostRangeDiscoveryType(source.discoveryType) ? (+ <HostRangeConfigForm+ source={source}+ discoveryType={source.discoveryType}+ onDirtyChange={onDirtyChange}+ />) : (<ActiveDirectoryConfigForm source={source} onDirtyChange={onDirtyChange} />);@@ -409,6 +421,7 @@ export const DiscoverySourceDetailSheet = ({ isOpen, sourceId, onOpenChange }: PqueryClient.invalidateQueries({queryKey: [...pamKeys.discovery(), "stale", sourceId ?? ""]});+ queryClient.invalidateQueries({ queryKey: [...pamKeys.discovery(), "sources"] });// A scan reconciles dependencies onto managed accounts, so refresh account views (their dependency// lists are keyed under pamKeys.account()) which the discovery scan otherwise never invalidates.queryClient.invalidateQueries({ queryKey: pamKeys.account() });