Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

refactor(imports): share public Git host classification with Sonar (#2474)

Michael D'Angeloa958c82e28c4
diff --git a/sdk/typescript/src/external-findings-local.ts b/sdk/typescript/src/external-findings-local.ts
index 980d6d5be..4a1d462f5 100644
--- a/sdk/typescript/src/external-findings-local.ts
+++ b/sdk/typescript/src/external-findings-local.ts
@@ -8,6 +8,8 @@ import {
} from "./semgrep-platform-findings.js";
import {
gitPathToHttpPath,
+ gitServiceHostname,
+ isPublicGitHost,
gitTransportBytes,
hostedRepositoryMatches,
} from "./hosted-git-repository.js";
@@ -193,17 +195,9 @@ interface RemoteRepositoryIdentity {
homeRelative?: boolean;
}
-function sonarHostedGit(hostname: string) {
- return (
- isGitHubCloudHost(hostname) ||
- hostname === "gitlab.com" ||
- hostname === "bitbucket.org"
- );
-}
-
function sonarHostedHostname(hostname: string) {
- const name = hostname.toLowerCase().replace(/\.$/u, "");
- return sonarHostedGit(name) ||
+ const name = gitServiceHostname(hostname.toLowerCase());
+ return isPublicGitHost(name) ||
["ssh.github.com", "ssh.dev.azure.com", "dev.azure.com"].includes(name)
? name
: undefined;
@@ -389,7 +383,7 @@ export function sonarRepositoryForRemote(origin: string): string | undefined {
isGitSsh(url.protocol) &&
url.username === "git" &&
(!url.port || url.port === "22") &&
- sonarHostedGit(hostname)
+ isPublicGitHost(hostname)
) {
candidate = `https://${hostname}/${path}`;
} else {