Skip to content

Commit 3fbb95e

Browse files
author
propr-dev[bot]
committed
chore: replace hyphen-trimming regex in run ID with linear scans
Replaced the CodeQL-flagged hyphen-trimming regex in [workspaceCloneTransport.ts](/home/node/workspace/packages/core/src/git/workspaceCloneTransport.ts:65) with linear scans. Run IDs keep the same 64-character prefix limit, `run` fallback, and random suffix. Core typecheck and all 10 focused run ID checks passed. The workspace transport suite passed 22 tests and skipped one that requires root or passwordless sudo. CodeQL verification is pending. PR: #3774 Comment by: @github-advanced-security[bot] (ID: 4677562060) Model: GPT-6.2 Sol ProPR-Agent: codex/gpt-6.2-sol
1 parent 313e79c commit 3fbb95e

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎packages/core/src/git/workspaceCloneTransport.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,15 @@ export const defaultCloneWorkspaceTransportDependencies: CloneWorkspaceTransport
6262
revokeToken: revokeInstallationToken,
6363
workerToken: () => getGitHubInstallationToken(),
6464
remoteUrl: ({ owner, repo }) => `https://github.com/${owner}/${repo}.git`,
65-
createRunId: spec => `${spec.name.toLowerCase().replace(/[^a-z0-9-]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 64) || 'run'}-${randomBytes(4).toString('hex')}`,
65+
createRunId: spec => {
66+
const normalizedName = spec.name.toLowerCase().replace(/[^a-z0-9-]+/g, '-');
67+
let start = 0;
68+
let end = normalizedName.length;
69+
while (start < end && normalizedName[start] === '-') start++;
70+
while (end > start && normalizedName[end - 1] === '-') end--;
71+
const prefix = normalizedName.slice(start, Math.min(end, start + 64)) || 'run';
72+
return `${prefix}-${randomBytes(4).toString('hex')}`;
73+
},
6674
};
6775

6876
/** `owner/repo` of a GitHub remote URL (https or ssh, with or without credentials). */

0 commit comments

Comments
 (0)