From d8ee05bfba490d719df46ea0778f706e217ed48f Mon Sep 17 00:00:00 2001 From: Scott Wilson Date: Tue, 3 Jun 2025 10:41:46 -0700 Subject: [PATCH] improvements: address feedback --- .../github/github-secret-scanning-factory.ts | 4 +++- .../github/github-secret-scanning-schemas.ts | 10 ++++++++-- .../secret-scanning-v2/secret-scanning-v2-fns.ts | 2 +- .../app-connection/ldap/ldap-connection-schemas.ts | 7 ++++++- .../forms/schemas/github-data-source-schema.ts | 2 +- 5 files changed, 19 insertions(+), 6 deletions(-) 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.ts index fc104e781..2dde97d7c 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 @@ -42,7 +42,9 @@ export const GitHubSecretScanningFactory = () => { }); if (existingDataSource) - throw new BadRequestError({ message: "A Data Source already exists for this GitHub Radar Connection" }); + throw new BadRequestError({ + message: `A Data Source already exists for this GitHub Radar Connection in the Project with ID "${existingDataSource.projectId}"` + }); return callback({ externalId 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.ts index e36248bfb..f1eec125c 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 @@ -17,9 +17,15 @@ import { AppConnection } from "@app/services/app-connection/app-connection-enums export const GitHubDataSourceConfigSchema = z.object({ includeRepos: z - .array(z.string().regex(GitHubRepositoryRegex, "Invalid repository name format").min(1).max(256)) + .array( + z + .string() + .min(1) + .max(256) + .refine((value) => value === "*" || GitHubRepositoryRegex.test(value), "Invalid repository name format") + ) .nonempty("One or more repositories required") - .max(25) + .max(100, "Cannot configure more than 100 repositories") .default(["*"]) .describe(SecretScanningDataSources.CONFIG.GITHUB.includeRepos) }); 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.ts index 031d15bb7..64a0ba4ed 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 @@ -95,7 +95,7 @@ export const convertPatchLineToFileLineNumber = (patch: string, patchLineNumber: currentPatchLine += 1; // Hunk header: @@ -a,b +c,d @@ - const hunkHeaderMatch = line.match(HunkHeaderRegex); + const hunkHeaderMatch = HunkHeaderRegex.match(line); if (hunkHeaderMatch) { const startLine = parseInt(hunkHeaderMatch[1], 10); currentNewLine = startLine; diff --git a/backend/src/services/app-connection/ldap/ldap-connection-schemas.ts b/backend/src/services/app-connection/ldap/ldap-connection-schemas.ts index c4c94b4fc..134b9667b 100644 --- a/backend/src/services/app-connection/ldap/ldap-connection-schemas.ts +++ b/backend/src/services/app-connection/ldap/ldap-connection-schemas.ts @@ -13,7 +13,12 @@ import { LdapConnectionMethod, LdapProvider } from "./ldap-connection-enums"; export const LdapConnectionSimpleBindCredentialsSchema = z.object({ provider: z.nativeEnum(LdapProvider).describe(AppConnections.CREDENTIALS.LDAP.provider), - url: z.string().trim().min(1, "URL required").regex(LdapUrlRegex).describe(AppConnections.CREDENTIALS.LDAP.url), + url: z + .string() + .trim() + .min(1, "URL required") + .refine((value) => LdapUrlRegex.test(value), "Invalid LDAP URL") + .describe(AppConnections.CREDENTIALS.LDAP.url), dn: z .string() .trim() 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.ts index 86f22b2b4..2b5f87f82 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 @@ -12,7 +12,7 @@ export const GitHubDataSourceSchema = z .string() .array() .min(1, "One or more repositories required") - .max(25, "Cannot configure more than 25 repositories") + .max(100, "Cannot configure more than 100 repositories") }) }) .merge(BaseSecretScanningDataSourceSchema({ isConnectionRequired: true }));