Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

chore(pam): condense comments and fix prettier wrapping

bernie-g6453dd57adeb
diff --git a/backend/src/db/migrations/20260720183403_pam-account-dependencies-rework.ts b/backend/src/db/migrations/20260720183403_pam-account-dependencies-rework.ts
index 4275a25f60..9b94ee47bc 100644
--- a/backend/src/db/migrations/20260720183403_pam-account-dependencies-rework.ts
+++ b/backend/src/db/migrations/20260720183403_pam-account-dependencies-rework.ts
@@ -3,10 +3,8 @@ import { Knex } from "knex";
import { TableName } from "../schemas";
import { createOnUpdateTrigger, dropOnUpdateTrigger } from "../utils";
-// Reworks the orphaned pre-revamp pam_account_dependencies table (which pointed at the legacy
-// pam_resources table) into a dependency table keyed off the revamp account model: a dependency is
-// anchored to its run-as identity (fingerprint) and points at either the staged discovered account
-// (discoveredAccountId, while its account is only staged) or the imported managed account (accountId).
+// Reworks the orphaned pre-revamp pam_account_dependencies table onto the revamp account model: each dependency
+// is anchored to its run-as identity (fingerprint) and points at the staged discovered or imported account.
export async function up(knex: Knex): Promise<void> {
await knex.schema.dropTableIfExists(TableName.PamAccountDependency);
@@ -52,9 +50,8 @@ export async function up(knex: Knex): Promise<void> {
await createOnUpdateTrigger(knex, TableName.PamAccountDependency);
- // The discovery run summary reports dependency counts alongside account counts. The runs table already
- // exists (created by the prior pam-discovery migration), so add the columns here, nullable, so a scan that
- // did not run dependency discovery leaves them null and the summary can omit the dependencies clause.
+ // Dependency counts on the existing runs table, nullable so a scan that ran no dependency discovery leaves
+ // them null and the summary omits the dependencies clause.
if (!(await knex.schema.hasColumn(TableName.PamDiscoverySourceRun, "dependencyCount"))) {
await knex.schema.alterTable(TableName.PamDiscoverySourceRun, (t) => {
t.integer("dependencyCount");
diff --git a/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.test.ts b/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.test.ts
index 18e1abde75..989b26c31d 100644
--- a/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.test.ts
+++ b/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.test.ts
@@ -157,9 +157,8 @@ describe("rotateScheduledAccount recovery probe", () => {
});
test("discards a pending credential whose probe throws once the current credential proves reachability", async () => {
- // Self-rotation verify throws on a wrong password just as on a transport blip. A stale pending (left by an
- // apply that failed its policy check) must not defer forever: a working current credential proves the target
- // is reachable, so the pending is a real rejection and can be discarded.
+ // Verify throws on a wrong password just as on a transport blip, so a working current credential proves
+ // reachability: the pending throw is then a real rejection and can be discarded, not deferred forever.
const { service, applyPasswordChange, updateById } = buildService((password) => {
if (password === PENDING_PASSWORD) throw new Error("winrm auth rejected");
return true;
diff --git a/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.ts b/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.ts
index 24db9b3ee2..e23d50086f 100644
--- a/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.ts
+++ b/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.ts
@@ -184,9 +184,8 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServic
gatewayPoolId?: string | null;
};
- // postRotate: push the new password into every service / scheduled task / IIS app pool that runs as the
- // account, connecting to each dependency's machine as the (delegated admin) rotator. Best-effort: a per-
- // dependency failure is recorded on the row and never fails the account rotation.
+ // postRotate: push the new password into every dependency, connecting as the rotator. Best-effort: a
+ // per-dependency failure is recorded on the row and never fails the account rotation.
const syncDependenciesAfterRotation = async ({
accountId,
projectId,
@@ -307,9 +306,8 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServic
throw new BadRequestError({ message: `Rotation account is no longer ${detail} this account` });
};
- // A stable key for the directory/host identity an account authenticates as, so two PAM objects that resolve to
- // the same underlying credential can be detected. Domain accounts key on domain (a DC is just a replica), local
- // Windows on host, SQL on host+port; all on the bare account name. Returns null when the type isn't rotatable.
+ // Stable key for the identity an account authenticates as, to detect two PAM objects on the same credential:
+ // domain accounts on domain, local Windows on host, SQL on host+port, all on the bare name. Null if not rotatable.
const identityKey = (accountType: PamAccountType, conn: Record<string, unknown>, username: string): string | null => {
const user = bareUsername(username);
if (accountType === PamAccountType.WindowsAd) {
@@ -331,11 +329,8 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServic
return null;
};
- // Other managed accounts that authenticate as this same identity, so the UI can warn that rotating this account
- // changes their shared password too (they hold their own copy and won't be updated automatically). Each is
- // annotated with any discovery sources that use it as their credential, since that is the concrete blast
- // radius. Covers the same AD object (identical discovery fingerprint) and accounts referenced as a discovery
- // credential — the two collisions seen in practice.
+ // Other managed accounts on this same identity (same AD object, or a discovery-source credential), so the UI
+ // can warn that rotating changes their shared password too. Each is annotated with the sources that use it.
const getSharedIdentityReferences = async (
account: TPamAccountDetail,
projectId: string,
@@ -387,7 +382,9 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServic
string,
{ id: string; name: string; folderId?: string | null; discoverySources: string[] }
>();
- siblings.forEach((s) => byAccount.set(s.id, { id: s.id, name: s.name, folderId: s.folderId, discoverySources: [] }));
+ siblings.forEach((s) =>
+ byAccount.set(s.id, { id: s.id, name: s.name, folderId: s.folderId, discoverySources: [] })
+ );
sourceMatches.forEach((m) => {
const existing = byAccount.get(m.accountId);
if (existing) existing.discoverySources.push(m.sourceName);
@@ -400,9 +397,8 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServic
});
});
- // Only surface what the caller may already see: an account they can read, and discovery-source names only if
- // they can view sources (PAM Admin) — otherwise this warning would leak names of resources behind folder or
- // product authorization the caller doesn't hold.
+ // Only surface what the caller may already see: accounts they can read, and source names only for a PAM
+ // Admin, so the warning can't leak resources behind folder or product authorization they don't hold.
const { hasRole } = await verifyProductMembership(permissionService, projectId, ctx);
const canViewSources = hasRole(PamProductRole.Admin);
const visible = await Promise.all(
@@ -516,9 +512,8 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServic
// definitive answer so a transient failure never discards a possibly-live credential.
if (account.encryptedPendingCredentials) {
const pending = await decryptSqlCredentials(projectId, accountType, account.encryptedPendingCredentials);
- // Verify connects to the target/DC through the gateway that can reach it — the rotator's, not the target
- // account's. A delegated target often carries no gateway of its own (its rotator/source holds it); for a
- // self-rotating account the two are the same, so this is always correct.
+ // Verify uses the rotator's gateway, not the target's: a delegated target often has no gateway of its own
+ // (self-rotation makes them the same).
const gatewayTarget = {
accountType,
connectionDetails,
@@ -544,12 +539,8 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServic
return null;
}
- // Pending did not authenticate. Probe the current credential too: besides detecting an interrupted
- // rotation, a *successful* current probe proves the target is reachable, which tells a dead pending apart
- // from a transient failure. This matters because self-rotation verify throws on a wrong password exactly
- // as it does on a transport blip, so a stale pending (e.g. left by an apply that failed its policy check)
- // would otherwise defer every future rotation forever. Without proof of reachability we still defer, so a
- // real blip never discards a possibly-live pending.
+ // Pending did not authenticate. A successful current-credential probe proves the target is reachable,
+ // telling a dead pending from a transport blip; without that proof we defer rather than discard pending.
const currentPassword = targetCredentials.password;
let currentWorks = false;
if (currentPassword) {
@@ -581,9 +572,8 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServic
// Stage before applying, so an apply interrupted mid-change leaves a credential the recovery probe can promote.
await pamAccountDAL.updateById(account.id, { encryptedPendingCredentials: encryptedPending });
- // Do NOT discard pending on an apply error: a WinRM/gateway apply can succeed on the host after the client
- // deadline fires, and for a self-rotating account pending is the only copy of the now-live password. The
- // recovery probe resolves genuine-failure vs ambiguous-success on the next run.
+ // Do NOT discard pending on an apply error: an apply can succeed on the host after the client deadline, and
+ // for self-rotation pending is the only copy of the now-live password. The recovery probe resolves it next run.
await handler.applyPasswordChange(
{
accountType,
@@ -605,8 +595,8 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServic
connectionDetails,
auth: { username: targetUsername, password: newPassword },
verifyVia,
- // Reach the target through the rotator's gateway (the one that just applied the change), not the target
- // account's — a delegated target often has no gateway of its own.
+ // Reach the target through the rotator's gateway (the one that just applied the change), not the
+ // target's; a delegated target often has no gateway of its own.
gatewayId: rotatorGatewayId,
gatewayPoolId: rotatorGatewayPoolId
},
@@ -619,9 +609,8 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServic
err instanceof Error ? err.message : String(err)
}]`
);
- // Applied, but verification couldn't complete after retries (transient gateway/network error). The new
- // password is already staged as pending; keep it so the recovery probe promotes it on the next run. A
- // one-off tunnel blip must never leave the account failed with a live-but-unrecorded password.
+ // Applied, but verification couldn't complete (transient gateway error). The new password stays pending so
+ // the recovery probe promotes it next run; a tunnel blip must not leave a live-but-unrecorded password.
throw new BadRequestError({
message:
"Password was changed on the target but verification could not complete due to a transient network error; it will be reconciled on the next rotation attempt"
@@ -652,8 +641,7 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServic
};
};
- // Set-LocalUser / Set-ADAccountPassword throw a bare InvalidPasswordException with no reason when the new
- // password violates the host's policy, and Windows never says which rule failed. Append the one thing we do
+ // Windows throws a bare InvalidPasswordException with no reason on a policy violation. Append the one thing we
// know (the configured format length) plus what to try, so the opaque error becomes actionable.
const augmentWindowsPolicyError = (account: TPamAccountDetail, message: string): string => {
if (!isWindowsRotatableType(account.accountType) || !message.includes("InvalidPasswordException")) {
@@ -666,9 +654,8 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServic
return `${message}\nNote: the host rejected the new password against its local password policy (minimum length, complexity, or history).${lengthHint}`;
};
- // Advance nextRotationAt to a capped retry, but only when the account is schedulable: a ready account's early
- // failure still can't be re-selected on every cron tick, and a not-ready account is never given a due-date it
- // cannot act on.
+ // Advance nextRotationAt to a capped retry, but only when the account is schedulable: keeps a ready account's
+ // failure off every cron tick without handing a not-ready account a due-date it can't act on.
const recordRotationFailure = async (account: TPamAccountDetail, err: unknown) => {
const projectId = account.projectId as string;
const rotation = getRotationConfig(account.templateSettings);
@@ -854,10 +841,8 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServic
await decrypt(projectId, rotator.encryptedConnectionDetails)
);
assertRotatorSameResource(account.accountType as PamAccountType, rotatorConn, targetConn);
- // A delegated rotator that resolves to the SAME directory identity as the target is a footgun: rotating
- // changes the shared principal's password, immediately invalidating the rotator's own stored credential
- // (and any other PAM copy of it). Require a genuinely different identity; to rotate itself, an account is
- // set as its own rotation account, which authenticates with the freshly-set password instead.
+ // A delegated rotator resolving to the SAME identity as the target is a footgun: rotating would invalidate
+ // the rotator's own stored credential. Require a different identity; self-rotation is a separate path.
const rotatorCredentials = await decryptSqlCredentials(
projectId,
account.accountType,
diff --git a/backend/src/ee/services/pam-account-rotation/pam-rotation-fns.ts b/backend/src/ee/services/pam-account-rotation/pam-rotation-fns.ts
index d93ec6b12e..9c1b8428bb 100644
--- a/backend/src/ee/services/pam-account-rotation/pam-rotation-fns.ts
+++ b/backend/src/ee/services/pam-account-rotation/pam-rotation-fns.ts
@@ -8,10 +8,8 @@ const sleep = (ms: number) =>
setTimeout(resolve, ms);
});
-// Rotation talks to the target through a freshly-opened gateway tunnel: to verify a new password, or to push it
-// into a dependency (service / task / IIS pool). A transient tunnel/TLS/auth blip is NOT a real failure, so the
-// probe throws on those and we retry. A definitive result short-circuits: verify returns true/false, a dependency
-// sync returns true on success. If every attempt throws, the last error propagates so the caller records it.
+// Rotation talks to the target through a gateway tunnel; a transient tunnel/TLS/auth blip is not a real failure,
+// so the probe throws on those and we retry, short-circuiting on a definitive result. Last error propagates.
export const GATEWAY_RETRY_ATTEMPTS = 3;
export const withGatewayRetry = async (
diff --git a/backend/src/ee/services/pam-account-rotation/pam-rotation-handlers.ts b/backend/src/ee/services/pam-account-rotation/pam-rotation-handlers.ts
index 76e5a93acd..3b262f6309 100644
--- a/backend/src/ee/services/pam-account-rotation/pam-rotation-handlers.ts
+++ b/backend/src/ee/services/pam-account-rotation/pam-rotation-handlers.ts
@@ -48,9 +48,8 @@ type TTestCredentialInput = {
export type TPamRotationHandler = {
validateTarget: (input: { accountType: TRotatableType; authMethod?: string }) => void;
applyPasswordChange: (input: TApplyPasswordChangeInput, deps: TPamRotationGatewayDeps) => Promise<void>;
- // Returns whether the credential authenticates (true/false is a definitive answer). THROWS only when
- // verification can't complete after retries (a transient transport error) — callers treat that as
- // inconclusive and defer, never as a wrong password.
+ // Returns whether the credential authenticates. THROWS only when verification can't complete (transient
+ // transport error); callers treat a throw as inconclusive and defer, never as a wrong password.
testCredential: (input: TTestCredentialInput, deps: TPamRotationGatewayDeps) => Promise<boolean>;
};
@@ -265,9 +264,8 @@ const windowsRotationHandler: TPamRotationHandler = {
const targetHost = winrmRotationTargetHost(accountType, connectionDetails);
const targetPort = winrmPortFromConn(connectionDetails);
- // Delegated local rotation: the target account usually can't WinRM in, so the rotator (admin) validates the
- // credential on the box instead of us trying to log in as the account. A wrong password comes back as
- // valid=false (definitive); a transport error throws and is retried.
+ // Delegated local rotation: the target usually can't WinRM in, so the rotator validates the credential on
+ // the box. A wrong password comes back valid=false (definitive); a transport error throws and is retried.
if (verifyVia) {
return withGatewayRetry(async () => {
const { valid } = await winrmRpcWithGateway<{ valid: boolean }>({
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.ts
index fbb9cd5745..2c254f0029 100644
--- 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.ts
@@ -221,11 +221,8 @@ export const parseRunAs = (runAs: string): { domain: string | null; account: str
// Retained for the account-name extraction; the fingerprint resolver below adds the domain check.
export const extractSamAccountName = (runAs: string): string | null => parseRunAs(runAs)?.account ?? null;
-// Anchor a dependency's run-as to a domain account's stable identity (domain:objectGUID), matching the
-// fingerprint minted for discovered domain accounts. Returns null for built-ins and any run-as that doesn't
-// resolve to an enumerated domain user (local/unknown accounts are not tracked as dependencies). A qualified
-// run-as must name the scanned domain, so a same-named local or trusted-domain account (e.g. WEB01\svc-sql)
-// is never mis-anchored to the domain account.
+// Anchor a run-as to a domain account's stable identity (domain:objectGUID), null for built-ins and non-domain
+// users; a qualified run-as must name the scanned domain so a same-named local account isn't mis-anchored.
export const resolveRunAsFingerprint = (
runAs: string,
domain: string,
@@ -238,9 +235,8 @@ export const resolveRunAsFingerprint = (
if (!parsed) return null;
const account = parsed.account.toLowerCase();
if (BUILTIN_RUNAS.has(account)) return null;
- // A trailing '$' marks a gMSA / sMSA / machine account, whose password AD manages automatically. There is
- // nothing for rotation to set, so it is never a dependency's run-as (domain enumeration also excludes these
- // via objectCategory=person; this makes the rule explicit and also covers the local-account branch below).
+ // A trailing '$' marks a gMSA / sMSA / machine account whose password AD manages automatically, so there is
+ // nothing for rotation to set; never a dependency's run-as.
if (account.endsWith("$")) return null;
if (parsed.domain !== null) {
diff --git a/backend/src/ee/services/pam-discovery/pam-account-dependency-dal.ts b/backend/src/ee/services/pam-discovery/pam-account-dependency-dal.ts
index 3e0e65e169..660ae4359a 100644
--- a/backend/src/ee/services/pam-discovery/pam-account-dependency-dal.ts
+++ b/backend/src/ee/services/pam-discovery/pam-account-dependency-dal.ts
@@ -20,16 +20,8 @@ type TUpsertDependency = {
export const pamAccountDependencyDALFactory = (db: TDbClient) => {
const orm = ormify(db, TableName.PamAccountDependency);
- // Upsert a discovered dependency keyed by its stable identity, returning the row id. Atomic (single
- // INSERT ... ON CONFLICT) so overlapping scans of the same machine can't race on the unique index. Discovery
- // owns fingerprint / machine / type / name / data and the account linkage; on conflict only those are merged,
- // so rotation-owned columns (rotationStatus, lastRotatedAt, encryptedLastRotationMessage) are never touched.
- //
- // Imported wins: a row already linked to a managed account (accountId set) is never demoted back to a staged
- // link, so a second discovery source scanning the same machine can't silently break rotation sync for an
- // account another source imported.
- // `xmax = 0` is true only for the freshly-inserted tuple; on an ON CONFLICT update xmax is the updating txid,
- // so it distinguishes a newly-discovered dependency from one the scan merely re-saw (drives the run's new count).
+ // Atomic upsert keyed by stable identity. On conflict only discovery-owned columns merge and an imported row
+ // is never demoted to staged; `xmax = 0` flags a fresh insert vs a re-seen row (drives the run's new count).
const upsertByIdentity = async (dep: TUpsertDependency, tx?: Knex): Promise<{ id: string; isNew: boolean }> => {
const conn = tx || db;
const { projectId, fingerprint, machine, type, name, data, accountId, discoveredAccountId } = dep;
@@ -49,9 +41,8 @@ export const pamAccountDependencyDALFactory = (db: TDbClient) => {
return { id: inserted.id, isNew: Boolean(inserted.inserted) };
};
- // Prune dependencies the current scan no longer found. Scoped to this source's accounts (staged or their
- // imported counterparts) and to the machines the scan actually re-checked, so an unreachable machine or a
- // narrower source never drops another scan's dependencies.
+ // Prune dependencies the current scan no longer found, scoped to this source's accounts and the machines it
+ // actually re-checked so an unreachable machine or narrower source can't drop another scan's dependencies.
const deleteStaleForSource = async (
{
projectId,
@@ -70,9 +61,8 @@ export const pamAccountDependencyDALFactory = (db: TDbClient) => {
): Promise<void> => {
if (!scannedMachines.length || (!accountIds.length && !discoveredAccountIds.length)) return;
- // Bind each list as a single array parameter (`= ANY(?)`) rather than one bind per element, so a large
- // domain can't blow past Postgres's 65,535 bind-parameter cap and fail the reconcile after upserts wrote.
- // Scoped to this tenant's project so a scan never touches another org's rows sharing the same machine name.
+ // `= ANY(?)` binds each list as one param (a large domain would blow past Postgres's 65,535 bind cap);
+ // scoped to this project so a scan never touches another tenant's rows on a same-named machine.
await (tx || db)(TableName.PamAccountDependency)
.where("projectId", projectId)
.whereRaw(`"machine" = ANY(?::text[])`, [scannedMachines])
diff --git a/backend/src/ee/services/pam-discovery/pam-discovery-fns.ts b/backend/src/ee/services/pam-discovery/pam-discovery-fns.ts
index 18ac78708d..13bd22ca2c 100644
--- a/backend/src/ee/services/pam-discovery/pam-discovery-fns.ts
+++ b/backend/src/ee/services/pam-discovery/pam-discovery-fns.ts
@@ -73,9 +73,8 @@ export const executeWithGateway = async <T>(
});
};
-// Resolve hostnames to IPs through the DC's DNS in one gateway session. Used at rotation-sync time so a
-// dependency's machine is targeted by a fresh IP (a scan-time snapshot can go stale via DHCP). Never throws;
-// unresolved hosts are simply absent from the map.
+// Resolve hostnames to IPs via the DC's DNS at rotation-sync time, so a machine is targeted by a fresh IP
+// (a scan-time snapshot can go stale via DHCP). Never throws; unresolved hosts are absent from the map.
export const resolveHostsViaDcDns = async (
hostnames: string[],
dcAddress: string,
@@ -100,10 +99,8 @@ export const resolveHostsViaDcDns = async (
const LDAP_BIND_CHECK_TIMEOUT_MS = 15 * 1000;
-// Confirms directory credentials by performing an LDAP simple bind through the gateway. Used to verify a
-// rotated domain account's new password: an LDAP bind needs only the credential, unlike a WinRM logon that
-// most service accounts lack. Returns true (bound) / false (definitive auth rejection); THROWS on a transport
-// error (TLS/tunnel/timeout) so a transient blip is retried rather than misread as a wrong password.
+// Verify a rotated domain account's password via an LDAP simple bind (needs only the credential, unlike a WinRM
+// logon most service accounts lack). Returns bound/rejected; THROWS on a transport error so a blip is retried.
export const ldapBindCheckViaGateway = async (
{
dcAddress,
@@ -184,9 +181,8 @@ export type TWinRmGatewayCredentials = {
caCertificate?: string;
};
-// runs one WinRM operation on the gateway inside the customer network. Node can't perform WinRM message
-// sealing, so the gateway (Go/masterzen) owns the WinRM client; the backend only names a vetted operation
-// and its params. Targets internal hosts by design, so it uses the gateway host validator (not the SSRF block).
+// Runs one WinRM operation on the gateway: Node can't do WinRM message sealing, so the gateway owns the client
+// and the backend only names a vetted operation. Targets internal hosts, so it uses the gateway host validator.
export const winrmRpcWithGateway = async <T>({
targetHost,
targetPort,
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.ts
index ed9fe35cad..9aaffd7ce5 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
@@ -469,9 +469,8 @@ export const pamDiscoverySourceServiceFactory = (deps: TPamDiscoverySourceServic
)
);
- // Persist dependencies found during the per-machine sweep, anchoring each to its run-as account by
- // fingerprint: point at the staged discovered account, or its imported managed account once imported.
- // null = dependency discovery did not run this scan, so the summary omits the dependencies clause.
+ // Persist dependencies from the sweep, anchoring each to its run-as account by fingerprint. null =
+ // dependency discovery did not run this scan, so the summary omits the dependencies clause.
let dependencyCount: number | null = null;
let newDependencyCount: number | null = null;
if (scannedDependencyMachines.length) {
@@ -690,10 +689,8 @@ export const pamDiscoverySourceServiceFactory = (deps: TPamDiscoverySourceServic
throw new NotFoundError({ message: "Discovered account not found" });
}
if (discovered.importedAccountId) {
- // Already imported. The account is created, marked, and its deps backfilled in three separate writes
- // (create runs its own transaction, so they can't share one). Re-run the idempotent backfill here so
- // a retry heals a prior import whose backfill didn't complete, flipping any still-staged deps onto
- // the account instead of leaving them stranded behind this early return.
+ // Already imported. Re-run the idempotent backfill so a retry heals a prior import whose backfill
+ // didn't complete (the three writes aren't one transaction), rather than stranding still-staged deps.
await pamAccountDependencyDAL.backfillImported(discovered.id, discovered.importedAccountId);
return {
discoveredAccountId: item.discoveredAccountId,
diff --git a/backend/src/lib/gateway-v2/winrm-rpc.ts b/backend/src/lib/gateway-v2/winrm-rpc.ts
index 225244b41b..48e5ebe1ef 100644
--- a/backend/src/lib/gateway-v2/winrm-rpc.ts
+++ b/backend/src/lib/gateway-v2/winrm-rpc.ts
@@ -38,10 +38,8 @@ export type WinRmRpcSuccess<T> = { ok: true; status: number; result: T };
export type WinRmRpcFailure = { ok: false; status: number; errorMessage: string };
export type WinRmRpcResponse<T> = WinRmRpcSuccess<T> | WinRmRpcFailure;
-// A WinRM session sets up NTLM and runs one or more PowerShell commands per file,
-// each of which can take a few seconds on a loaded host, so allow a generous ceiling.
-// This must exceed the gateway's own connection deadline (op 120s + 15s flush margin) so a
-// gateway-side timeout surfaces as its structured error rather than an opaque client timeout.
+// Must exceed the gateway's own connection deadline (op 120s + 15s flush margin) so a gateway-side timeout
+// surfaces as its structured error rather than an opaque client timeout.
export const WINRM_RPC_TIMEOUT_MS = 150_000;
const MAX_WINRM_RPC_RESPONSE_BYTES = 1024 * 1024;
diff --git a/frontend/src/hooks/api/pam/mutations.tsx b/frontend/src/hooks/api/pam/mutations.tsx
index 822fc44dd1..85510d5edf 100644
--- a/frontend/src/hooks/api/pam/mutations.tsx
+++ b/frontend/src/hooks/api/pam/mutations.tsx
@@ -486,9 +486,8 @@ export const useRemovePamProductIdentityMember = () => {
});
};
-// Product user/group add & removal must go through the PAM endpoints so the PAM-specific audit
-// events fire and approver assignments / folder memberships are handled (the generic workspace
-// routes emit project-scoped events and skip that).
+// Product user/group changes go through the PAM endpoints so PAM audit events fire and approver assignments /
+// folder memberships are handled (the generic workspace routes skip that).
export const useAddPamProductUserMember = () => {
const queryClient = useQueryClient();
return useMutation({