From 5eaf8ba876a877a75c4c7b5259ae6e46badaec41 Mon Sep 17 00:00:00 2001 From: Smartsheet-JB-Brown Date: Fri, 18 Apr 2025 16:48:28 -0700 Subject: [PATCH] fix regex in response to security scan concern in CI build --- src/shared/MarketplaceValidation.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/shared/MarketplaceValidation.ts b/src/shared/MarketplaceValidation.ts index 03c3ac44d6..1648e3bc02 100644 --- a/src/shared/MarketplaceValidation.ts +++ b/src/shared/MarketplaceValidation.ts @@ -27,18 +27,18 @@ export function isValidGitRepositoryUrl(url: string): boolean { // - https://gitlab.com/username/repo // - https://bitbucket.org/username/repo const httpsPattern = - /^https?:\/\/[a-zA-Z0-9_.-]+(\.[a-zA-Z0-9_.-]+)*\/[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+(\/.+)*(\.git)?$/ + /^https?:\/\/(?:[a-zA-Z0-9_-]+\.)*[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]+(?:\/[^/]+)*(?:\.git)?$/ // SSH pattern // Examples: // - git@github.com:username/repo.git // - git@gitlab.com:username/repo.git - const sshPattern = /^git@[a-zA-Z0-9_.-]+(\.[a-zA-Z0-9_.-]+)*:([a-zA-Z0-9_.-]+)\/([a-zA-Z0-9_.-]+)(\.git)?$/ + const sshPattern = /^git@(?:[a-zA-Z0-9_-]+\.)*[a-zA-Z0-9_-]+:([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)(?:\.git)?$/ // Git protocol pattern // Examples: // - git://github.com/username/repo.git - const gitProtocolPattern = /^git:\/\/[a-zA-Z0-9_.-]+(\.[a-zA-Z0-9_.-]+)*\/[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+(\.git)?$/ + const gitProtocolPattern = /^git:\/\/(?:[a-zA-Z0-9_-]+\.)*[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]+(?:\.git)?$/ return httpsPattern.test(trimmedUrl) || sshPattern.test(trimmedUrl) || gitProtocolPattern.test(trimmedUrl) }