Skip to content

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

address reviews

x116b050f7033
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 efe430e381..2e913411a4 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
@@ -1,6 +1,7 @@
import net from "node:net";
import ldapjs from "@infisical/ldapjs";
+import slugify from "@sindresorhus/slugify";
import { runPowershell } from "winrm-client";
import { BadRequestError } from "@app/lib/errors";
@@ -302,9 +303,10 @@ export const activeDirectoryDiscoveryFactory: TPamDiscoveryFactory = ({
);
// Domain accounts inherit the source's connection target; only the login user differs
+ const domainShortName = domain.split(".")[0];
const discovered: TDiscoveredAccount[] = users.map((u) => ({
accountType: PamAccountType.WindowsAd,
- name: u.sAMAccountName.toLowerCase(),
+ name: slugify(`${domainShortName} ${u.sAMAccountName}`, { lowercase: true }).slice(0, 64).replace(/-+$/, ""),
fingerprint: `${domain}:${u.objectGUID}`,
details: { connectionDetails, credentials: { username: u.sAMAccountName } }
}));
@@ -321,6 +323,7 @@ export const activeDirectoryDiscoveryFactory: TPamDiscoveryFactory = ({
for (const computer of computers) {
const host = computer.resolvedIp || computer.dNSHostName || computer.cn;
+ const hostLabel = computer.cn || computer.dNSHostName || host;
try {
// eslint-disable-next-line no-await-in-loop
const localUsers = await enumerateLocalUsers(
@@ -335,7 +338,7 @@ export const activeDirectoryDiscoveryFactory: TPamDiscoveryFactory = ({
for (const u of localUsers.filter((lu) => lu.Name)) {
discovered.push({
accountType: PamAccountType.Windows,
- name: u.Name.toLowerCase(),
+ name: slugify(`${hostLabel} ${u.Name}`, { lowercase: true }).slice(0, 64).replace(/-+$/, ""),
fingerprint: `${domain}:${computer.objectGUID}:${u.Name.toLowerCase()}`,
details: {
connectionDetails: { host, port: connectionDetails.rdpPort },
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 ac422678b1..2cada1f0de 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
@@ -352,6 +352,10 @@ export const pamDiscoverySourceServiceFactory = (deps: TPamDiscoverySourceServic
const listRuns = async ({ projectId, sourceId, offset = 0, limit = 20, ...ctx }: TListRunsDTO) => {
await verifyAdmin(projectId, ctx);
+ const source = await pamDiscoverySourceDAL.findById(sourceId);
+ if (!source || source.projectId !== projectId) {
+ throw new NotFoundError({ message: `Discovery source with ID '${sourceId}' not found` });
+ }
const runs = await pamDiscoverySourceRunDAL.find(
{ discoverySourceId: sourceId },
{ sort: [["createdAt", "desc"]], offset, limit }
@@ -361,6 +365,10 @@ export const pamDiscoverySourceServiceFactory = (deps: TPamDiscoverySourceServic
const listDiscovered = async ({ projectId, sourceId, search, ...ctx }: TListDiscoveredDTO) => {
await verifyAdmin(projectId, ctx);
+ const source = await pamDiscoverySourceDAL.findById(sourceId);
+ if (!source || source.projectId !== projectId) {
+ throw new NotFoundError({ message: `Discovery source with ID '${sourceId}' not found` });
+ }
const accounts = await pamDiscoveredAccountDAL.listStaged(sourceId, search);
return accounts.map((a) => ({
id: a.id,
diff --git a/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoverySourceDetailSheet.tsx b/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoverySourceDetailSheet.tsx
index feda3b526c..7129f6e690 100644
--- a/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoverySourceDetailSheet.tsx
+++ b/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoverySourceDetailSheet.tsx
@@ -177,6 +177,7 @@ const ConfigurationTab = ({
<FieldLabel>Gateway</FieldLabel>
<FieldContent>
<GatewayPicker
+ isRequired
value={{ gatewayId, gatewayPoolId }}
onChange={(value) => {
setValue("gatewayId", value.gatewayId, { shouldDirty: true });