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
remove includeRepo from everywhere
Matheus Nogueira97e57887a05d
diff --git a/backend/CLAUDE.md b/backend/CLAUDE.mdindex 516ff0c3bf..808f6fbc93 100644--- a/backend/CLAUDE.md+++ b/backend/CLAUDE.md@@ -1059,7 +1059,7 @@ EE routes register before community routes so they can override/extend endpoints**Agent Vault**: the same applies to the `agent-vault-*` services and routers; the concept map is [`src/ee/services/agent-vault/CLAUDE.md`](src/ee/services/agent-vault/CLAUDE.md). PAM and Agent Vault are the two **org-scoped products**: one implicit project per org, resolved lazily, whose roles collapse to admin or member. Anything that branches on `ProjectType.PAM` (metering emits, predefined roles, the billable-project count, invite grants) almost always needs an Agent Vault arm too.-**Secret Scanning** is single-project (see the root `CLAUDE.md`): `secret-scanning-v2-project-bootstrap.ts` creates the project with the org when it has a creator to make admin (like PAM and Agent Vault), `secret-scanning-v2-project-resolver.ts` picks the active project and lazily creates it, with every org admin as project admin, for older orgs and for orgs created from the admin console, whose admins are only invited after the org exists, and routes that take `projectId` read `req.internalSecretScanningProjectId`. A data source covers the resources it has rows for (added, included at create, or discovered); `config.includeRepos` / `includeProjects` are only read on create and on API updates that change them, so scans, "included" state and GitLab account-scope webhooks all key off rows.+**Secret Scanning** is single-project (see the root `CLAUDE.md`): `secret-scanning-v2-project-bootstrap.ts` creates the project with the org when it has a creator to make admin (like PAM and Agent Vault), `secret-scanning-v2-project-resolver.ts` picks the active project and lazily creates it, with every org admin as project admin, for older orgs and for orgs created from the admin console, whose admins are only invited after the org exists, and routes that take `projectId` read `req.internalSecretScanningProjectId`. A data source covers the resources it has rows for (added by a user or discovered from a push); its `config` only says where to look (Bitbucket workspace, GitLab group), never which resources, so scans, "included" state and GitLab account-scope webhooks all key off rows. Stored configs may still carry the old `includeRepos` / `includeProjects` keys, which nothing reads.**Dynamic secret lease secrets needed at revoke time go in `dynamic_secret_leases.encryptedLeaseData`**, never in `externalEntityId` or `config` (both plaintext, and `externalEntityId` is returned by every lease route and logged in audit events). A provider opts in by listing the `create()` `data` keys in `persistedLeaseFields`; the lease service encrypts them with the project's SecretManager key and every revoke path passes them back as `metadata.leaseData`. Lease routes return `SanitizedDynamicSecretLeaseSchema` so the column never reaches a response. Secret *config* fields are listed separately in `DYNAMIC_SECRET_SECRET_FIELDS` (`providers/redact.ts`), as dotted paths so nested secrets work (`clientAuth.clientSecret`): reads strip them via `redactStoredInputs`, and an update that omits one keeps the stored value via `restoreOmittedSecretFields`, because the update merge is shallow.diff --git a/backend/src/ee/services/secret-scanning-v2/bitbucket/bitbucket-secret-scanning-factory.ts b/backend/src/ee/services/secret-scanning-v2/bitbucket/bitbucket-secret-scanning-factory.tsindex 68338c1e0b..5aed67a016 100644--- a/backend/src/ee/services/secret-scanning-v2/bitbucket/bitbucket-secret-scanning-factory.ts+++ b/backend/src/ee/services/secret-scanning-v2/bitbucket/bitbucket-secret-scanning-factory.ts@@ -148,19 +148,12 @@ export const BitbucketSecretScanningFactory = () => {) => {const {connection,- config: { includeRepos, workspaceSlug }+ config: { workspaceSlug }} = dataSource;const repos = await listBitbucketRepositories(connection, workspaceSlug);- const filteredRepos: typeof repos = [];- if (includeRepos.includes("*")) {- filteredRepos.push(...repos);- } else {- filteredRepos.push(...repos.filter((repo) => includeRepos.includes(repo.full_name)));- }-- return filteredRepos.map(({ full_name, uuid }) => ({+ return repos.map(({ full_name, uuid }) => ({name: full_name,externalId: uuid}));diff --git a/backend/src/ee/services/secret-scanning-v2/bitbucket/bitbucket-secret-scanning-schemas.ts b/backend/src/ee/services/secret-scanning-v2/bitbucket/bitbucket-secret-scanning-schemas.tsindex 00f1c0d810..1e142553f0 100644--- a/backend/src/ee/services/secret-scanning-v2/bitbucket/bitbucket-secret-scanning-schemas.ts+++ b/backend/src/ee/services/secret-scanning-v2/bitbucket/bitbucket-secret-scanning-schemas.ts@@ -9,7 +9,6 @@ import {GitRepositoryScanFindingDetailsSchema} from "@app/ee/services/secret-scanning-v2/secret-scanning-v2-schemas";import { SecretScanningDataSources } from "@app/lib/api-docs";-import { BasicRepositoryRegex } from "@app/lib/regex";import { AppConnection } from "@app/services/app-connection/app-connection-enums";export const BitbucketDataSourceConfigSchema = z.object({@@ -17,18 +16,7 @@ export const BitbucketDataSourceConfigSchema = z.object({.string().min(1, "Workspace slug required").max(128)- .describe(SecretScanningDataSources.CONFIG.BITBUCKET.workspaceSlug),- includeRepos: z- .array(- z- .string()- .min(1)- .max(256)- .refine((value) => value === "*" || BasicRepositoryRegex.test(value), "Invalid repository name format")- )- .max(100, "Cannot configure more than 100 repositories")- .default(["*"])- .describe(SecretScanningDataSources.CONFIG.BITBUCKET.includeRepos)+ .describe(SecretScanningDataSources.CONFIG.BITBUCKET.workspaceSlug)});export const BitbucketDataSourceSchema = BaseSecretScanningDataSourceSchema({diff --git a/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-factory.ts b/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-factory.tsindex a1748cbbad..aa73cbcf98 100644--- a/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-factory.ts+++ b/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-factory.ts@@ -82,21 +82,9 @@ export const GitHubSecretScanningFactory = () => {const listRawResources: TSecretScanningFactoryListRawResources<TGitHubDataSourceWithConnection> = async (dataSource) => {- const {- connection,- config: { includeRepos }- } = dataSource;-- const repos = await listGitHubRadarRepositories(connection);-- const filteredRepos: typeof repos = [];- if (includeRepos.includes("*")) {- filteredRepos.push(...repos);- } else {- filteredRepos.push(...repos.filter((repo) => includeRepos.includes(repo.full_name)));- }+ const repos = await listGitHubRadarRepositories(dataSource.connection);- return filteredRepos.map(({ id, full_name }) => ({+ return repos.map(({ id, full_name }) => ({name: full_name,externalId: id.toString()}));diff --git a/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-schemas.ts b/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-schemas.tsindex 1f146e363c..14a4a0c984 100644--- a/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-schemas.ts+++ b/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-schemas.ts@@ -8,23 +8,10 @@ import {BaseUpdateSecretScanningDataSourceSchema,GitRepositoryScanFindingDetailsSchema} from "@app/ee/services/secret-scanning-v2/secret-scanning-v2-schemas";-import { SecretScanningDataSources } from "@app/lib/api-docs";-import { BasicRepositoryRegex } from "@app/lib/regex";import { AppConnection } from "@app/services/app-connection/app-connection-enums";-export const GitHubDataSourceConfigSchema = z.object({- includeRepos: z- .array(- z- .string()- .min(1)- .max(256)- .refine((value) => value === "*" || BasicRepositoryRegex.test(value), "Invalid repository name format")- )- .max(100, "Cannot configure more than 100 repositories")- .default(["*"])- .describe(SecretScanningDataSources.CONFIG.GITHUB.includeRepos)-});+// Which repositories are scanned is the data source's resources, so a GitHub data source has nothing to configure.+export const GitHubDataSourceConfigSchema = z.object({});export const GitHubDataSourceSchema = BaseSecretScanningDataSourceSchema({type: SecretScanningDataSource.GitHub,diff --git a/backend/src/ee/services/secret-scanning-v2/gitlab/gitlab-secret-scanning-enums.ts b/backend/src/ee/services/secret-scanning-v2/gitlab/gitlab-secret-scanning-enums.tsindex 502e67395e..aeaa8e92d0 100644--- a/backend/src/ee/services/secret-scanning-v2/gitlab/gitlab-secret-scanning-enums.ts+++ b/backend/src/ee/services/secret-scanning-v2/gitlab/gitlab-secret-scanning-enums.ts@@ -1,5 +1,4 @@export enum GitLabDataSourceScope {- // Every project the connection can read, with no group webhook to discover new ones.Account = "account",Project = "project",Group = "group"diff --git a/backend/src/ee/services/secret-scanning-v2/gitlab/gitlab-secret-scanning-factory.ts b/backend/src/ee/services/secret-scanning-v2/gitlab/gitlab-secret-scanning-factory.tsindex 03f92c28ae..326194a6cd 100644--- a/backend/src/ee/services/secret-scanning-v2/gitlab/gitlab-secret-scanning-factory.ts+++ b/backend/src/ee/services/secret-scanning-v2/gitlab/gitlab-secret-scanning-factory.ts@@ -36,7 +36,6 @@ import {getGitLabConnectionClient,getGitLabInstanceUrl} from "@app/services/app-connection/gitlab/gitlab-connection-fns";-import { KmsDataKey } from "@app/services/kms/kms-types";import { GitLabDataSourceScope } from "./gitlab-secret-scanning-enums";import {@@ -50,13 +49,6 @@ const PROJECT_HOOK_CONCURRENCY = 5;type TGitLabProjectHook = { projectId: number; projectName: string; hookId: number };-// Including every project (`*`) would mean a hook on each project the connection can see, possibly thousands,-// so only an explicit list gets project hooks.-const getHookedProjectNames = (config: TGitLabDataSourceInput["config"]) => {- if (config.scope !== GitLabDataSourceScope.Account || config.includeProjects.includes("*")) return [];- return config.includeProjects;-};-export const GitLabSecretScanningFactory = ({ appConnectionDAL, kmsService }: TSecretScanningFactoryParams) => {type TGitLabClient = Awaited<ReturnType<typeof getGitLabConnectionClient>>;type THookableConfig = Exclude<TGitLabDataSourceInput["config"], { scope: GitLabDataSourceScope.Account }>;@@ -211,42 +203,13 @@ export const GitLabSecretScanningFactory = ({ appConnectionDAL, kmsService }: TSTGitLabDataSourceInput,TGitLabConnection,TGitLabDataSourceCredentials- > = async ({ payload, connection, secretScanningV2DAL }, callback) => {+ > = async ({ payload, connection }, callback) => {const { config, name } = payload;if (!isDataSourceWebhookRequired(payload)) return callback({});- if (config.scope === GitLabDataSourceScope.Account) {- const projectNames = getHookedProjectNames(config);- if (!projectNames.length) return callback({});-- // Project hooks are created with the data source ID already set, so they are added once the row exists- // rather than in a second call inside the create transaction.- const accountClient = await getGitLabConnectionClient(connection, appConnectionDAL, kmsService);- const dataSource = await callback({});- const accountToken = alphaNumericNanoId(64);- let projectHooks: TGitLabProjectHook[] = [];-- try {- projectHooks = await addProjectHooks(accountClient, projectNames, accountToken, dataSource.id);-- const credentials: TGitLabDataSourceCredentials = { token: accountToken, projectHooks };- const { encryptor } = await kmsService.createCipherPairWithDataKey({- type: KmsDataKey.SecretManager,- projectId: dataSource.projectId- });- const { cipherTextBlob: encryptedCredentials } = encryptor({- plainText: Buffer.from(JSON.stringify(credentials))- });-- await secretScanningV2DAL.dataSources.updateById(dataSource.id, { encryptedCredentials });- return { ...dataSource, encryptedCredentials };- } catch (error) {- await removeProjectHooks(accountClient, projectHooks);- await secretScanningV2DAL.dataSources.deleteById(dataSource.id);- throw error;- }- }+ // An account data source starts with no projects; each one gets its hook as it is added.+ if (config.scope === GitLabDataSourceScope.Account) return callback({});const client = await getGitLabConnectionClient(connection, appConnectionDAL, kmsService);const token = alphaNumericNanoId(64);@@ -340,21 +303,15 @@ export const GitLabSecretScanningFactory = ({ appConnectionDAL, kmsService }: TS];}- const { includeProjects } = config;-const projects =config.scope === GitLabDataSourceScope.Account? await client.Projects.all({ membership: true, archived: false }): await client.Groups.allProjects(config.groupId, { archived: false });- const resources = projects.map(({ id, pathWithNamespace }) => ({+ return projects.map(({ id, pathWithNamespace }) => ({name: pathWithNamespace,externalId: id.toString()}));-- if (!includeProjects || includeProjects.includes("*")) return resources;-- return resources.filter((resource) => includeProjects.includes(resource.name));};const getFullScanPath: TSecretScanningFactoryGetFullScanPath<TGitLabDataSourceWithConnection> = async ({diff --git a/backend/src/ee/services/secret-scanning-v2/gitlab/gitlab-secret-scanning-schemas.ts b/backend/src/ee/services/secret-scanning-v2/gitlab/gitlab-secret-scanning-schemas.tsindex fd894e8b86..570c0dcecc 100644--- a/backend/src/ee/services/secret-scanning-v2/gitlab/gitlab-secret-scanning-schemas.ts+++ b/backend/src/ee/services/secret-scanning-v2/gitlab/gitlab-secret-scanning-schemas.ts@@ -10,31 +10,16 @@ import {GitRepositoryScanFindingDetailsSchema} from "@app/ee/services/secret-scanning-v2/secret-scanning-v2-schemas";import { SecretScanningDataSources } from "@app/lib/api-docs";-import { GitLabProjectRegex } from "@app/lib/regex";import { AppConnection } from "@app/services/app-connection/app-connection-enums";-const GitLabIncludeProjectsSchema = z- .array(- z- .string()- .min(1)- .max(256)- .refine((value) => value === "*" || GitLabProjectRegex.test(value), "Invalid project name format")- )- .max(100, "Cannot configure more than 100 projects")- .default(["*"])- .describe(SecretScanningDataSources.CONFIG.GITLAB.includeProjects);-export const GitLabDataSourceConfigSchema = z.discriminatedUnion("scope", [z.object({scope: z.literal(GitLabDataSourceScope.Group).describe(SecretScanningDataSources.CONFIG.GITLAB.scope),groupId: z.number().describe(SecretScanningDataSources.CONFIG.GITLAB.groupId),- groupName: z.string().trim().max(256).optional().describe(SecretScanningDataSources.CONFIG.GITLAB.groupName),- includeProjects: GitLabIncludeProjectsSchema+ groupName: z.string().trim().max(256).optional().describe(SecretScanningDataSources.CONFIG.GITLAB.groupName)}),z.object({- scope: z.literal(GitLabDataSourceScope.Account).describe(SecretScanningDataSources.CONFIG.GITLAB.scope),- includeProjects: GitLabIncludeProjectsSchema+ scope: z.literal(GitLabDataSourceScope.Account).describe(SecretScanningDataSources.CONFIG.GITLAB.scope)}),z.object({scope: z.literal(GitLabDataSourceScope.Project).describe(SecretScanningDataSources.CONFIG.GITLAB.scope),diff --git a/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-fns.test.ts b/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-fns.test.tsindex a258ce7020..c41aff5f2c 100644--- a/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-fns.test.ts+++ b/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-fns.test.ts@@ -11,13 +11,8 @@ import {SecretScanningExecPhase} from "@app/ee/services/secret-scanning/secret-scanning-exec";-import { GitLabDataSourceScope } from "./gitlab/gitlab-secret-scanning-enums";-import { SecretScanningDataSource } from "./secret-scanning-v2-enums";import {assertClonedRepositoryWithinSizeLimit,- doesConfigUpdateIncludeNewResources,- getConfigIncludingAllResources,- isResourceIncludedByConfig,parseScanErrorMessage,planCommitBatches,repositoryHasCommits,@@ -303,74 +298,3 @@ describe("planCommitBatches", () => {});});});--describe("doesConfigUpdateIncludeNewResources", () => {- const github = (includeRepos: string[]) =>- ({ type: SecretScanningDataSource.GitHub, config: { includeRepos } }) as const;-- test("is true when a repository is added", () => {- expect(doesConfigUpdateIncludeNewResources(github(["acme/api"]), github(["acme/api", "acme/web"]))).toBe(true);- });-- test("is true when an empty list becomes all repositories", () => {- expect(doesConfigUpdateIncludeNewResources(github([]), github(["*"]))).toBe(true);- });-- test("is false when a repository is only removed", () => {- expect(doesConfigUpdateIncludeNewResources(github(["acme/api", "acme/web"]), github(["acme/api"]))).toBe(false);- });-- test("is false when everything was already included", () => {- expect(doesConfigUpdateIncludeNewResources(github(["*"]), github(["*"]))).toBe(false);- });-- test("is false for a project-scoped GitLab data source", () => {- const gitlab = {- type: SecretScanningDataSource.GitLab,- config: { scope: GitLabDataSourceScope.Project, projectId: 1 }- } as Parameters<typeof doesConfigUpdateIncludeNewResources>[0];-- expect(doesConfigUpdateIncludeNewResources(gitlab, gitlab)).toBe(false);- });-});--describe("isResourceIncludedByConfig", () => {- test("matches listed names exactly", () => {- const dataSource = {- type: SecretScanningDataSource.Bitbucket,- config: { includeRepos: ["acme/api"] }- } as Parameters<typeof isResourceIncludedByConfig>[0];-- expect(isResourceIncludedByConfig(dataSource, "acme/api")).toBe(true);- expect(isResourceIncludedByConfig(dataSource, "acme/web")).toBe(false);- });-- test("includes every resource for a wildcard", () => {- const dataSource = {- type: SecretScanningDataSource.GitLab,- config: { scope: GitLabDataSourceScope.Group, groupId: 1, includeProjects: ["*"] }- } as Parameters<typeof isResourceIncludedByConfig>[0];-- expect(isResourceIncludedByConfig(dataSource, "acme/anything")).toBe(true);- });-});--describe("getConfigIncludingAllResources", () => {- test("widens a repository list to every repository and keeps the rest of the config", () => {- const dataSource = {- type: SecretScanningDataSource.Bitbucket,- config: { workspaceSlug: "acme", includeRepos: ["acme/api"] }- } as Parameters<typeof getConfigIncludingAllResources>[0];-- expect(getConfigIncludingAllResources(dataSource).config).toEqual({ workspaceSlug: "acme", includeRepos: ["*"] });- });-- test("leaves a project-scoped GitLab data source unchanged", () => {- const dataSource = {- type: SecretScanningDataSource.GitLab,- config: { scope: GitLabDataSourceScope.Project, projectId: 1 }- } as Parameters<typeof getConfigIncludingAllResources>[0];-- expect(getConfigIncludingAllResources(dataSource)).toBe(dataSource);- });-});diff --git a/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-fns.ts b/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-fns.tsindex 461ad0eac8..082b68269e 100644--- a/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-fns.ts+++ b/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-fns.ts@@ -30,12 +30,7 @@ import { logger } from "@app/lib/logger";import { GitLabDataSourceScope } from "./gitlab/gitlab-secret-scanning-enums";import { SecretScanningDataSource, SecretScanningFindingSeverity } from "./secret-scanning-v2-enums";-import {- TCloneRepository,- TGetFindingsPayload,- TSecretScanningDataSourceListItem,- TSecretScanningDataSourceTypeAndConfig-} from "./secret-scanning-v2-types";+import { TCloneRepository, TGetFindingsPayload, TSecretScanningDataSourceListItem } from "./secret-scanning-v2-types";const SECRET_SCANNING_SOURCE_LIST_OPTIONS: Record<SecretScanningDataSource, TSecretScanningDataSourceListItem> = {[SecretScanningDataSource.GitHub]: GITHUB_SECRET_SCANNING_DATA_SOURCE_LIST_OPTION,@@ -47,76 +42,6 @@ export const listSecretScanningDataSourceOptions = () => {return Object.values(SECRET_SCANNING_SOURCE_LIST_OPTIONS).sort((a, b) => a.name.localeCompare(b.name));};-export const doesDataSourceIncludeResources = (dataSource: TSecretScanningDataSourceTypeAndConfig) => {- switch (dataSource.type) {- case SecretScanningDataSource.GitHub:- case SecretScanningDataSource.Bitbucket:- return dataSource.config.includeRepos.length > 0;- case SecretScanningDataSource.GitLab:- return dataSource.config.scope === GitLabDataSourceScope.Project || dataSource.config.includeProjects.length > 0;- default:- return true;- }-};--// null means the config includes every resource the connection can see-const getIncludedResourceNames = (dataSource: TSecretScanningDataSourceTypeAndConfig) => {- let names: string[] | undefined;-- switch (dataSource.type) {- case SecretScanningDataSource.GitHub:- case SecretScanningDataSource.Bitbucket:- names = dataSource.config.includeRepos;- break;- case SecretScanningDataSource.GitLab:- if (dataSource.config.scope === GitLabDataSourceScope.Project) return null;- names = dataSource.config.includeProjects;- break;- default:- return null;- }-- return !names || names.includes("*") ? null : names;-};--export const isResourceIncludedByConfig = (- dataSource: TSecretScanningDataSourceTypeAndConfig,- resourceName: string-) => {- const names = getIncludedResourceNames(dataSource);- return names === null || names.includes(resourceName);-};--export const getConfigIncludingAllResources = <T extends { type: SecretScanningDataSource; config: unknown }>(- dataSource: T-): T => {- const { type, config } = dataSource as TSecretScanningDataSourceTypeAndConfig;-- switch (type) {- case SecretScanningDataSource.GitHub:- case SecretScanningDataSource.Bitbucket:- return { ...dataSource, config: { ...config, includeRepos: ["*"] } };- case SecretScanningDataSource.GitLab:- if (config.scope === GitLabDataSourceScope.Project) return dataSource;- return { ...dataSource, config: { ...config, includeProjects: ["*"] } };- default:- return dataSource;- }-};--export const doesConfigUpdateIncludeNewResources = (- current: TSecretScanningDataSourceTypeAndConfig,- next: TSecretScanningDataSourceTypeAndConfig-) => {- const currentNames = getIncludedResourceNames(current);- if (currentNames === null) return false;-- const nextNames = getIncludedResourceNames(next);- if (nextNames === null) return true;-- return nextNames.some((name) => !currentNames.includes(name));-};-// GitLab only reports new projects through group webhooks, so discovery needs a group. Self-hosted system// hooks would also work, but are not supported.export const doesDataSourceSupportDiscovery = ({ type, config }: { type: string; config?: unknown }) =>diff --git a/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-queue.ts b/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-queue.tsindex 720922e35d..f46d6dde46 100644--- a/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-queue.ts+++ b/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-queue.ts@@ -14,7 +14,6 @@ import {} from "@app/ee/services/secret-scanning/secret-scanning-queue/secret-scanning-fns";import {assertClonedRepositoryWithinSizeLimit,- getConfigIncludingAllResources,parseScanErrorMessage,planCommitBatches,repositoryHasCommits,@@ -175,15 +174,11 @@ export const secretScanningV2QueueServiceFactory = ({{resourceExternalId,triggeredByUserId,- shouldScanResource,- existingResourcesOnly+ shouldScanResource}: {resourceExternalId?: string;triggeredByUserId?: string;shouldScanResource?: (resource: Pick<TSecretScanningResourcesInsert, "externalId" | "name">) => boolean;- // The data source's resources are the ones added to it, not what its include list matches. The provider is- // still listed so a renamed resource is cloned under its current name and a deleted one is skipped.- existingResourcesOnly?: boolean;} = {}) => {try {@@ -194,17 +189,13 @@ export const secretScanningV2QueueServiceFactory = ({appConnectionDAL});- const rawResources = await factory.listRawResources(- existingResourcesOnly ? getConfigIncludingAllResources(dataSource) : dataSource- );-- let filteredRawResources = rawResources;+ // Only the data source's resources are scanned. The provider is still listed so a renamed resource is cloned+ // under its current name and a deleted one is skipped.+ const rawResources = await factory.listRawResources(dataSource);+ const existingResources = await secretScanningV2DAL.resources.find({ dataSourceId: dataSource.id });+ const existingExternalIds = new Set(existingResources.map((resource) => resource.externalId));- if (existingResourcesOnly) {- const existingResources = await secretScanningV2DAL.resources.find({ dataSourceId: dataSource.id });- const existingExternalIds = new Set(existingResources.map((resource) => resource.externalId));- filteredRawResources = filteredRawResources.filter((resource) => existingExternalIds.has(resource.externalId));- }+ let filteredRawResources = rawResources.filter((resource) => existingExternalIds.has(resource.externalId));// TODO: should add individual resource fetch to factoryif (resourceExternalId) {diff --git a/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-service.ts b/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-service.tsindex 1fe874b422..ad6f25d18f 100644--- a/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-service.ts+++ b/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-service.ts@@ -24,12 +24,8 @@ import {} from "@app/ee/services/secret-scanning-v2/secret-scanning-v2-enums";import { SECRET_SCANNING_FACTORY_MAP } from "@app/ee/services/secret-scanning-v2/secret-scanning-v2-factory";import {- doesConfigUpdateIncludeNewResources,- doesDataSourceIncludeResources,doesDataSourceSupportDiscovery,- getConfigIncludingAllResources,isDataSourceWebhookRequired,- isResourceIncludedByConfig,listSecretScanningDataSourceOptions} from "@app/ee/services/secret-scanning-v2/secret-scanning-v2-fns";import {@@ -49,7 +45,6 @@ import {TSecretScanningDataSource,TSecretScanningDataSourceCredentials,TSecretScanningDataSourceInput,- TSecretScanningDataSourceTypeAndConfig,TSecretScanningDataSourceWithConnection,TSecretScanningDataSourceWithDetails,TSecretScanningFinding,@@ -387,38 +382,6 @@ export const secretScanningV2ServiceFactory = ({});- // A data source created with an empty include list has nothing to scan yet; queueing would only fail.- if (doesDataSourceIncludeResources(payload as TSecretScanningDataSourceTypeAndConfig)) {- const createdDataSourceWithConnection = {- ...createdDataSource,- connection- } as TSecretScanningDataSourceWithConnection;-- try {- // The include list is only read here: from now on the data source covers the resources it has rows for.- if (payload.isHistoricalScanEnabled) {- await secretScanningV2Queue.queueDataSourceFullScan(createdDataSourceWithConnection, {- triggeredByUserId: actor.type === ActorType.USER ? actor.id : undefined- });- } else {- const rawResources = await factory.listRawResources(createdDataSourceWithConnection);-- if (rawResources.length) {- await secretScanningV2DAL.resources.upsert(- rawResources.map((resource) => ({ ...resource, dataSourceId: createdDataSource.id })),- ["externalId", "dataSourceId"]- );- }- }- } catch (error) {- // Deliberately non-fatal — the data source is saved, and its resources can still be added from it.- logger.error(- error,- `secretScanningV2Service: Failed to set up resources on data source creation [dataSourceId=${createdDataSource.id}] [projectId=${payload.projectId}]`- );- }- }-return createdDataSource as TSecretScanningDataSource;} catch (err) {if (err instanceof DatabaseError && (err.error as { code: string })?.code === DatabaseErrorCode.UniqueViolation) {@@ -568,68 +531,6 @@ export const secretScanningV2ServiceFactory = ({throw err;}- if (- doesConfigUpdateIncludeNewResources(- dataSource as TSecretScanningDataSourceTypeAndConfig,- updatedDataSource as TSecretScanningDataSourceTypeAndConfig- )- ) {- const isNewlyIncluded = (resource: { name: string }) =>- !isResourceIncludedByConfig(dataSource as TSecretScanningDataSourceTypeAndConfig, resource.name);- const updatedDataSourceWithConnection = {- ...updatedDataSource,- connection- } as TSecretScanningDataSourceWithConnection;-- try {- // Newly included resources have no history scanned yet, so they get the same historical scan a new data source does.- if (updatedDataSource.isHistoricalScanEnabled) {- await secretScanningV2Queue.queueDataSourceFullScan(updatedDataSourceWithConnection, {- triggeredByUserId: actor.type === ActorType.USER ? actor.id : undefined,- shouldScanResource: isNewlyIncluded- });- } else {- // Without a scan nothing would create the resource rows, and the resources wouldn't be listed until their next push.- const newResources = (await factory.listRawResources(updatedDataSourceWithConnection)).filter(- isNewlyIncluded- );-- if (newResources.length) {- await secretScanningV2DAL.resources.upsert(- newResources.map((resource) => ({ ...resource, dataSourceId })),- ["externalId", "dataSourceId"]- );- }- }-- const resources = await secretScanningV2DAL.resources.find({ dataSourceId });- const savedDataSource = await secretScanningV2DAL.dataSources.findById(dataSourceId);- const webhook = await prepareResourceWebhooks(- updatedDataSourceWithConnection,- savedDataSource?.encryptedCredentials,- resources.map((resource) => resource.name)- );-- if (webhook) {- try {- await secretScanningV2DAL.dataSources.updateById(dataSourceId, {- encryptedCredentials: webhook.encryptedCredentials- });- } catch (err) {- await webhook.revert();- throw err;- }- await webhook.finalize();- }- } catch (error) {- // Deliberately non-fatal: the include list is saved, and the resources can still be scanned manually.- logger.error(- error,- `secretScanningV2Service: Failed to set up newly included resources [dataSourceId=${dataSourceId}] [projectId=${dataSource.projectId}]`- );- }- }-return updatedDataSource;};@@ -770,8 +671,7 @@ export const secretScanningV2ServiceFactory = ({} as TSecretScanningDataSourceWithConnection,{resourceExternalId,- triggeredByUserId: actor.type === ActorType.USER ? actor.id : undefined,- existingResourcesOnly: true+ triggeredByUserId: actor.type === ActorType.USER ? actor.id : undefined});@@ -857,7 +757,7 @@ export const secretScanningV2ServiceFactory = ({let availableResources: Awaited<ReturnType<typeof factory.listRawResources>>;try {- availableResources = await factory.listRawResources(getConfigIncludingAllResources(dataSourceWithConnection));+ availableResources = await factory.listRawResources(dataSourceWithConnection);} catch (error) {if (error instanceof BadRequestError) throw error;@@ -924,7 +824,6 @@ export const secretScanningV2ServiceFactory = ({try {await secretScanningV2Queue.queueDataSourceFullScan(dataSourceWithConnection, {triggeredByUserId: actor.type === ActorType.USER ? actor.id : undefined,- existingResourcesOnly: true,shouldScanResource: (resource) => newExternalIds.has(resource.externalId)});} catch (error) {@@ -1108,12 +1007,10 @@ export const secretScanningV2ServiceFactory = ({let rawResources: Awaited<ReturnType<typeof factory.listRawResources>>;try {- rawResources = await factory.listRawResources(- getConfigIncludingAllResources({- ...dataSource,- connection- } as TSecretScanningDataSourceWithConnection)- );+ rawResources = await factory.listRawResources({+ ...dataSource,+ connection+ } as TSecretScanningDataSourceWithConnection);} catch (error) {if (error instanceof BadRequestError) throw error;diff --git a/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-types.ts b/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-types.tsindex 244b0b93f7..aae4669645 100644--- a/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-types.ts+++ b/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-types.ts@@ -41,13 +41,6 @@ import { TKmsServiceFactory } from "@app/services/kms/kms-service";export type TSecretScanningDataSource = TGitHubDataSource | TBitbucketDataSource | TGitLabDataSource;-// The data source schemas type `type` as the whole enum rather than their own member, so this pairs each-// literal with its config by hand to let a check on `type` narrow `config`.-export type TSecretScanningDataSourceTypeAndConfig =- | { type: SecretScanningDataSource.GitHub; config: TGitHubDataSource["config"] }- | { type: SecretScanningDataSource.Bitbucket; config: TBitbucketDataSource["config"] }- | { type: SecretScanningDataSource.GitLab; config: TGitLabDataSource["config"] };-export type TSecretScanningDataSourceWithDetails = TSecretScanningDataSource & {lastScannedAt?: Date | null;lastScanStatus?: SecretScanningScanStatus | null;diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex e26b5eb138..5e39bd8bf3 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -4003,24 +4003,16 @@ export const SecretScanningDataSources = {resourceId: "The ID of the resource to remove. Its scans and findings are deleted with it."}),CONFIG: {- GITHUB: {- includeRepos:- 'The repositories to include when scanning. Use ["*"] for all repositories or an empty list for none. Defaults to all repositories (["*"]).'- },GITLAB: {- includeProjects:- 'The projects to include when scanning. Use ["*"] for all projects or an empty list for none. Defaults to all projects (["*"]).',scope:- "The GitLab scope scanning should occur at: account (every project the connection can read), group, or project (deprecated, kept for existing Data Sources).",+ "Where projects are added from: account (projects the connection can read, added one at a time), group, or project (deprecated, kept for existing Data Sources).",projectId: "The ID of the project to scan.",projectName: "The name of the project to scan.",groupId: "The ID of the group to scan projects from.",groupName: "The name of the group to scan projects from."},BITBUCKET: {- workspaceSlug: "The workspace to scan.",- includeRepos:- 'The repositories to include when scanning. Use ["*"] for all repositories or an empty list for none. Defaults to all repositories (["*"]).'+ workspaceSlug: "The workspace to scan."}}};diff --git a/frontend/src/components/secret-scanning/forms/CreateSecretScanningDataSourceForm.tsx b/frontend/src/components/secret-scanning/forms/CreateSecretScanningDataSourceForm.tsxindex 176ac816e6..5d2fd77458 100644--- a/frontend/src/components/secret-scanning/forms/CreateSecretScanningDataSourceForm.tsx+++ b/frontend/src/components/secret-scanning/forms/CreateSecretScanningDataSourceForm.tsx@@ -51,11 +51,11 @@ enum FormStep {const getDefaultConfig = (type: SecretScanningDataSource) => {switch (type) {case SecretScanningDataSource.GitHub:- return { includeRepos: [] };+ return {};case SecretScanningDataSource.Bitbucket:- return { workspaceSlug: "", includeRepos: [] };+ return { workspaceSlug: "" };case SecretScanningDataSource.GitLab:- return { scope: GitLabDataSourceScope.Account, includeProjects: [] };+ return { scope: GitLabDataSourceScope.Account };default:throw new Error(`Unhandled data source type: ${type}`);}diff --git a/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceConfigFields/GitLabDataSourceConfigFields.tsx b/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceConfigFields/GitLabDataSourceConfigFields.tsxindex 7edb0d14c5..6147c4d573 100644--- a/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceConfigFields/GitLabDataSourceConfigFields.tsx+++ b/frontend/src/components/secret-scanning/forms/SecretScanningDataSourceConfigFields/GitLabDataSourceConfigFields.tsx@@ -59,7 +59,6 @@ export const GitLabDataSourceConnectionFields = () => {// @ts-expect-error rhf doesn't like this but we need to resetsetValue("config.groupId", group ? Number(group.id) : undefined);setValue("config.groupName", group?.fullName ?? "");- setValue("config.includeProjects", []);setValue("isDiscoveryEnabled", Boolean(group));};diff --git a/frontend/src/components/secret-scanning/forms/schemas/bitbucket-data-source-schema.ts b/frontend/src/components/secret-scanning/forms/schemas/bitbucket-data-source-schema.tsindex 7ff420f498..c8923be346 100644--- a/frontend/src/components/secret-scanning/forms/schemas/bitbucket-data-source-schema.ts+++ b/frontend/src/components/secret-scanning/forms/schemas/bitbucket-data-source-schema.ts@@ -8,8 +8,7 @@ export const BitbucketDataSourceSchema = z.object({type: z.literal(SecretScanningDataSource.Bitbucket),config: z.object({- workspaceSlug: z.string().min(1, "Workspace Required").max(128),- includeRepos: z.string().array().max(100, "Cannot configure more than 100 repositories")+ workspaceSlug: z.string().min(1, "Workspace Required").max(128)})}).merge(BaseSecretScanningDataSourceSchema({ isConnectionRequired: true }));diff --git a/frontend/src/components/secret-scanning/forms/schemas/github-data-source-schema.ts b/frontend/src/components/secret-scanning/forms/schemas/github-data-source-schema.tsindex 226f73bcf1..e72c14dff1 100644--- a/frontend/src/components/secret-scanning/forms/schemas/github-data-source-schema.ts+++ b/frontend/src/components/secret-scanning/forms/schemas/github-data-source-schema.ts@@ -7,8 +7,6 @@ import { BaseSecretScanningDataSourceSchema } from "./base-secret-scanning-data-export const GitHubDataSourceSchema = z.object({type: z.literal(SecretScanningDataSource.GitHub),- config: z.object({- includeRepos: z.string().array().max(100, "Cannot configure more than 100 repositories")- })+ config: z.object({})}).merge(BaseSecretScanningDataSourceSchema({ isConnectionRequired: true }));diff --git a/frontend/src/components/secret-scanning/forms/schemas/gitlab-data-source-schema.ts b/frontend/src/components/secret-scanning/forms/schemas/gitlab-data-source-schema.tsindex b803c10d61..73dd204f43 100644--- a/frontend/src/components/secret-scanning/forms/schemas/gitlab-data-source-schema.ts+++ b/frontend/src/components/secret-scanning/forms/schemas/gitlab-data-source-schema.ts@@ -5,10 +5,6 @@ import { GitLabDataSourceScope } from "@app/hooks/api/secretScanningV2/types/gitimport { BaseSecretScanningDataSourceSchema } from "./base-secret-scanning-data-source-schema";-const IncludeProjectsSchema = z- .array(z.string().min(1).max(256))- .max(100, "Cannot configure more than 100 projects");-export const GitLabDataSourceSchema = z.object({type: z.literal(SecretScanningDataSource.GitLab),@@ -16,12 +12,10 @@ export const GitLabDataSourceSchema = zz.object({scope: z.literal(GitLabDataSourceScope.Group),groupId: z.number(),- groupName: z.string(),- includeProjects: IncludeProjectsSchema+ groupName: z.string()}),z.object({- scope: z.literal(GitLabDataSourceScope.Account),- includeProjects: IncludeProjectsSchema+ scope: z.literal(GitLabDataSourceScope.Account)}),z.object({scope: z.literal(GitLabDataSourceScope.Project),diff --git a/frontend/src/hooks/api/secretScanningV2/types/bitbucket-data-source.ts b/frontend/src/hooks/api/secretScanningV2/types/bitbucket-data-source.tsindex d9e7eb929a..5de8ef5036 100644--- a/frontend/src/hooks/api/secretScanningV2/types/bitbucket-data-source.ts+++ b/frontend/src/hooks/api/secretScanningV2/types/bitbucket-data-source.ts@@ -7,7 +7,6 @@ export type TBitbucketDataSource = TSecretScanningDataSourceBase & {type: SecretScanningDataSource.Bitbucket;config: {workspaceSlug: string;- includeRepos: string[];};};diff --git a/frontend/src/hooks/api/secretScanningV2/types/github-data-source.ts b/frontend/src/hooks/api/secretScanningV2/types/github-data-source.tsindex 8931e4eee1..d18f9699d4 100644--- a/frontend/src/hooks/api/secretScanningV2/types/github-data-source.ts+++ b/frontend/src/hooks/api/secretScanningV2/types/github-data-source.ts@@ -5,9 +5,7 @@ import { TSecretScanningDataSourceBase } from "./shared";export type TGitHubDataSource = TSecretScanningDataSourceBase & {type: SecretScanningDataSource.GitHub;- config: {- includeRepos: string[];- };+ config: Record<string, never>;};export type TGitHubDataSourceOption = {diff --git a/frontend/src/hooks/api/secretScanningV2/types/gitlab-data-source.ts b/frontend/src/hooks/api/secretScanningV2/types/gitlab-data-source.tsindex c8d97ed2ab..bab522c188 100644--- a/frontend/src/hooks/api/secretScanningV2/types/gitlab-data-source.ts+++ b/frontend/src/hooks/api/secretScanningV2/types/gitlab-data-source.ts@@ -16,11 +16,9 @@ export type TGitLabDataSource = TSecretScanningDataSourceBase & {| {groupId: number;groupName?: string;- includeProjects: string[];scope: GitLabDataSourceScope.Group;}| {- includeProjects: string[];scope: GitLabDataSourceScope.Account;}| {