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
update add repositories and settings
Matheus Nogueirab07bcc452014
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.tsindex 9f49c3df5b..773315f315 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@@ -580,6 +580,44 @@ export const registerSecretScanningEndpoints = <}});+ // not exposed, for UI only+ server.route({+ method: "GET",+ url: "/:dataSourceId/available-resources",+ config: {+ rateLimit: readLimit+ },+ schema: {+ operationId: `list${sourceTypeId}DataSourceAvailableResources`,+ tags: [ApiDocsTags.SecretScanning],+ params: z.object({+ dataSourceId: z.string().uuid()+ }),+ response: {+ 200: z.object({+ resources: z+ .object({+ externalId: z.string(),+ name: z.string(),+ isIncluded: z.boolean()+ })+ .array()+ })+ }+ },+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.OAUTH]),+ handler: async (req) => {+ const { dataSourceId } = req.params;++ const { resources } = await server.services.secretScanningV2.listSecretScanningAvailableResourcesByDataSourceId(+ { dataSourceId, type },+ req.permission+ );++ return { resources };+ }+ });+server.route({method: "GET",url: "/:dataSourceId/scans-dashboard",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 c41aff5f2c..a258ce7020 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,8 +11,13 @@ 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,@@ -298,3 +303,74 @@ 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 363e88139d..515d402ddc 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@@ -59,6 +59,64 @@ export const doesDataSourceIncludeResources = (dataSource: TSecretScanningDataSo}};+// null means the config includes every resource the connection can see+const getIncludedResourceNames = (dataSource: Pick<TSecretScanningDataSourceInput, "type" | "config">) => {+ 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: Pick<TSecretScanningDataSourceInput, "type" | "config">,+ resourceName: string+) => {+ const names = getIncludedResourceNames(dataSource);+ return names === null || names.includes(resourceName);+};++export const getConfigIncludingAllResources = <T extends Pick<TSecretScanningDataSourceInput, "type" | "config">>(+ dataSource: T+): T => {+ const { type, config } = dataSource as Pick<TSecretScanningDataSourceInput, "type" | "config">;++ 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: Pick<TSecretScanningDataSourceInput, "type" | "config">,+ next: Pick<TSecretScanningDataSourceInput, "type" | "config">+) => {+ 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 88064b14b9..818c09d60b 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@@ -171,7 +171,15 @@ export const secretScanningV2QueueServiceFactory = ({const queueDataSourceFullScan = async (dataSource: TSecretScanningDataSourceWithConnection,- { resourceExternalId, triggeredByUserId }: { resourceExternalId?: string; triggeredByUserId?: string } = {}+ {+ resourceExternalId,+ triggeredByUserId,+ shouldScanResource+ }: {+ resourceExternalId?: string;+ triggeredByUserId?: string;+ shouldScanResource?: (resource: Pick<TSecretScanningResourcesInsert, "externalId" | "name">) => boolean;+ } = {}) => {try {const { type } = dataSource;@@ -190,6 +198,10 @@ export const secretScanningV2QueueServiceFactory = ({filteredRawResources = rawResources.filter((resource) => resource.externalId === resourceExternalId);}+ if (shouldScanResource) {+ filteredRawResources = filteredRawResources.filter(shouldScanResource);+ }+if (!filteredRawResources.length) {throw new BadRequestError({message: `${resourceExternalId ? `Resource with "ID" ${resourceExternalId} could not be found.` : "Data source has no resources to scan"}. Ensure your data source config is correct and not filtering out scanning resources.`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 2c4d042843..4d22a6dab8 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@@ -20,9 +20,12 @@ import { githubSecretScanningService } from "@app/ee/services/secret-scanning-v2import { SecretScanningFindingStatus } 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 {@@ -475,13 +478,13 @@ export const secretScanningV2ServiceFactory = ({encryptedCredentials = null;}+ let updatedDataSource: TSecretScanningDataSource;+try {- const updatedDataSource = await secretScanningV2DAL.dataSources.updateById(dataSourceId, {+ updatedDataSource = (await secretScanningV2DAL.dataSources.updateById(dataSourceId, {...payload,...(encryptedCredentials !== undefined && { encryptedCredentials })- });-- return updatedDataSource as TSecretScanningDataSource;+ })) as TSecretScanningDataSource;} catch (err) {if (createdCredentials) {await factory.teardown({ dataSource: dataSourceWithConnection, credentials: createdCredentials });@@ -495,6 +498,50 @@ export const secretScanningV2ServiceFactory = ({throw err;}++ if (+ doesConfigUpdateIncludeNewResources(+ dataSource as TSecretScanningDataSourceInput,+ updatedDataSource as TSecretScanningDataSourceInput+ )+ ) {+ const isNewlyIncluded = (resource: { name: string }) =>+ !isResourceIncludedByConfig(dataSource as TSecretScanningDataSourceInput, 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"]+ );+ }+ }+ } 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;};const deleteSecretScanningDataSource = async (@@ -683,6 +730,82 @@ export const secretScanningV2ServiceFactory = ({return { resources, projectId: dataSource.projectId };};+ // Lists what the data source's connection can see, so a user can pick resources to add to its include list.+ const listSecretScanningAvailableResourcesByDataSourceId = async (+ { type, dataSourceId }: TFindSecretScanningDataSourceByIdDTO,+ actor: OrgServiceActor+ ) => {+ const dataSource = await secretScanningV2DAL.dataSources.findById(dataSourceId);++ if (!dataSource)+ throw new NotFoundError({+ message: `Could not find ${SECRET_SCANNING_DATA_SOURCE_NAME_MAP[type]} Data Source with ID "${dataSourceId}"`+ });++ const { permission } = await permissionService.getProjectPermission({+ actor: actor.type,+ actorId: actor.id,+ actorAuthMethod: actor.authMethod,+ actorOrgId: actor.orgId,+ actionProjectType: ActionProjectType.SecretScanning,+ projectId: dataSource.projectId+ });++ ForbiddenError.from(permission).throwUnlessCan(+ ProjectPermissionSecretScanningDataSourceActions.ReadResources,+ ProjectPermissionSub.SecretScanningDataSources+ );++ if (type !== dataSource.type)+ throw new BadRequestError({+ message: `Secret Scanning Data Source with ID "${dataSourceId}" is not configured for ${SECRET_SCANNING_DATA_SOURCE_NAME_MAP[type]}`+ });++ const sourceName = SECRET_SCANNING_DATA_SOURCE_NAME_MAP[type];++ if (dataSource.isDisconnected)+ throw new BadRequestError({+ message: `Data Source "${dataSource.name}" is disconnected from ${sourceName}, so its resources can't be listed. Delete it and connect ${sourceName} again.`+ });++ let connection: TAppConnection | null = null;+ if (dataSource.connection) connection = await decryptAppConnection(dataSource.connection, kmsService);++ const factory = SECRET_SCANNING_FACTORY_MAP[dataSource.type]({+ appConnectionDAL,+ kmsService+ });++ let rawResources: Awaited<ReturnType<typeof factory.listRawResources>>;+ try {+ rawResources = await factory.listRawResources(+ getConfigIncludingAllResources({+ ...dataSource,+ connection+ } as TSecretScanningDataSourceWithConnection)+ );+ } catch (error) {+ if (error instanceof BadRequestError) throw error;++ logger.error(+ error,+ `secretScanningV2Service: Failed to list available resources [dataSourceId=${dataSourceId}] [projectId=${dataSource.projectId}]`+ );+ throw new BadRequestError({+ message: `Could not list resources from ${sourceName} for Data Source "${dataSource.name}". Check that its App Connection still has access, then try again.`+ });+ }++ const resources = rawResources+ .map((resource) => ({+ ...resource,+ isIncluded: isResourceIncludedByConfig(dataSource as TSecretScanningDataSourceInput, resource.name)+ }))+ .sort((a, b) => a.name.localeCompare(b.name));++ return { resources, projectId: dataSource.projectId };+ };+const listSecretScanningScansByDataSourceId = async ({ type, dataSourceId }: TFindSecretScanningDataSourceByIdDTO,actor: OrgServiceActor@@ -1028,6 +1151,7 @@ export const secretScanningV2ServiceFactory = ({deleteSecretScanningDataSource,triggerSecretScanningDataSourceScan,listSecretScanningResourcesByDataSourceId,+ listSecretScanningAvailableResourcesByDataSourceId,listSecretScanningScansByDataSourceId,listSecretScanningResourcesWithDetailsByDataSourceId,listSecretScanningScansWithDetailsByDataSourceId,diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex 99b47f0015..866c76e961 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -3960,7 +3960,7 @@ export const SecretScanningDataSources = {APP_CONNECTION_NAME_MAP[SECRET_SCANNING_DATA_SOURCE_CONNECTION_MAP[type]]} Connection to use for this Data Source.`,isAutoScanEnabled: `Deprecated: use isHistoricalScanEnabled and isScanNewCommitsEnabled. Sets both when they are not provided.`,- isHistoricalScanEnabled: `Whether a full scan of existing history runs for ${autoScanDescription.noun} when this Data Source is created. Defaults to true.`,+ isHistoricalScanEnabled: `Whether a full scan of existing history runs for ${autoScanDescription.noun} when this Data Source is created, and for ${autoScanDescription.noun} added to its configuration later. Defaults to true.`,isScanNewCommitsEnabled: `Whether a scan runs when a ${autoScanDescription.verb} occurs to ${autoScanDescription.noun} associated with this Data Source. Defaults to true.`,isDiscoveryEnabled: `Whether ${autoScanDescription.noun} added to the provider after setup are scanned automatically. Defaults to true, except for GitLab project scope, which does not support it.`,config: `The configuration parameters to use for this Data Source.`@@ -3975,7 +3975,7 @@ export const SecretScanningDataSources = {name: `The updated name of the ${typeName} Data Source. Must be slug-friendly.`,description: `The updated description of the ${typeName} Data Source.`,isAutoScanEnabled: `Deprecated: use isHistoricalScanEnabled and isScanNewCommitsEnabled. Sets both when they are not provided.`,- isHistoricalScanEnabled: `Whether a full scan of existing history runs for ${autoScanDescription.noun} when this Data Source is created.`,+ isHistoricalScanEnabled: `Whether a full scan of existing history runs for ${autoScanDescription.noun} added to this Data Source's configuration.`,isScanNewCommitsEnabled: `Whether a scan runs when a ${autoScanDescription.verb} occurs to ${autoScanDescription.noun} associated with this Data Source.`,isDiscoveryEnabled: `Whether ${autoScanDescription.noun} added to the provider after setup are scanned automatically. Not supported for GitLab project scope.`,config: `The updated configuration parameters to use for this Data Source.`diff --git a/frontend/src/components/secret-scanning/DeleteSecretScanningDataSourceModal.tsx b/frontend/src/components/secret-scanning/DeleteSecretScanningDataSourceModal.tsxindex 8cbfc5aeab..13e210ede2 100644--- a/frontend/src/components/secret-scanning/DeleteSecretScanningDataSourceModal.tsx+++ b/frontend/src/components/secret-scanning/DeleteSecretScanningDataSourceModal.tsx@@ -52,7 +52,7 @@ export const DeleteSecretScanningDataSourceModal = ({onDeleteApproved={handleDeleteDataSource}><p className="mt-1 font-sans text-sm text-muted">- Findings associated with this data source will be preserved.+ This permanently deletes the findings and scan history of this data source.</p></DeleteActionModal>);diff --git a/frontend/src/helpers/secretScanningV2.ts b/frontend/src/helpers/secretScanningV2.tsindex d8d6062df4..736fa1e43f 100644--- a/frontend/src/helpers/secretScanningV2.ts+++ b/frontend/src/helpers/secretScanningV2.ts@@ -52,6 +52,73 @@ export const doesDataSourceSupportDiscovery = ({(config as { scope?: string } | undefined)?.scope !== GitLabDataSourceScope.Group);+// a project-scoped GitLab data source scans exactly one project, so it has no include list to add to+export const canAddSecretScanningResources = (dataSource: TSecretScanningDataSource) =>+ !(+ dataSource.type === SecretScanningDataSource.GitLab &&+ dataSource.config.scope === GitLabDataSourceScope.Project+ );++export const getConfigWithIncludedResource = (+ dataSource: TSecretScanningDataSource,+ resourceName: string+): TSecretScanningDataSource["config"] | null => {+ const append = (names: string[]) => [...names.filter((name) => name !== "*"), resourceName];++ switch (dataSource.type) {+ case SecretScanningDataSource.Bitbucket:+ case SecretScanningDataSource.GitHub:+ return { ...dataSource.config, includeRepos: append(dataSource.config.includeRepos) };+ case SecretScanningDataSource.GitLab:+ if (dataSource.config.scope === GitLabDataSourceScope.Project) return null;+ return {+ ...dataSource.config,+ includeProjects: append(dataSource.config.includeProjects)+ };+ default:+ return null;+ }+};++// mirrors what the backend does with resources added to the include list+export const getAddedResourceScanDescription = (+ dataSource: Pick<TSecretScanningDataSource, "isHistoricalScanEnabled" | "isScanNewCommitsEnabled">+) => {+ if (dataSource.isHistoricalScanEnabled) return "Their full history will be scanned for secrets.";+ if (dataSource.isScanNewCommitsEnabled) return "Only commits pushed from now on will be scanned.";+ return "Nothing will be scanned until Historical Scan or Scan New Commits is turned on in Settings.";+};++export const getConfigWithAllResourcesIncluded = (+ dataSource: TSecretScanningDataSource+): TSecretScanningDataSource["config"] | null => {+ switch (dataSource.type) {+ case SecretScanningDataSource.Bitbucket:+ case SecretScanningDataSource.GitHub:+ return { ...dataSource.config, includeRepos: ["*"] };+ case SecretScanningDataSource.GitLab:+ if (dataSource.config.scope === GitLabDataSourceScope.Project) return null;+ return { ...dataSource.config, includeProjects: ["*"] };+ default:+ return null;+ }+};++export const areAllSecretScanningResourcesIncluded = (dataSource: TSecretScanningDataSource) => {+ switch (dataSource.type) {+ case SecretScanningDataSource.Bitbucket:+ case SecretScanningDataSource.GitHub:+ return dataSource.config.includeRepos.includes("*");+ case SecretScanningDataSource.GitLab:+ return (+ dataSource.config.scope === GitLabDataSourceScope.Project ||+ dataSource.config.includeProjects.includes("*")+ );+ default:+ return false;+ }+};+export const isSecretScanningResourceIncluded = (dataSource: TSecretScanningDataSource,resourceName: stringdiff --git a/frontend/src/hooks/api/secretScanningV2/queries.tsx b/frontend/src/hooks/api/secretScanningV2/queries.tsxindex 533c9c5488..3b4e0ce5c6 100644--- a/frontend/src/hooks/api/secretScanningV2/queries.tsx+++ b/frontend/src/hooks/api/secretScanningV2/queries.tsx@@ -6,6 +6,7 @@ import {TGetSecretScanningConfigResponse,TGetSecretScanningDataSource,TGetSecretScanningUnresolvedFindingsResponse,+ TListSecretScanningAvailableResourcesResponse,TListSecretScanningBasicDataSources,TListSecretScanningBasicResourcesResponse,TListSecretScanningDataSourceOptions,@@ -14,6 +15,7 @@ import {TListSecretScanningFindingsResponse,TListSecretScanningResourcesResponse,TListSecretScanningScansResponse,+ TSecretScanningAvailableResource,TSecretScanningConfig,TSecretScanningDataSource,TSecretScanningDataSourceOption,@@ -49,6 +51,10 @@ export const secretScanningV2Keys = {...secretScanningV2Keys.listResources(dataSourceId),"basic"],+ listAvailableResources: (dataSourceId: string) => [+ ...secretScanningV2Keys.listResources(dataSourceId),+ "available"+ ],listResources: (dataSourceId: string) => [...secretScanningV2Keys.dataSource(),"resources",@@ -263,6 +269,31 @@ export const useListSecretScanningResources = (});};+export const useListSecretScanningAvailableResources = (+ { dataSourceId, type }: TGetSecretScanningDataSource,+ options?: Omit<+ UseQueryOptions<+ TSecretScanningAvailableResource[],+ unknown,+ TSecretScanningAvailableResource[],+ ReturnType<typeof secretScanningV2Keys.listAvailableResources>+ >,+ "queryKey" | "queryFn"+ >+) => {+ return useQuery({+ queryKey: secretScanningV2Keys.listAvailableResources(dataSourceId),+ queryFn: async () => {+ const { data } = await apiRequest.get<TListSecretScanningAvailableResourcesResponse>(+ `/api/v2/secret-scanning/data-sources/${type}/${dataSourceId}/available-resources`+ );++ return data.resources;+ },+ ...options+ });+};+export const useListSecretScanningScans = ({ dataSourceId, type }: TGetSecretScanningDataSource,options?: Omit<@@ -340,8 +371,10 @@ export const useGetSecretScanningConfig = (projectId: string,options?: Omit<UseQueryOptions<+ TSecretScanningAvailableResource,TSecretScanningConfig,unknown,+ TSecretScanningAvailableResource,TSecretScanningConfig,ReturnType<typeof secretScanningV2Keys.configByProjectId>>,diff --git a/frontend/src/hooks/api/secretScanningV2/types/index.ts b/frontend/src/hooks/api/secretScanningV2/types/index.tsindex 1c03d4d4f8..046f0bc03f 100644--- a/frontend/src/hooks/api/secretScanningV2/types/index.ts+++ b/frontend/src/hooks/api/secretScanningV2/types/index.ts@@ -129,6 +129,16 @@ export type TListSecretScanningBasicResourcesResponse = {resources: TSecretScanningResource[];};+export type TSecretScanningAvailableResource = {+ externalId: string;+ name: string;+ isIncluded: boolean;+};++export type TListSecretScanningAvailableResourcesResponse = {+ resources: TSecretScanningAvailableResource[];+};+export type TSecretScanningScanWithDetails = {id: string;createdAt: string;diff --git a/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/AddSecretScanningResourceSheet.tsx b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/AddSecretScanningResourceSheet.tsxnew file mode 100644index 0000000000..f4bc27bf71--- /dev/null+++ b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/AddSecretScanningResourceSheet.tsx@@ -0,0 +1,187 @@+import { useMemo, useState } from "react";+import { FolderGitIcon, SearchIcon } from "lucide-react";++import { createNotification } from "@app/components/notifications";+import {+ Button,+ Empty,+ EmptyDescription,+ EmptyHeader,+ EmptyMedia,+ EmptyTitle,+ InputGroup,+ InputGroupAddon,+ InputGroupInput,+ Item,+ ItemActions,+ ItemContent,+ ItemGroup,+ ItemTitle,+ Sheet,+ SheetContent,+ SheetDescription,+ SheetFooter,+ SheetHeader,+ SheetTitle,+ Skeleton+} from "@app/components/v3";+import {+ getAddedResourceScanDescription,+ getConfigWithIncludedResource,+ RESOURCE_DESCRIPTION_HELPER,+ SECRET_SCANNING_DATA_SOURCE_MAP+} from "@app/helpers/secretScanningV2";+import {+ TSecretScanningDataSource,+ useListSecretScanningAvailableResources,+ useUpdateSecretScanningDataSource+} from "@app/hooks/api/secretScanningV2";++type Props = {+ dataSource: TSecretScanningDataSource;+ isOpen: boolean;+ onOpenChange: (isOpen: boolean) => void;+};++export const AddSecretScanningResourceSheet = ({ dataSource, isOpen, onOpenChange }: Props) => {+ const [search, setSearch] = useState("");+ const [pendingName, setPendingName] = useState<string | null>(null);++ const { data: resources = [], isPending } = useListSecretScanningAvailableResources(+ { dataSourceId: dataSource.id, type: dataSource.type },+ { enabled: isOpen }+ );++ const updateDataSource = useUpdateSecretScanningDataSource();++ const resourceDetails = RESOURCE_DESCRIPTION_HELPER[dataSource.type];+ const { name: platform } = SECRET_SCANNING_DATA_SOURCE_MAP[dataSource.type];++ const availableResources = useMemo(() => {+ const searchValue = search.trim().toLowerCase();++ return resources.filter(+ ({ name, isIncluded }) => !isIncluded && name.toLowerCase().includes(searchValue)+ );+ }, [resources, search]);++ const hasExcludedResources = resources.some(({ isIncluded }) => !isIncluded);++ const handleEnableScanning = async (resourceName: string) => {+ const config = getConfigWithIncludedResource(dataSource, resourceName);+ if (!config) return;++ setPendingName(resourceName);+ try {+ await updateDataSource.mutateAsync({+ dataSourceId: dataSource.id,+ type: dataSource.type,+ projectId: dataSource.projectId,+ config+ });+ } finally {+ setPendingName(null);+ }++ createNotification({+ text: `Added "${resourceName}". ${getAddedResourceScanDescription(dataSource)}`,+ type: "success"+ });+ };++ const renderList = () => {+ if (isPending) {+ return (+ <ItemGroup className="gap-2">+ {["first", "second", "third"].map((row) => (+ <Skeleton key={`available-resource-skeleton-${row}`} className="h-12 w-full" />+ ))}+ </ItemGroup>+ );+ }++ if (!availableResources.length) {+ return (+ <Empty className="border">+ <EmptyHeader>+ <EmptyMedia variant="icon">+ {hasExcludedResources ? <SearchIcon /> : <FolderGitIcon />}+ </EmptyMedia>+ <EmptyTitle>+ {hasExcludedResources+ ? `No ${resourceDetails.pluralNoun} match your search`+ : `No ${resourceDetails.pluralNoun} left to add`}+ </EmptyTitle>+ <EmptyDescription>+ {hasExcludedResources+ ? "Try a different search term."+ : `Every ${resourceDetails.singularNoun} this connection can access is already being scanned. Don't see one? Check that the App Connection has access to it in ${platform}.`}+ </EmptyDescription>+ </EmptyHeader>+ </Empty>+ );+ }++ return (+ <ItemGroup className="gap-2">+ {availableResources.map(({ externalId, name }) => (+ <Item key={externalId} variant="outline" size="sm">+ <ItemContent className="min-w-0">+ <ItemTitle className="truncate">{name}</ItemTitle>+ </ItemContent>+ <ItemActions>+ <Button+ variant="outline"+ size="xs"+ isPending={pendingName === name}+ isDisabled={Boolean(pendingName)}+ onClick={() => handleEnableScanning(name)}+ >+ Enable Scanning+ </Button>+ </ItemActions>+ </Item>+ ))}+ </ItemGroup>+ );+ };++ return (+ <Sheet+ open={isOpen}+ onOpenChange={(open) => {+ if (!open) setSearch("");+ onOpenChange(open);+ }}+ >+ <SheetContent onOpenAutoFocus={(event) => event.preventDefault()}>+ <SheetHeader>+ <SheetTitle>Add {resourceDetails.singularTitle}</SheetTitle>+ <SheetDescription>+ Enable scanning for a {resourceDetails.singularNoun} from {dataSource.name}.+ {dataSource.isHistoricalScanEnabled &&+ ` Its full history is scanned as soon as it's added.`}+ </SheetDescription>+ </SheetHeader>+ <div className="flex flex-1 flex-col gap-3 overflow-y-auto p-4">+ <InputGroup>+ <InputGroupAddon align="inline-start">+ <SearchIcon />+ </InputGroupAddon>+ <InputGroupInput+ value={search}+ onChange={(e) => setSearch(e.target.value)}+ placeholder={`Search ${resourceDetails.pluralNoun}...`}+ />+ </InputGroup>+ {renderList()}+ </div>+ <SheetFooter className="justify-end">+ <Button variant="outline" onClick={() => onOpenChange(false)}>+ Done+ </Button>+ </SheetFooter>+ </SheetContent>+ </Sheet>+ );+};diff --git a/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/AddSecretScanningResourcesButton.tsx b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/AddSecretScanningResourcesButton.tsxnew file mode 100644index 0000000000..20cb51a376--- /dev/null+++ b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/AddSecretScanningResourcesButton.tsx@@ -0,0 +1,135 @@+import { useState } from "react";+import { ChevronDownIcon, ListPlusIcon, PlusIcon } from "lucide-react";++import { createNotification } from "@app/components/notifications";+import { ProjectPermissionCan } from "@app/components/permissions";+import {+ AlertDialog,+ AlertDialogAction,+ AlertDialogCancel,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogFooter,+ AlertDialogHeader,+ AlertDialogTitle,+ Button,+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuTrigger+} from "@app/components/v3";+import { ProjectPermissionSub } from "@app/context";+import { ProjectPermissionSecretScanningDataSourceActions } from "@app/context/ProjectPermissionContext/types";+import {+ areAllSecretScanningResourcesIncluded,+ getAddedResourceScanDescription,+ getConfigWithAllResourcesIncluded,+ RESOURCE_DESCRIPTION_HELPER,+ SECRET_SCANNING_DATA_SOURCE_MAP+} from "@app/helpers/secretScanningV2";+import {+ TSecretScanningDataSource,+ useUpdateSecretScanningDataSource+} from "@app/hooks/api/secretScanningV2";++import { AddSecretScanningResourceSheet } from "./AddSecretScanningResourceSheet";++type Props = {+ dataSource: TSecretScanningDataSource;+};++export const AddSecretScanningResourcesButton = ({ dataSource }: Props) => {+ const [isSheetOpen, setIsSheetOpen] = useState(false);+ const [isAddAllOpen, setIsAddAllOpen] = useState(false);++ const updateDataSource = useUpdateSecretScanningDataSource();++ const { singularTitle, singularNoun, pluralTitle, pluralNoun } =+ RESOURCE_DESCRIPTION_HELPER[dataSource.type];+ const isEverythingIncluded = areAllSecretScanningResourcesIncluded(dataSource);++ const handleAddAll = async () => {+ const config = getConfigWithAllResourcesIncluded(dataSource);+ if (!config) return;++ await updateDataSource.mutateAsync({+ dataSourceId: dataSource.id,+ type: dataSource.type,+ projectId: dataSource.projectId,+ config+ });++ setIsAddAllOpen(false);+ createNotification({+ text: `Added all ${pluralNoun}. ${getAddedResourceScanDescription(dataSource)}`,+ type: "success"+ });+ };++ return (+ <>+ <ProjectPermissionCan+ I={ProjectPermissionSecretScanningDataSourceActions.Edit}+ a={ProjectPermissionSub.SecretScanningDataSources}+ >+ {(isAllowed) => (+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button variant="project" isDisabled={!isAllowed || dataSource.isDisconnected}>+ <ChevronDownIcon />+ Add {singularTitle}+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end">+ <DropdownMenuItem+ isDisabled={isEverythingIncluded}+ onClick={() => setIsSheetOpen(true)}+ >+ <PlusIcon />+ Add {singularTitle}+ </DropdownMenuItem>+ <DropdownMenuItem+ isDisabled={isEverythingIncluded}+ onClick={() => setIsAddAllOpen(true)}+ >+ <ListPlusIcon />+ Add All {pluralTitle}+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ )}+ </ProjectPermissionCan>+ <AddSecretScanningResourceSheet+ dataSource={dataSource}+ isOpen={isSheetOpen}+ onOpenChange={setIsSheetOpen}+ />+ <AlertDialog open={isAddAllOpen} onOpenChange={setIsAddAllOpen}>+ <AlertDialogContent>+ <AlertDialogHeader>+ <AlertDialogTitle>Add all {pluralNoun}?</AlertDialogTitle>+ <AlertDialogDescription>+ Every {singularNoun} the {SECRET_SCANNING_DATA_SOURCE_MAP[dataSource.type].name}{" "}+ connection can access will be added. {getAddedResourceScanDescription(dataSource)}+ {dataSource.isDiscoveryEnabled &&+ ` ${pluralTitle} created later are added automatically.`}+ </AlertDialogDescription>+ </AlertDialogHeader>+ <AlertDialogFooter>+ <AlertDialogCancel isDisabled={updateDataSource.isPending}>Cancel</AlertDialogCancel>+ <AlertDialogAction+ variant="project"+ isPending={updateDataSource.isPending}+ onClick={(event) => {+ event.preventDefault();+ handleAddAll();+ }}+ >+ Add All {pluralTitle}+ </AlertDialogAction>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog>+ </>+ );+};diff --git a/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/DataSourceConfigDisplay/BitbucketDataSourceConfigDisplay.tsx b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/DataSourceConfigDisplay/BitbucketDataSourceConfigDisplay.tsxindex d552ab5e58..eb730ad210 100644--- a/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/DataSourceConfigDisplay/BitbucketDataSourceConfigDisplay.tsx+++ b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/DataSourceConfigDisplay/BitbucketDataSourceConfigDisplay.tsx@@ -5,21 +5,9 @@ type Props = {dataSource: TBitbucketDataSource;};-export const BitbucketDataSourceConfigDisplay = ({ dataSource }: Props) => {- const {- config: { includeRepos, workspaceSlug }- } = dataSource;-- return (- <>- <Detail>- <DetailLabel>Workspace Slug</DetailLabel>- <DetailValue>{workspaceSlug}</DetailValue>- </Detail>- <Detail>- <DetailLabel>Scan Repositories</DetailLabel>- <DetailValue>{includeRepos.includes("*") ? "All" : includeRepos.join(", ")}</DetailValue>- </Detail>- </>- );-};+export const BitbucketDataSourceConfigDisplay = ({ dataSource }: Props) => (+ <Detail>+ <DetailLabel>Workspace Slug</DetailLabel>+ <DetailValue>{dataSource.config.workspaceSlug}</DetailValue>+ </Detail>+);diff --git a/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/DataSourceConfigDisplay/DataSourceConfigDisplay.tsx b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/DataSourceConfigDisplay/DataSourceConfigDisplay.tsxindex 55f2b9a32f..4c88ef0001 100644--- a/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/DataSourceConfigDisplay/DataSourceConfigDisplay.tsx+++ b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/DataSourceConfigDisplay/DataSourceConfigDisplay.tsx@@ -1,24 +1,33 @@+import { DetailGroup } from "@app/components/v3";import {SecretScanningDataSource,TSecretScanningDataSource} from "@app/hooks/api/secretScanningV2";import { BitbucketDataSourceConfigDisplay } from "./BitbucketDataSourceConfigDisplay";-import { GitHubDataSourceConfigDisplay } from "./GitHubDataSourceConfigDisplay";import { GitLabDataSourceConfigDisplay } from "./GitLabDataSourceConfigDisplay";type Props = {dataSource: TSecretScanningDataSource;};+// which repositories are scanned is managed from the Repositories tab, so only the rest of the config shows hereexport const DataSourceConfigDisplay = ({ dataSource }: Props) => {switch (dataSource.type) {case SecretScanningDataSource.GitHub:- return <GitHubDataSourceConfigDisplay dataSource={dataSource} />;+ return null;case SecretScanningDataSource.Bitbucket:- return <BitbucketDataSourceConfigDisplay dataSource={dataSource} />;+ return (+ <DetailGroup>+ <BitbucketDataSourceConfigDisplay dataSource={dataSource} />+ </DetailGroup>+ );case SecretScanningDataSource.GitLab:- return <GitLabDataSourceConfigDisplay dataSource={dataSource} />;+ return (+ <DetailGroup>+ <GitLabDataSourceConfigDisplay dataSource={dataSource} />+ </DetailGroup>+ );default:throw new Error(`Unhandled dataSource type ${(dataSource as TSecretScanningDataSource).type}`diff --git a/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/DataSourceConfigDisplay/GitHubDataSourceConfigDisplay.tsx b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/DataSourceConfigDisplay/GitHubDataSourceConfigDisplay.tsxdeleted file mode 100644index 21b9ba09e2..0000000000--- a/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/DataSourceConfigDisplay/GitHubDataSourceConfigDisplay.tsx+++ /dev/null@@ -1,19 +0,0 @@-import { Detail, DetailLabel, DetailValue } from "@app/components/v3";-import { TGitHubDataSource } from "@app/hooks/api/secretScanningV2/types/github-data-source";--type Props = {- dataSource: TGitHubDataSource;-};--export const GitHubDataSourceConfigDisplay = ({ dataSource }: Props) => {- const {- config: { includeRepos }- } = dataSource;-- return (- <Detail>- <DetailLabel>Scan Repositories</DetailLabel>- <DetailValue>{includeRepos.includes("*") ? "All" : includeRepos.join(", ")}</DetailValue>- </Detail>- );-};diff --git a/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/DataSourceConfigDisplay/GitLabDataSourceConfigDisplay.tsx b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/DataSourceConfigDisplay/GitLabDataSourceConfigDisplay.tsxindex db8aa8a173..4a6f5dff70 100644--- a/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/DataSourceConfigDisplay/GitLabDataSourceConfigDisplay.tsx+++ b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/DataSourceConfigDisplay/GitLabDataSourceConfigDisplay.tsx@@ -27,24 +27,14 @@ export const GitLabDataSourceConfigDisplay = ({ dataSource }: Props) => {);}- const { includeProjects } = config;-return (- <>- <Detail>- <DetailLabel>Group</DetailLabel>- <DetailValue>- {config.scope === GitLabDataSourceScope.Group- ? config.groupName || config.groupId- : "None (all accessible projects)"}- </DetailValue>- </Detail>- <Detail>- <DetailLabel>Scan Projects</DetailLabel>- <DetailValue>- {includeProjects.includes("*") ? "All" : includeProjects.join(", ")}- </DetailValue>- </Detail>- </>+ <Detail>+ <DetailLabel>Group</DetailLabel>+ <DetailValue>+ {config.scope === GitLabDataSourceScope.Group+ ? config.groupName || config.groupId+ : "None (all accessible projects)"}+ </DetailValue>+ </Detail>);};diff --git a/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/SecretScanningDataSourceSettings.tsx b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/SecretScanningDataSourceSettings.tsxindex 31baab5b75..858768131b 100644--- a/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/SecretScanningDataSourceSettings.tsx+++ b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/SecretScanningDataSourceSettings.tsx@@ -1,11 +1,10 @@import { Controller, useForm } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";-import { PencilIcon, TrashIcon } from "lucide-react";+import { TrashIcon } from "lucide-react";import { z } from "zod";import { createNotification } from "@app/components/notifications";import { ProjectPermissionCan } from "@app/components/permissions";-import { EditSecretScanningDataSourceModal } from "@app/components/secret-scanning";import { DeleteSecretScanningDataSourceModal } from "@app/components/secret-scanning/DeleteSecretScanningDataSourceModal";import {Button,@@ -16,26 +15,25 @@ import {CardFooter,CardHeader,CardTitle,- Detail,- DetailGroup,- DetailLabel,- DetailValue,+ Combobox,Field,FieldContent,FieldDescription,FieldError,FieldGroup,FieldLabel,+ FieldTitle,Input,- Label,TextArea,Toggle} from "@app/components/v3";import { ProjectPermissionSub, useProjectPermission } from "@app/context";import { ProjectPermissionSecretScanningDataSourceActions } from "@app/context/ProjectPermissionContext/types";+import { APP_CONNECTION_MAP } from "@app/helpers/appConnections";import {doesDataSourceSupportDiscovery,RESOURCE_DESCRIPTION_HELPER,+ SECRET_SCANNING_DATA_SOURCE_CONNECTION_MAP,SECRET_SCANNING_DATA_SOURCE_MAP} from "@app/helpers/secretScanningV2";import { usePopUp } from "@app/hooks";@@ -68,10 +66,7 @@ export const SecretScanningDataSourceSettings = ({ dataSource, onDeleted }: PropProjectPermissionSub.SecretScanningDataSources);- const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp([- "editDataSource",- "deleteDataSource"- ] as const);+ const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp(["deleteDataSource"] as const);const updateDataSource = useUpdateSecretScanningDataSource();@@ -90,6 +85,8 @@ export const SecretScanningDataSourceSettings = ({ dataSource, onDeleted }: Propconst { name: platform } = SECRET_SCANNING_DATA_SOURCE_MAP[dataSource.type];const { pluralNoun, pluralTitle } = RESOURCE_DESCRIPTION_HELPER[dataSource.type];const supportsDiscovery = doesDataSourceSupportDiscovery(dataSource);+ const connectionDetails =+ APP_CONNECTION_MAP[SECRET_SCANNING_DATA_SOURCE_CONNECTION_MAP[dataSource.type]];const onSaveGeneral = async (form: TGeneralForm) => {await updateDataSource.mutateAsync({@@ -154,25 +151,50 @@ export const SecretScanningDataSourceSettings = ({ dataSource, onDeleted }: Prop<CardContent><form id="data-source-general-form" onSubmit={handleSubmit(onSaveGeneral)}><FieldGroup>- <Controller- control={control}- name="name"- render={({ field, fieldState: { error } }) => (- <Field data-invalid={Boolean(error)} data-disabled={!canEdit}>- <FieldLabel htmlFor="data-source-name">Name</FieldLabel>+ <div className="grid grid-cols-1 gap-5 md:grid-cols-2">+ <Controller+ control={control}+ name="name"+ render={({ field, fieldState: { error } }) => (+ <Field data-invalid={Boolean(error)} data-disabled={!canEdit}>+ <FieldLabel htmlFor="data-source-name">Name</FieldLabel>+ <FieldContent>+ <Input+ {...field}+ id="data-source-name"+ autoComplete="off"+ isError={Boolean(error)}+ disabled={!canEdit}+ />+ <FieldError errors={[error]} />+ </FieldContent>+ </Field>+ )}+ />+ {dataSource.connection && (+ <Field data-disabled>+ <FieldLabel htmlFor="data-source-connection">+ {connectionDetails.name} Connection+ </FieldLabel><FieldContent>- <Input- {...field}- id="data-source-name"- autoComplete="off"- isError={Boolean(error)}- disabled={!canEdit}+ <Combobox<{ id: string; name: string }>+ id="data-source-connection"+ value={dataSource.connection}+ options={[dataSource.connection]}+ isClearable={false}+ isDisabled+ onValueChange={() => {}}+ getOptionLabel={(option) => option.name}+ getOptionValue={(option) => option.id}+ aria-describedby="data-source-connection-help"/>- <FieldError errors={[error]} />+ <FieldDescription id="data-source-connection-help">+ Cannot be updated+ </FieldDescription></FieldContent></Field>)}- />+ </div><Controllercontrol={control}name="description"@@ -196,12 +218,6 @@ export const SecretScanningDataSourceSettings = ({ dataSource, onDeleted }: Prop</Field>)}/>- {dataSource.connection && (- <Detail>- <DetailLabel>App Connection</DetailLabel>- <DetailValue>{dataSource.connection.name}</DetailValue>- </Detail>- )}</FieldGroup></form></CardContent>@@ -221,29 +237,15 @@ export const SecretScanningDataSourceSettings = ({ dataSource, onDeleted }: Prop<Card><CardHeader><CardTitle>Scanning</CardTitle>- <CardDescription>- When {dataSource.name} is scanned and which {pluralNoun} are included.- </CardDescription>- <CardAction>- <Button- variant="outline"- isDisabled={!canEdit}- onClick={() => handlePopUpOpen("editDataSource")}- >- <PencilIcon />- Edit Configuration- </Button>- </CardAction>+ <CardDescription>When {dataSource.name} is scanned for secrets.</CardDescription></CardHeader><CardContent><FieldGroup>- <DetailGroup>- <DataSourceConfigDisplay dataSource={dataSource} />- </DetailGroup>+ <DataSourceConfigDisplay dataSource={dataSource} />{scanToggles.map(({ name, label, description, isDisabled }) => (<Field key={name} orientation="horizontal" data-disabled={!canEdit || isDisabled}><FieldContent>- <Label htmlFor={`data-source-${name}`}>{label}</Label>+ <FieldTitle id={`data-source-${name}-title`}>{label}</FieldTitle><FieldDescription id={`data-source-${name}-help`}>{description}</FieldDescription>@@ -254,6 +256,7 @@ export const SecretScanningDataSourceSettings = ({ dataSource, onDeleted }: Propchecked={dataSource[name]}onCheckedChange={(checked) => handleToggle(name, label, checked)}disabled={!canEdit || isDisabled || updateDataSource.isPending}+ aria-labelledby={`data-source-${name}-title`}aria-describedby={`data-source-${name}-help`}/></Field>@@ -266,7 +269,7 @@ export const SecretScanningDataSourceSettings = ({ dataSource, onDeleted }: Prop<CardHeader><CardTitle>Danger Zone</CardTitle><CardDescription>- Stop scanning {dataSource.name} and delete its scan history. Findings are preserved.+ Stop scanning {dataSource.name} and permanently delete its findings and scan history.</CardDescription><CardAction><ProjectPermissionCan@@ -288,11 +291,6 @@ export const SecretScanningDataSourceSettings = ({ dataSource, onDeleted }: Prop</CardHeader></Card></div>- <EditSecretScanningDataSourceModal- dataSource={dataSource}- isOpen={popUp.editDataSource.isOpen}- onOpenChange={(isOpen) => handlePopUpToggle("editDataSource", isOpen)}- /><DeleteSecretScanningDataSourceModaldataSource={dataSource}isOpen={popUp.deleteDataSource.isOpen}diff --git a/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/SecretScanningResourceTable.tsx b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/SecretScanningResourceTable.tsxindex 2683242671..36e8a58134 100644--- a/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/SecretScanningResourceTable.tsx+++ b/frontend/src/pages/secret-scanning/SecretScanningDataSourceByIdPage/components/SecretScanningResourceTable.tsx@@ -5,6 +5,7 @@ import { twMerge } from "tailwind-merge";import {Button,Card,+ CardAction,CardContent,CardDescription,CardHeader,@@ -36,6 +37,7 @@ import {import { ProjectPermissionSub, useProjectPermission } from "@app/context";import { ProjectPermissionSecretScanningDataSourceActions } from "@app/context/ProjectPermissionContext/types";import {+ canAddSecretScanningResources,isSecretScanningResourceIncluded,RESOURCE_DESCRIPTION_HELPER,SECRET_SCANNING_DATA_SOURCE_MAP@@ -49,6 +51,7 @@ import {useListSecretScanningResources} from "@app/hooks/api/secretScanningV2";+import { AddSecretScanningResourcesButton } from "./AddSecretScanningResourcesButton";import { SecretScanningResourceRow } from "./SecretScanningResourceRow";enum ResourcesOrderBy {@@ -238,13 +241,15 @@ export const SecretScanningResourcesTable = ({ dataSource, onViewFindings }: Pro</EmptyMedia><EmptyTitle>No {resourceDetails.pluralNoun} yet</EmptyTitle><EmptyDescription>- {resourceDetails.pluralTitle} appear here once the data source has been scanned.+ Add a {resourceDetails.singularNoun} to start scanning it for secrets.</EmptyDescription></EmptyHeader></Empty>);};+ const canAddResources = canAddSecretScanningResources(dataSource);+return (<Card><CardHeader>@@ -254,7 +259,12 @@ export const SecretScanningResourcesTable = ({ dataSource, onViewFindings }: Pro{SECRET_SCANNING_DATA_SOURCE_MAP[dataSource.type].name} data source. Select one to see itsfindings.</CardDescription>- <div className="flex gap-2">+ {canAddResources && (+ <CardAction>+ <AddSecretScanningResourcesButton dataSource={dataSource} />+ </CardAction>+ )}+ <div className="col-span-full flex gap-2"><InputGroup className="flex-1"><InputGroupAddon align="inline-start"><SearchIcon />