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
finalize discovery base + other minor tweaks
x0322053a65a82ec25b
diff --git a/backend/src/ee/routes/v1/pam-discovery-routers/pam-discovery-router.ts b/backend/src/ee/routes/v1/pam-discovery-routers/pam-discovery-router.tsindex 47e8d053e5..42d6f285ab 100644--- a/backend/src/ee/routes/v1/pam-discovery-routers/pam-discovery-router.ts+++ b/backend/src/ee/routes/v1/pam-discovery-routers/pam-discovery-router.ts@@ -65,7 +65,12 @@ export const registerPamDiscoveryRouter = async (server: FastifyZodProvider) =>}),response: {200: z.object({- sources: SanitizedDiscoverySourcesSchema.array(),+ sources: SanitizedDiscoverySourcesSchema.and(+ z.object({+ totalResources: z.number(),+ totalAccounts: z.number()+ })+ ).array(),totalCount: z.number()})}diff --git a/backend/src/ee/services/pam-discovery/active-directory/active-directory-discovery-factory.ts b/backend/src/ee/services/pam-discovery/active-directory/active-directory-discovery-factory.tsnew file mode 100644index 0000000000..60359b28fb--- /dev/null+++ b/backend/src/ee/services/pam-discovery/active-directory/active-directory-discovery-factory.ts@@ -0,0 +1,613 @@+import ldapjs from "ldapjs";++import { TPamDiscoveryScanDeps } from "@app/ee/services/pam-discovery/pam-discovery-factory";+import { BadRequestError } from "@app/lib/errors";+import { GatewayProxyProtocol } from "@app/lib/gateway";+import { withGatewayV2Proxy } from "@app/lib/gateway-v2/gateway-v2";+import { logger } from "@app/lib/logger";+import { TKmsServiceFactory } from "@app/services/kms/kms-service";++import { verifyHostInputValidity } from "../../dynamic-secret/dynamic-secret-fns";+import { TGatewayV2ServiceFactory } from "../../gateway-v2/gateway-v2-service";+import { TPamAccountDALFactory } from "../../pam-account/pam-account-dal";+import { encryptAccountCredentials } from "../../pam-account/pam-account-fns";+import {+ TActiveDirectoryAccountCredentials,+ TActiveDirectoryAccountMetadata,+ TActiveDirectoryResourceConnectionDetails+} from "../../pam-resource/active-directory/active-directory-resource-types";+import { TPamResourceDALFactory } from "../../pam-resource/pam-resource-dal";+import { PamResource } from "../../pam-resource/pam-resource-enums";+import { encryptResourceConnectionDetails } from "../../pam-resource/pam-resource-fns";+import { WindowsProtocol } from "../../pam-resource/windows-server/windows-server-resource-enums";+import { TWindowsResourceConnectionDetails } from "../../pam-resource/windows-server/windows-server-resource-types";+import { PamDiscoveryRunStatus, PamDiscoveryRunTrigger } from "../pam-discovery-enums";+import { TPamDiscoveryFactory } from "../pam-discovery-types";+import {+ TActiveDirectoryDiscoveryConfiguration as TAdDiscoveryConfiguration,+ TActiveDirectoryDiscoveryCredentials as TAdDiscoveryCredentials,+ TActiveDirectoryDiscoverySourceRunProgress+} from "./active-directory-discovery-types";++const LDAP_TIMEOUT = 30 * 1000;+const LDAP_PAGE_SIZE = 500;+const SERVICE_ACCOUNT_PATTERNS = [/^svc[_-]/i, /[_-]service$/i, /[_-]svc$/i];++type TLdapComputer = {+ cn: string;+ dNSHostName: string;+ operatingSystem: string;+ objectGUID: string;+ whenChanged: string;+};++type TLdapUser = {+ sAMAccountName: string;+ userPrincipalName: string;+ objectGUID: string;+ displayName: string;+ servicePrincipalName: string | string[];+ memberOf: string | string[];+ pwdLastSet: string;+ userAccountControl: string;+ whenChanged: string;+};++const isServiceAccount = (user: TLdapUser): boolean => {+ const spn = user.servicePrincipalName;+ if (spn && (typeof spn === "string" ? spn.length > 0 : spn.length > 0)) {+ return true;+ }+ const name = user.sAMAccountName || "";+ if (SERVICE_ACCOUNT_PATTERNS.some((pattern) => pattern.test(name))) {+ return true;+ }+ return false;+};++const toSlugName = (name: string): string =>+ name+ .toLowerCase()+ .replace(/[^a-z0-9-]/g, "-")+ .replace(/-+/g, "-")+ .replace(/^-|-$/g, "");++const buildDomainDN = (domainFQDN: string): string => {+ return domainFQDN+ .split(".")+ .map((part) => `DC=${part}`)+ .join(",");+};++const parseObjectGUID = (buf: Buffer | undefined): string => {+ if (buf && buf.length === 16) {+ const hex = buf.toString("hex");+ return [+ hex.substring(6, 8) + hex.substring(4, 6) + hex.substring(2, 4) + hex.substring(0, 2),+ hex.substring(10, 12) + hex.substring(8, 10),+ hex.substring(14, 16) + hex.substring(12, 14),+ hex.substring(16, 20),+ hex.substring(20, 32)+ ].join("-");+ }+ return "";+};++const ldapSearch = async (+ client: ldapjs.Client,+ baseDN: string,+ filter: string,+ attributes: string[]+): Promise<ldapjs.SearchEntry[]> => {+ return new Promise((resolve, reject) => {+ const results: ldapjs.SearchEntry[] = [];++ client.search(+ baseDN,+ {+ filter,+ scope: "sub",+ attributes,+ paged: { pageSize: LDAP_PAGE_SIZE },+ timeLimit: LDAP_TIMEOUT / 1000+ },+ (err, searchRes) => {+ if (err) {+ reject(err);+ return;+ }++ searchRes.on("searchEntry", (entry) => {+ results.push(entry);+ });++ searchRes.on("error", (searchErr) => {+ reject(searchErr);+ });++ searchRes.on("end", (result) => {+ if (result?.status !== 0) {+ reject(new Error(`LDAP search failed with status ${result?.status}`));+ } else {+ resolve(results);+ }+ });+ }+ );+ });+};++const executeWithGateway = async <T>(+ config: {+ dcAddress: string;+ port: number;+ gatewayId: string;+ },+ gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">,+ operation: (proxyPort: number) => Promise<T>+): Promise<T> => {+ const { dcAddress, port, gatewayId } = config;+ const [targetHost] = await verifyHostInputValidity({+ host: dcAddress,+ isGateway: true,+ isDynamicSecret: false+ });++ const platformConnectionDetails = await gatewayV2Service.getPlatformConnectionDetailsByGatewayId({+ gatewayId,+ targetHost,+ targetPort: port+ });++ if (!platformConnectionDetails) {+ throw new BadRequestError({ message: "Unable to connect to gateway, no platform connection details found" });+ }++ return withGatewayV2Proxy(+ async (proxyPort) => {+ return operation(proxyPort);+ },+ {+ protocol: GatewayProxyProtocol.Tcp,+ relayHost: platformConnectionDetails.relayHost,+ gateway: platformConnectionDetails.gateway,+ relay: platformConnectionDetails.relay+ }+ );+};++type TLdapAttribute = { type: string; values: string[]; buffers: Buffer[] };++const getAttr = (entry: ldapjs.SearchEntry, attrName: string): string => {+ const attr = (entry as unknown as { attributes: TLdapAttribute[] }).attributes?.find(+ (a) => a.type.toLowerCase() === attrName.toLowerCase()+ );+ return attr?.values?.[0] ?? "";+};++const getAttrBuffer = (entry: ldapjs.SearchEntry, attrName: string): Buffer | undefined => {+ const attr = (entry as unknown as { attributes: TLdapAttribute[] }).attributes?.find(+ (a) => a.type.toLowerCase() === attrName.toLowerCase()+ );+ return attr?.buffers?.[0];+};++const getAttrAll = (entry: ldapjs.SearchEntry, attrName: string): string[] => {+ const attr = (entry as unknown as { attributes: TLdapAttribute[] }).attributes?.find(+ (a) => a.type.toLowerCase() === attrName.toLowerCase()+ );+ return attr?.values ?? [];+};++const executeLdapEnumeration = async (+ configuration: TAdDiscoveryConfiguration,+ credentials: TAdDiscoveryCredentials,+ gatewayId: string,+ gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">+): Promise<{ computers: TLdapComputer[]; users: TLdapUser[] }> => {+ return executeWithGateway(+ { dcAddress: configuration.dcAddress, port: configuration.port, gatewayId },+ gatewayV2Service,+ async (proxyPort) => {+ const client = ldapjs.createClient({+ url: `ldap://localhost:${proxyPort}`,+ connectTimeout: LDAP_TIMEOUT,+ timeout: LDAP_TIMEOUT+ });++ try {+ const bindDn = `${credentials.username}@${configuration.domainFQDN}`;+ await new Promise<void>((resolve, reject) => {+ client.bind(bindDn, credentials.password, (err) => {+ if (err) reject(new Error(`LDAP bind failed: ${err.message}`));+ else resolve();+ });+ });++ const baseDN = buildDomainDN(configuration.domainFQDN);++ const computerEntries = await ldapSearch(+ client,+ baseDN,+ "(&(objectClass=computer)(operatingSystem=*Server*))",+ ["cn", "dNSHostName", "operatingSystem", "objectGUID", "whenChanged"]+ );++ const computers: TLdapComputer[] = computerEntries.map((entry) => ({+ cn: getAttr(entry, "cn"),+ dNSHostName: getAttr(entry, "dNSHostName"),+ operatingSystem: getAttr(entry, "operatingSystem"),+ objectGUID: parseObjectGUID(getAttrBuffer(entry, "objectGUID")),+ whenChanged: getAttr(entry, "whenChanged")+ }));++ const userEntries = await ldapSearch(client, baseDN, "(&(objectClass=user)(objectCategory=person))", [+ "sAMAccountName",+ "userPrincipalName",+ "objectGUID",+ "displayName",+ "servicePrincipalName",+ "memberOf",+ "pwdLastSet",+ "userAccountControl",+ "whenChanged"+ ]);++ const users: TLdapUser[] = userEntries.map((entry) => ({+ sAMAccountName: getAttr(entry, "sAMAccountName"),+ userPrincipalName: getAttr(entry, "userPrincipalName"),+ objectGUID: parseObjectGUID(getAttrBuffer(entry, "objectGUID")),+ displayName: getAttr(entry, "displayName"),+ servicePrincipalName: getAttrAll(entry, "servicePrincipalName"),+ memberOf: getAttrAll(entry, "memberOf"),+ pwdLastSet: getAttr(entry, "pwdLastSet"),+ userAccountControl: getAttr(entry, "userAccountControl"),+ whenChanged: getAttr(entry, "whenChanged")+ }));++ logger.info(+ { computerCount: computers.length, userCount: users.length },+ "PAM AD discovery LDAP enumeration completed"+ );++ return { computers, users };+ } finally {+ client.unbind();+ }+ }+ );+};++const upsertAdServerResource = async (+ projectId: string,+ configuration: TAdDiscoveryConfiguration,+ gatewayId: string,+ kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">,+ pamResourceDAL: Pick<TPamResourceDALFactory, "create" | "find">+) => {+ const existing = await pamResourceDAL.find({+ projectId,+ resourceType: PamResource.ActiveDirectory+ });++ const domainResourceName = toSlugName(configuration.domainFQDN);+ const matched = existing.find((r) => r.name === domainResourceName);+ if (matched) return { resource: matched, isNew: false };++ const encryptedConnectionDetails = await encryptResourceConnectionDetails({+ projectId,+ connectionDetails: {+ domain: configuration.domainFQDN,+ dcAddress: configuration.dcAddress,+ port: configuration.port+ } as TActiveDirectoryResourceConnectionDetails,+ kmsService+ });++ const resource = await pamResourceDAL.create({+ projectId,+ name: domainResourceName,+ resourceType: PamResource.ActiveDirectory,+ gatewayId,+ encryptedConnectionDetails+ });++ return { resource, isNew: true };+};++const upsertWindowsServerResource = async (+ projectId: string,+ computer: TLdapComputer,+ adServerResourceId: string,+ gatewayId: string,+ kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">,+ pamResourceDAL: Pick<TPamResourceDALFactory, "create" | "find">+) => {+ const hostname = computer.dNSHostName || computer.cn;+ const resourceName = toSlugName(hostname);++ const existing = await pamResourceDAL.find({+ projectId,+ resourceType: PamResource.Windows,+ name: resourceName+ });++ if (existing.length > 0) return { resource: existing[0], isNew: false };++ const encryptedConnectionDetails = await encryptResourceConnectionDetails({+ projectId,+ connectionDetails: {+ protocol: WindowsProtocol.RDP,+ hostname,+ port: 3389+ } as TWindowsResourceConnectionDetails,+ kmsService+ });++ const resource = await pamResourceDAL.create({+ projectId,+ name: resourceName,+ resourceType: PamResource.Windows,+ gatewayId,+ encryptedConnectionDetails,+ adServerResourceId+ });++ return { resource, isNew: true };+};++const upsertDomainAccount = async (+ projectId: string,+ user: TLdapUser,+ adServerResourceId: string,+ kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">,+ pamAccountDAL: Pick<TPamAccountDALFactory, "create" | "find">+) => {+ const accountName = user.sAMAccountName;+ const accountType = isServiceAccount(user) ? "service" : "user";++ const existing = await pamAccountDAL.find({+ resourceId: adServerResourceId,+ name: accountName+ });++ if (existing.length > 0) return { account: existing[0], isNew: false };++ const encryptedCredentials = await encryptAccountCredentials({+ projectId,+ credentials: {+ username: user.sAMAccountName,+ password: ""+ } as TActiveDirectoryAccountCredentials,+ kmsService+ });++ let servicePrincipalName: string[] | undefined;+ if (Array.isArray(user.servicePrincipalName)) {+ servicePrincipalName = user.servicePrincipalName;+ } else if (user.servicePrincipalName) {+ servicePrincipalName = [user.servicePrincipalName];+ }++ const metadata = {+ accountType,+ adGuid: user.objectGUID,+ displayName: user.displayName || undefined,+ userPrincipalName: user.userPrincipalName || undefined,+ servicePrincipalName,+ userAccountControl: user.userAccountControl ? parseInt(user.userAccountControl, 10) : undefined,+ pwdLastSet: user.pwdLastSet || undefined+ } as TActiveDirectoryAccountMetadata;++ const account = await pamAccountDAL.create({+ projectId,+ resourceId: adServerResourceId,+ name: accountName,+ encryptedCredentials,+ metadata+ });++ return { account, isNew: true };+};++export const activeDirectoryDiscoveryFactory: TPamDiscoveryFactory<+ TAdDiscoveryConfiguration,+ TAdDiscoveryCredentials+> = (_discoveryType, configuration, credentials, gatewayId, projectId, gatewayV2Service) => {+ const validateConnection = async () => {+ try {+ await executeWithGateway(+ { dcAddress: configuration.dcAddress, port: configuration.port, gatewayId },+ gatewayV2Service,+ async (proxyPort) => {+ return new Promise<void>((resolve, reject) => {+ const client = ldapjs.createClient({+ url: `ldap://localhost:${proxyPort}`,+ connectTimeout: LDAP_TIMEOUT,+ timeout: LDAP_TIMEOUT+ });++ client.on("error", (err: Error) => {+ client.unbind();+ reject(err);+ });++ const bindDn = `${credentials.username}@${configuration.domainFQDN}`;+ client.bind(bindDn, credentials.password, (err) => {+ if (err) {+ client.unbind();+ reject(new Error("LDAP bind failed: invalid credentials"));+ } else {+ client.unbind();+ resolve();+ }+ });+ });+ }+ );+ } catch (error) {+ throw new BadRequestError({+ message: `Unable to validate connection to Active Directory: ${(error as Error).message || String(error)}`+ });+ }+ };++ const scan = async (discoverySourceId: string, deps: TPamDiscoveryScanDeps) => {+ const {+ pamDiscoverySourceDAL,+ pamDiscoveryRunDAL,+ pamDiscoverySourceResourcesDAL,+ pamDiscoverySourceAccountsDAL,+ pamResourceDAL,+ pamAccountDAL,+ kmsService+ } = deps;++ // Create discovery run+ const run = await pamDiscoveryRunDAL.create({+ discoverySourceId,+ status: PamDiscoveryRunStatus.Running,+ triggeredBy: PamDiscoveryRunTrigger.Manual,+ startedAt: new Date(),+ progress: {+ adEnumeration: { status: "running" }+ } as TActiveDirectoryDiscoverySourceRunProgress+ });++ let adEnumerationSucceeded = false;+ let resourcesDiscovered = 0;+ let accountsDiscovered = 0;+ let newItems = 0;++ try {+ const { computers, users } = await executeLdapEnumeration(+ configuration,+ credentials,+ gatewayId,+ gatewayV2Service+ );++ adEnumerationSucceeded = true;++ await pamDiscoveryRunDAL.updateById(run.id, {+ progress: {+ adEnumeration: { status: "completed", completedAt: new Date().toISOString() },+ dependencyScan: { status: "skipped", reason: "WinRM scanning not yet implemented" }+ } as TActiveDirectoryDiscoverySourceRunProgress+ });++ // Auto-import AD Server resource+ const { resource: adServerResource, isNew: isAdServerNew } = await upsertAdServerResource(+ projectId,+ configuration,+ gatewayId,+ kmsService,+ pamResourceDAL+ );++ await pamDiscoverySourceResourcesDAL.upsertJunction({+ discoverySourceId,+ resourceId: adServerResource.id,+ lastDiscoveredRunId: run.id+ });+ resourcesDiscovered += 1;+ if (isAdServerNew) newItems += 1;++ // Auto-import Windows Server resources+ for await (const computer of computers) {+ try {+ const { resource, isNew } = await upsertWindowsServerResource(+ projectId,+ computer,+ adServerResource.id,+ gatewayId,+ kmsService,+ pamResourceDAL+ );++ await pamDiscoverySourceResourcesDAL.upsertJunction({+ discoverySourceId,+ resourceId: resource.id,+ lastDiscoveredRunId: run.id+ });++ resourcesDiscovered += 1;+ if (isNew) newItems += 1;+ } catch (err) {+ logger.warn({ err, computer: computer.dNSHostName }, "Failed to import Windows Server resource");+ }+ }++ // Auto-import domain accounts+ for await (const user of users) {+ try {+ const { account, isNew } = await upsertDomainAccount(+ projectId,+ user,+ adServerResource.id,+ kmsService,+ pamAccountDAL+ );++ await pamDiscoverySourceAccountsDAL.upsertJunction({+ discoverySourceId,+ accountId: account.id,+ lastDiscoveredRunId: run.id+ });++ accountsDiscovered += 1;+ if (isNew) newItems += 1;+ } catch (err) {+ logger.warn({ err, user: user.sAMAccountName }, "Failed to import domain account");+ }+ }++ if (adEnumerationSucceeded) {+ const staleResources = await pamDiscoverySourceResourcesDAL.markStaleForRun(discoverySourceId, run.id);+ const staleAccounts = await pamDiscoverySourceAccountsDAL.markStaleForRun(discoverySourceId, run.id);+ const staleSinceLastRun = (staleResources || 0) + (staleAccounts || 0);++ await pamDiscoveryRunDAL.updateById(run.id, {+ status: PamDiscoveryRunStatus.Completed,+ resourcesDiscovered,+ accountsDiscovered,+ dependenciesDiscovered: 0,+ newSinceLastRun: newItems,+ staleSinceLastRun,+ completedAt: new Date()+ });+ }++ await pamDiscoverySourceDAL.updateById(discoverySourceId, {+ lastRunAt: new Date()+ });+ } catch (error) {+ logger.error({ error, discoverySourceId, runId: run.id }, "PAM AD discovery scan failed");++ const progress: TActiveDirectoryDiscoverySourceRunProgress = adEnumerationSucceeded+ ? {+ adEnumeration: { status: "completed" },+ dependencyScan: { status: "failed", reason: (error as Error).message }+ }+ : {+ adEnumeration: { status: "failed", error: (error as Error).message }+ };++ await pamDiscoveryRunDAL.updateById(run.id, {+ status: PamDiscoveryRunStatus.Failed,+ progress,+ errorMessage: (error as Error).message,+ completedAt: new Date()+ });++ await pamDiscoverySourceDAL.updateById(discoverySourceId, {+ lastRunAt: new Date()+ });+ }+ };++ return {+ validateConnection,+ scan+ };+};diff --git a/backend/src/ee/services/pam-discovery/active-directory/active-directory-discovery-schemas.ts b/backend/src/ee/services/pam-discovery/active-directory/active-directory-discovery-schemas.tsindex 3531ffbd57..d45dc65f25 100644--- a/backend/src/ee/services/pam-discovery/active-directory/active-directory-discovery-schemas.ts+++ b/backend/src/ee/services/pam-discovery/active-directory/active-directory-discovery-schemas.ts@@ -52,12 +52,11 @@ export const UpdateActiveDirectoryDiscoverySourceSchema = BaseUpdatePamDiscovery});// Discovery Run-const ActiveDirectoryDiscoverySourceRunProgressSchema = z.object({- // TODO(andrey): Revisit this schema+export const ActiveDirectoryDiscoverySourceRunProgressSchema = z.object({adEnumeration: z.object({status: z.enum(["running", "completed", "failed"]),- completedAt: z.date().optional(),+ completedAt: z.string().optional(),error: z.string().optional()}).optional(),diff --git a/backend/src/ee/services/pam-discovery/active-directory/active-directory-discovery-types.ts b/backend/src/ee/services/pam-discovery/active-directory/active-directory-discovery-types.tsindex 6794315a65..3a0b820510 100644--- a/backend/src/ee/services/pam-discovery/active-directory/active-directory-discovery-types.ts+++ b/backend/src/ee/services/pam-discovery/active-directory/active-directory-discovery-types.ts@@ -3,9 +3,13 @@ import { z } from "zod";import {ActiveDirectoryDiscoveryConfigurationSchema,ActiveDirectoryDiscoveryCredentialsSchema,+ ActiveDirectoryDiscoverySourceRunProgressSchema,ActiveDirectoryDiscoverySourceSchema} from "./active-directory-discovery-schemas";export type TActiveDirectoryDiscoverySource = z.infer<typeof ActiveDirectoryDiscoverySourceSchema>;export type TActiveDirectoryDiscoveryCredentials = z.infer<typeof ActiveDirectoryDiscoveryCredentialsSchema>;export type TActiveDirectoryDiscoveryConfiguration = z.infer<typeof ActiveDirectoryDiscoveryConfigurationSchema>;+export type TActiveDirectoryDiscoverySourceRunProgress = z.infer<+ typeof ActiveDirectoryDiscoverySourceRunProgressSchema+>;diff --git a/backend/src/ee/services/pam-discovery/pam-discovery-enums.ts b/backend/src/ee/services/pam-discovery/pam-discovery-enums.tsindex 6545376a6c..6fbdd2a302 100644--- a/backend/src/ee/services/pam-discovery/pam-discovery-enums.ts+++ b/backend/src/ee/services/pam-discovery/pam-discovery-enums.ts@@ -21,12 +21,9 @@ export enum PamDiscoveryOrderBy {// Discovery Runsexport enum PamDiscoveryRunStatus {- Pending = "pending",Running = "running",Completed = "completed",- CompletedWithErrors = "completed_with_errors",- Failed = "failed",- Stopped = "stopped"+ Failed = "failed"}export enum PamDiscoveryRunTrigger {diff --git a/backend/src/ee/services/pam-discovery/pam-discovery-source-accounts-dal.ts b/backend/src/ee/services/pam-discovery/pam-discovery-source-accounts-dal.tsindex 3f44197d23..1fddc46999 100644--- a/backend/src/ee/services/pam-discovery/pam-discovery-source-accounts-dal.ts+++ b/backend/src/ee/services/pam-discovery/pam-discovery-source-accounts-dal.ts@@ -27,7 +27,7 @@ export const pamDiscoverySourceAccountsDALFactory = (db: TDbClient) => {const countQuery = query.clone().count("*", { as: "count" }).first();void query.select(- selectAllTableCols(TableName.PamDiscoverySourceResource),+ selectAllTableCols(TableName.PamDiscoverySourceAccount),db.ref("name").withSchema(TableName.PamAccount).as("accountName"),db.ref("resourceId").withSchema(TableName.PamAccount).as("resourceId"),db.ref("resourceType").withSchema(TableName.PamResource).as("resourceType"),@@ -88,6 +88,20 @@ export const pamDiscoverySourceAccountsDALFactory = (db: TDbClient) => {}};+ const countByDiscoverySourceIds = async (discoverySourceIds: string[], tx?: Knex) => {+ try {+ const rows = await (tx || db.replicaNode())(TableName.PamDiscoverySourceAccount)+ .whereIn("discoverySourceId", discoverySourceIds)+ .groupBy("discoverySourceId")+ .select("discoverySourceId")+ .count("*", { as: "count" });++ return Object.fromEntries(rows.map((r) => [r.discoverySourceId, Number(r.count)]));+ } catch (error) {+ throw new DatabaseError({ error, name: "Count PAM discovery source accounts by source IDs" });+ }+ };+const markStaleForRun = async (discoverySourceId: string, runId: string, tx?: Knex) => {try {const knex = tx || db;@@ -109,6 +123,7 @@ export const pamDiscoverySourceAccountsDALFactory = (db: TDbClient) => {return {...orm,findByDiscoverySourceIdWithAccounts,+ countByDiscoverySourceIds,upsertJunction,markStaleForRun};diff --git a/backend/src/ee/services/pam-discovery/pam-discovery-source-dal.ts b/backend/src/ee/services/pam-discovery/pam-discovery-source-dal.tsindex 802c46a05c..96076e1806 100644--- a/backend/src/ee/services/pam-discovery/pam-discovery-source-dal.ts+++ b/backend/src/ee/services/pam-discovery/pam-discovery-source-dal.ts@@ -102,7 +102,7 @@ export const pamDiscoverySourceDALFactory = (db: TDbClient) => {(tx || db.replicaNode())(TableName.PamDiscoveryRun).select(db.raw("1")).whereRaw(`"discoverySourceId" = ${TableName.PamDiscoverySource}."id"`)- .whereIn("status", [PamDiscoveryRunStatus.Pending, PamDiscoveryRunStatus.Running])+ .where("status", PamDiscoveryRunStatus.Running));return docs as TPamDiscoverySources[];diff --git a/backend/src/ee/services/pam-discovery/pam-discovery-source-resources-dal.ts b/backend/src/ee/services/pam-discovery/pam-discovery-source-resources-dal.tsindex 5becc95379..83488fb8d5 100644--- a/backend/src/ee/services/pam-discovery/pam-discovery-source-resources-dal.ts+++ b/backend/src/ee/services/pam-discovery/pam-discovery-source-resources-dal.ts@@ -88,6 +88,20 @@ export const pamDiscoverySourceResourcesDALFactory = (db: TDbClient) => {}};+ const countByDiscoverySourceIds = async (discoverySourceIds: string[], tx?: Knex) => {+ try {+ const rows = await (tx || db.replicaNode())(TableName.PamDiscoverySourceResource)+ .whereIn("discoverySourceId", discoverySourceIds)+ .groupBy("discoverySourceId")+ .select("discoverySourceId")+ .count("*", { as: "count" });++ return Object.fromEntries(rows.map((r) => [r.discoverySourceId, Number(r.count)]));+ } catch (error) {+ throw new DatabaseError({ error, name: "Count PAM discovery source resources by source IDs" });+ }+ };+const markStaleForRun = async (discoverySourceId: string, runId: string, tx?: Knex) => {try {const knex = tx || db;@@ -109,6 +123,7 @@ export const pamDiscoverySourceResourcesDALFactory = (db: TDbClient) => {return {...orm,findByDiscoverySourceIdWithResources,+ countByDiscoverySourceIds,upsertJunction,markStaleForRun};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 d9a062b0d4..510c7d64a5 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@@ -47,8 +47,14 @@ type TPamDiscoverySourceServiceFactoryDep = {TPamDiscoveryRunDALFactory,"findByDiscoverySourceId" | "findLatestBySourceId" | "findById" | "find">;- pamDiscoverySourceResourcesDAL: Pick<TPamDiscoverySourceResourcesDALFactory, "findByDiscoverySourceIdWithResources">;- pamDiscoverySourceAccountsDAL: Pick<TPamDiscoverySourceAccountsDALFactory, "findByDiscoverySourceIdWithAccounts">;+ pamDiscoverySourceResourcesDAL: Pick<+ TPamDiscoverySourceResourcesDALFactory,+ "findByDiscoverySourceIdWithResources" | "countByDiscoverySourceIds"+ >;+ pamDiscoverySourceAccountsDAL: Pick<+ TPamDiscoverySourceAccountsDALFactory,+ "findByDiscoverySourceIdWithAccounts" | "countByDiscoverySourceIds"+ >;permissionService: Pick<TPermissionServiceFactory, "getProjectPermission">;kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;gatewayV2DAL: Pick<TGatewayV2DALFactory, "findOne">;@@ -349,8 +355,21 @@ export const pamDiscoverySourceServiceFactory = ({filterDiscoveryTypes});+ const sourceIds = sources.map((s) => s.id);++ const [resourceCounts, accountCounts]: { [k: string]: number }[] = await Promise.all([+ sourceIds.length ? pamDiscoverySourceResourcesDAL.countByDiscoverySourceIds(sourceIds) : {},+ sourceIds.length ? pamDiscoverySourceAccountsDAL.countByDiscoverySourceIds(sourceIds) : {}+ ]);+return {- sources: await Promise.all(sources.map((src) => decryptDiscoverySource(src, projectId, kmsService))),+ sources: await Promise.all(+ sources.map(async (src) => ({+ ...(await decryptDiscoverySource(src, projectId, kmsService)),+ totalResources: resourceCounts[src.id] ?? 0,+ totalAccounts: accountCounts[src.id] ?? 0+ }))+ ),totalCount};};@@ -381,10 +400,7 @@ export const pamDiscoverySourceServiceFactory = ({// Check if a scan is already runningconst latestRun = await pamDiscoveryRunDAL.findLatestBySourceId(id);- if (- latestRun &&- (latestRun.status === PamDiscoveryRunStatus.Pending || latestRun.status === PamDiscoveryRunStatus.Running)- ) {+ if (latestRun && latestRun.status === PamDiscoveryRunStatus.Running) {throw new BadRequestError({ message: "A scan is already in progress for this Discovery Source" });}diff --git a/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-schemas.ts b/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-schemas.tsindex 7b29e9b5de..0471d98e5f 100644--- a/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-schemas.ts+++ b/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-schemas.ts@@ -36,7 +36,13 @@ export const ActiveDirectoryAccountCredentialsSchema = z.object({// Account metadataexport const ActiveDirectoryAccountMetadataSchema = z.object({- accountType: z.nativeEnum(ActiveDirectoryAccountType)+ accountType: z.nativeEnum(ActiveDirectoryAccountType),+ adGuid: z.string().optional(),+ displayName: z.string().optional(),+ userPrincipalName: z.string().optional(),+ servicePrincipalName: z.string().array().optional(),+ userAccountControl: z.number().optional(),+ pwdLastSet: z.string().optional()});export const ActiveDirectoryResourceSchema = BaseActiveDirectoryResourceSchema.extend({diff --git a/frontend/src/hooks/api/pamDiscovery/types.ts b/frontend/src/hooks/api/pamDiscovery/types.tsindex 21669362f6..b3fbb9ef0d 100644--- a/frontend/src/hooks/api/pamDiscovery/types.ts+++ b/frontend/src/hooks/api/pamDiscovery/types.ts@@ -21,12 +21,29 @@ export type TPamDiscoverySource = {discoveryCredentials?: Record<string, unknown>;schedule?: string | null;lastRunAt?: string | null;- nextRunAt?: string | null;status: string;+ totalResources: number;+ totalAccounts: number;createdAt: string;updatedAt: string;};+export type TPamDiscoveryRunProgress = {+ adEnumeration?: {+ status: "running" | "completed" | "failed";+ completedAt?: string;+ error?: string;+ };+ dependencyScan?: {+ status: "running" | "completed" | "failed" | "skipped";+ totalMachines?: number;+ scannedMachines?: number;+ failedMachines?: number;+ reason?: string;+ };+ machineErrors?: Record<string, string>;+};+export type TPamDiscoveryRun = {id: string;discoverySourceId: string;@@ -37,7 +54,7 @@ export type TPamDiscoveryRun = {dependenciesDiscovered: number;newSinceLastRun: number;staleSinceLastRun: number;- progress?: unknown;+ progress?: TPamDiscoveryRunProgress;errorMessage?: string | null;startedAt?: string | null;completedAt?: string | null;@@ -61,6 +78,7 @@ export type TDiscoveredAccount = {accountName: string;resourceId: string;resourceName: string;+ resourceType: string;lastDiscoveredAt: string;isStale: boolean;metadata?: unknown;diff --git a/frontend/src/pages/pam/PamDiscoveryDetailPage/PamDiscoveryDetailPage.tsx b/frontend/src/pages/pam/PamDiscoveryDetailPage/PamDiscoveryDetailPage.tsxindex acd1a5267d..7080195770 100644--- a/frontend/src/pages/pam/PamDiscoveryDetailPage/PamDiscoveryDetailPage.tsx+++ b/frontend/src/pages/pam/PamDiscoveryDetailPage/PamDiscoveryDetailPage.tsx@@ -5,7 +5,15 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";import { useQuery } from "@tanstack/react-query";import { useNavigate, useParams } from "@tanstack/react-router";import { format } from "date-fns";-import { BanIcon, EllipsisVerticalIcon, PencilIcon, PlayIcon, TrashIcon } from "lucide-react";+import {+ BanIcon,+ ChevronDownIcon,+ ChevronRightIcon,+ EllipsisVerticalIcon,+ PencilIcon,+ PlayIcon,+ TrashIcon+} from "lucide-react";import { createNotification } from "@app/components/notifications";import { ProjectPermissionCan } from "@app/components/permissions";@@ -37,7 +45,11 @@ import { ProjectPermissionSub, useOrganization } from "@app/context";import { ProjectPermissionPamDiscoveryActions } from "@app/context/ProjectPermissionContext/types";import { usePagination } from "@app/hooks";import { gatewaysQueryKeys } from "@app/hooks/api";-import type { PamDiscoveryType, TPamDiscoverySource } from "@app/hooks/api/pamDiscovery";+import type {+ PamDiscoveryType,+ TPamDiscoveryRunProgress,+ TPamDiscoverySource+} from "@app/hooks/api/pamDiscovery";import {PAM_DISCOVERY_TYPE_MAP,useDeletePamDiscoverySource,@@ -197,6 +209,99 @@ const DiscoveryCredentialsSection = ({);};+const formatDuration = (startedAt?: string | null, completedAt?: string | null): string => {+ if (!startedAt) return "-";+ const end = completedAt ? new Date(completedAt) : new Date();+ const seconds = Math.floor((end.getTime() - new Date(startedAt).getTime()) / 1000);+ if (seconds < 60) return `${seconds}s`;+ const mins = Math.floor(seconds / 60);+ const secs = seconds % 60;+ return secs > 0 ? `${mins}m ${secs}s` : `${mins}m`;+};++const PROGRESS_BADGE_MAP: Record<string, "success" | "danger" | "info" | "neutral"> = {+ completed: "success",+ failed: "danger",+ running: "info",+ skipped: "neutral"+};++const RunExpandedContent = ({+ progress,+ errorMessage+}: {+ progress?: TPamDiscoveryRunProgress;+ errorMessage?: string | null;+}) => {+ const adEnum = progress?.adEnumeration;+ const depScan = progress?.dependencyScan;+ const machineErrors = progress?.machineErrors;+ const hasMachineErrors = machineErrors && Object.keys(machineErrors).length > 0;++ return (+ <div className="flex flex-col gap-4 px-8 py-4">+ <div className="flex gap-10">+ {adEnum && (+ <div className="flex flex-col gap-1.5">+ <span className="text-xs font-medium tracking-wider text-muted uppercase">+ AD Enumeration+ </span>+ <Badge variant={PROGRESS_BADGE_MAP[adEnum.status] || "info"}>{adEnum.status}</Badge>+ {adEnum.error && adEnum.error !== errorMessage && (+ <span className="text-xs text-red-400">{adEnum.error}</span>+ )}+ </div>+ )}+ {depScan && (+ <div className="flex flex-col gap-1.5">+ <span className="text-xs font-medium tracking-wider text-muted uppercase">+ Dependency Scan+ </span>+ <Badge variant={PROGRESS_BADGE_MAP[depScan.status] || "info"}>{depScan.status}</Badge>+ {depScan.totalMachines !== undefined && (+ <span className="text-xs text-muted">+ {depScan.scannedMachines ?? 0}/{depScan.totalMachines} machines+ {(depScan.failedMachines ?? 0) > 0 && (+ <span className="ml-1 text-red-400">({depScan.failedMachines} failed)</span>+ )}+ </span>+ )}+ {depScan.reason && depScan.reason !== errorMessage && (+ <span className="text-xs text-muted">{depScan.reason}</span>+ )}+ </div>+ )}+ </div>+ {errorMessage && (+ <div className="flex flex-col gap-1.5">+ <span className="text-xs font-medium tracking-wider text-muted uppercase">Error</span>+ <span className="rounded border border-red-500/30 bg-red-500/10 px-3 py-2 font-mono text-xs text-red-400">+ {errorMessage}+ </span>+ </div>+ )}+ {hasMachineErrors && (+ <div className="flex flex-col gap-1.5">+ <span className="text-xs font-medium tracking-wider text-muted uppercase">+ Machine Errors+ </span>+ <div className="flex flex-col gap-1">+ {Object.entries(machineErrors).map(([host, err]) => (+ <div+ key={host}+ className="rounded border border-red-500/30 bg-red-500/10 px-3 py-2 font-mono text-xs"+ >+ <span className="font-semibold text-foreground">{host}</span>+ <span className="ml-2 text-muted">{err}</span>+ </div>+ ))}+ </div>+ </div>+ )}+ </div>+ );+};+const RunsTab = ({discoverySourceId,discoveryType@@ -204,6 +309,7 @@ const RunsTab = ({discoverySourceId: string;discoveryType: PamDiscoveryType;}) => {+ const [expandedRunId, setExpandedRunId] = useState<string | null>(null);const { page, perPage, setPage, setPerPage, offset } = usePagination("", {initPerPage: 20});@@ -215,16 +321,18 @@ const RunsTab = ({const runs = data?.runs || [];const totalCount = data?.totalCount || 0;+ const COL_COUNT = 9;return (<div><UnstableTable><UnstableTableHeader><UnstableTableRow>- <UnstableTableHead>Status</UnstableTableHead>- <UnstableTableHead>Triggered By</UnstableTableHead>+ <UnstableTableHead className="w-8" /><UnstableTableHead>Started</UnstableTableHead>- <UnstableTableHead>Completed</UnstableTableHead>+ <UnstableTableHead>Duration</UnstableTableHead>+ <UnstableTableHead>Triggered By</UnstableTableHead>+ <UnstableTableHead>Status</UnstableTableHead><UnstableTableHead>Resources</UnstableTableHead><UnstableTableHead>Accounts</UnstableTableHead><UnstableTableHead>New</UnstableTableHead>@@ -234,14 +342,14 @@ const RunsTab = ({<UnstableTableBody>{isPending && (<UnstableTableRow>- <UnstableTableCell colSpan={8} className="text-center text-muted">+ <UnstableTableCell colSpan={COL_COUNT} className="text-center text-muted">Loading runs...</UnstableTableCell></UnstableTableRow>)}{!isPending && runs.length === 0 && (<UnstableTableRow>- <UnstableTableCell colSpan={8}>+ <UnstableTableCell colSpan={COL_COUNT}><UnstableEmpty className="border-0 bg-transparent py-8 shadow-none"><UnstableEmptyHeader><UnstableEmptyTitle>No discovery runs yet</UnstableEmptyTitle>@@ -251,24 +359,63 @@ const RunsTab = ({</UnstableTableRow>)}{!isPending &&- runs.map((run) => (- <UnstableTableRow key={run.id}>- <UnstableTableCell>- <Badge variant={STATUS_BADGE_MAP[run.status] || "info"}>{run.status}</Badge>- </UnstableTableCell>- <UnstableTableCell className="text-muted">{run.triggeredBy}</UnstableTableCell>- <UnstableTableCell className="text-muted">- {run.startedAt ? format(new Date(run.startedAt), "MMM d, yyyy HH:mm") : "-"}- </UnstableTableCell>- <UnstableTableCell className="text-muted">- {run.completedAt ? format(new Date(run.completedAt), "MMM d, yyyy HH:mm") : "-"}- </UnstableTableCell>- <UnstableTableCell>{run.resourcesDiscovered}</UnstableTableCell>- <UnstableTableCell>{run.accountsDiscovered}</UnstableTableCell>- <UnstableTableCell>{run.newSinceLastRun}</UnstableTableCell>- <UnstableTableCell>{run.staleSinceLastRun}</UnstableTableCell>- </UnstableTableRow>- ))}+ runs.map((run) => {+ const isExpanded = expandedRunId === run.id;+ const hasDetails =+ run.progress?.adEnumeration ||+ run.progress?.dependencyScan ||+ run.errorMessage ||+ (run.progress?.machineErrors && Object.keys(run.progress.machineErrors).length > 0);++ return (+ <>+ <UnstableTableRow+ key={run.id}+ className={hasDetails ? "cursor-pointer" : undefined}+ onClick={+ hasDetails ? () => setExpandedRunId(isExpanded ? null : run.id) : undefined+ }+ >+ <UnstableTableCell>+ {hasDetails &&+ (isExpanded ? (+ <ChevronDownIcon className="size-4 text-muted" />+ ) : (+ <ChevronRightIcon className="size-4 text-muted" />+ ))}+ </UnstableTableCell>+ <UnstableTableCell className="text-muted">+ {run.startedAt ? format(new Date(run.startedAt), "MMM d, yyyy hh:mm a") : "-"}+ </UnstableTableCell>+ <UnstableTableCell className="text-muted">+ {formatDuration(run.startedAt, run.completedAt)}+ </UnstableTableCell>+ <UnstableTableCell className="text-muted capitalize">+ {run.triggeredBy}+ </UnstableTableCell>+ <UnstableTableCell>+ <Badge variant={STATUS_BADGE_MAP[run.status] || "info"}>{run.status}</Badge>+ </UnstableTableCell>+ <UnstableTableCell>{run.resourcesDiscovered}</UnstableTableCell>+ <UnstableTableCell>{run.accountsDiscovered}</UnstableTableCell>+ <UnstableTableCell className="text-green-400">+ {run.newSinceLastRun > 0 ? `+${run.newSinceLastRun}` : run.newSinceLastRun}+ </UnstableTableCell>+ <UnstableTableCell>{run.staleSinceLastRun}</UnstableTableCell>+ </UnstableTableRow>+ {isExpanded && (+ <UnstableTableRow key={`${run.id}-expanded`}>+ <UnstableTableCell colSpan={COL_COUNT} className="p-0">+ <RunExpandedContent+ progress={run.progress}+ errorMessage={run.errorMessage}+ />+ </UnstableTableCell>+ </UnstableTableRow>+ )}+ </>+ );+ })}</UnstableTableBody></UnstableTable>{Boolean(totalCount) && !isPending && (@@ -286,11 +433,15 @@ const RunsTab = ({const ResourcesTab = ({discoverySourceId,- discoveryType+ discoveryType,+ projectId}: {discoverySourceId: string;discoveryType: PamDiscoveryType;+ projectId: string;}) => {+ const navigate = useNavigate();+ const { currentOrg } = useOrganization();const { page, perPage, setPage, setPerPage, offset } = usePagination("", {initPerPage: 20});@@ -335,7 +486,21 @@ const ResourcesTab = ({)}{!isPending &&resources.map((resource) => (- <UnstableTableRow key={resource.id}>+ <UnstableTableRow+ key={resource.id}+ className="cursor-pointer"+ onClick={() =>+ navigate({+ to: "/organizations/$orgId/projects/pam/$projectId/resources/$resourceType/$resourceId",+ params: {+ orgId: currentOrg.id,+ projectId,+ resourceType: resource.resourceType,+ resourceId: resource.resourceId+ }+ })+ }+ ><UnstableTableCell className="font-medium">{resource.resourceName}</UnstableTableCell>@@ -371,11 +536,15 @@ const ResourcesTab = ({const AccountsTab = ({discoverySourceId,- discoveryType+ discoveryType,+ projectId}: {discoverySourceId: string;discoveryType: PamDiscoveryType;+ projectId: string;}) => {+ const navigate = useNavigate();+ const { currentOrg } = useOrganization();const { page, perPage, setPage, setPerPage, offset } = usePagination("", {initPerPage: 20});@@ -420,7 +589,22 @@ const AccountsTab = ({)}{!isPending &&accounts.map((account) => (- <UnstableTableRow key={account.id}>+ <UnstableTableRow+ key={account.id}+ className="cursor-pointer"+ onClick={() =>+ navigate({+ to: "/organizations/$orgId/projects/pam/$projectId/resources/$resourceType/$resourceId/accounts/$accountId",+ params: {+ orgId: currentOrg.id,+ projectId,+ resourceType: account.resourceType,+ resourceId: account.resourceId,+ accountId: account.accountId+ }+ })+ }+ ><UnstableTableCell className="font-medium">{account.accountName}</UnstableTableCell><UnstableTableCell className="text-muted">{account.resourceName}</UnstableTableCell><UnstableTableCell className="text-muted">@@ -631,10 +815,18 @@ const PageContent = () => {<RunsTab discoverySourceId={source.id} discoveryType={source.discoveryType} /></TabPanel><TabPanel value="resources">- <ResourcesTab discoverySourceId={source.id} discoveryType={source.discoveryType} />+ <ResourcesTab+ discoverySourceId={source.id}+ discoveryType={source.discoveryType}+ projectId={projectId!}+ /></TabPanel><TabPanel value="accounts">- <AccountsTab discoverySourceId={source.id} discoveryType={source.discoveryType} />+ <AccountsTab+ discoverySourceId={source.id}+ discoveryType={source.discoveryType}+ projectId={projectId!}+ /></TabPanel></Tabs></div>diff --git a/frontend/src/pages/pam/PamDiscoveryPage/components/PamDiscoverySourcesTable.tsx b/frontend/src/pages/pam/PamDiscoveryPage/components/PamDiscoverySourcesTable.tsxindex dabf8772b5..006da56f6b 100644--- a/frontend/src/pages/pam/PamDiscoveryPage/components/PamDiscoverySourcesTable.tsx+++ b/frontend/src/pages/pam/PamDiscoveryPage/components/PamDiscoverySourcesTable.tsx@@ -137,6 +137,9 @@ export const PamDiscoverySourcesTable = ({ projectId }: Props) => {<UnstableTableRow><UnstableTableHead>Name</UnstableTableHead><UnstableTableHead>Domain</UnstableTableHead>+ <UnstableTableHead>Schedule</UnstableTableHead>+ <UnstableTableHead>Resources</UnstableTableHead>+ <UnstableTableHead>Accounts</UnstableTableHead><UnstableTableHead>Status</UnstableTableHead><UnstableTableHead>Last Run</UnstableTableHead><UnstableTableHead className="w-5" />@@ -145,14 +148,14 @@ export const PamDiscoverySourcesTable = ({ projectId }: Props) => {<UnstableTableBody>{isPending && (<UnstableTableRow>- <UnstableTableCell colSpan={5} className="text-center text-muted">+ <UnstableTableCell colSpan={8} className="text-center text-muted">Loading discovery sources...</UnstableTableCell></UnstableTableRow>)}{!isPending && sources.length === 0 && (<UnstableTableRow>- <UnstableTableCell colSpan={5}>+ <UnstableTableCell colSpan={8}><UnstableEmpty className="border-0 bg-transparent py-8 shadow-none"><UnstableEmptyHeader><UnstableEmptyTitle>@@ -184,6 +187,15 @@ export const PamDiscoverySourcesTable = ({ projectId }: Props) => {<UnstableTableCell className="text-muted">{(source.discoveryConfiguration?.domainFQDN as string) || "-"}</UnstableTableCell>+ <UnstableTableCell className="text-muted capitalize">+ {source.schedule ?? "-"}+ </UnstableTableCell>+ <UnstableTableCell className="text-muted">+ {source.totalResources}+ </UnstableTableCell>+ <UnstableTableCell className="text-muted">+ {source.totalAccounts}+ </UnstableTableCell><UnstableTableCell><Badge variant={STATUS_BADGE_MAP[source.status] || "info"}>{source.status}