Skip to content

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

add all projects if auto discovery is on

Matheus Nogueira8cc9a37c1d30
diff --git a/backend/src/ee/routes/v2/secret-scanning-v2-routers/secret-scanning-v2-endpoints.ts b/backend/src/ee/routes/v2/secret-scanning-v2-routers/secret-scanning-v2-endpoints.ts
index 69732fdcaa..35b4fb1772 100644
--- a/backend/src/ee/routes/v2/secret-scanning-v2-routers/secret-scanning-v2-endpoints.ts
+++ b/backend/src/ee/routes/v2/secret-scanning-v2-routers/secret-scanning-v2-endpoints.ts
@@ -17,6 +17,7 @@ import {
} from "@app/ee/services/secret-scanning-v2/secret-scanning-v2-types";
import { ApiDocsTags, SecretScanningDataSources } from "@app/lib/api-docs";
import { startsWithVowel } from "@app/lib/fn";
+import { logger } from "@app/lib/logger";
import { OrderByDirection } from "@app/lib/types";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { getTelemetryDistinctId } from "@app/server/lib/telemetry";
@@ -261,6 +262,38 @@ export const registerSecretScanningEndpoints = <
})
.catch(() => {});
+ // Discovery only picks up resources that push after setup, so start from everything already accessible.
+ // Best effort: the data source exists either way, and the rest can be added from its resources tab.
+ if (dataSource.isDiscoveryEnabled) {
+ try {
+ const { resources, dataSourceName } = await server.services.secretScanningV2.addAllSecretScanningResources(
+ { type, dataSourceId: dataSource.id },
+ req.permission
+ );
+
+ if (resources.length) {
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ projectId: dataSource.projectId,
+ event: {
+ type: EventType.SECRET_SCANNING_RESOURCE_ADD,
+ metadata: {
+ type,
+ dataSourceId: dataSource.id,
+ dataSourceName,
+ resources: resources.map((resource) => ({ resourceId: resource.id, resourceName: resource.name }))
+ }
+ }
+ });
+ }
+ } catch (error) {
+ logger.error(
+ error,
+ `secretScanningV2: Failed to add resources to new data source [dataSourceId=${dataSource.id}] [projectId=${dataSource.projectId}]`
+ );
+ }
+ }
+
return { dataSource };
}
});