Skip to content

Commit 928e63b

Browse files
fix(miner): validate commit SHA format in replay-snapshot path planner (#7796)
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 17ae3e6 commit 928e63b

3 files changed

Lines changed: 83 additions & 61 deletions

File tree

packages/loopover-miner/lib/replay-snapshot.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ function normalizeDbPath(dbPath: string): string {
6767

6868
const FIELD_SEP = "\x1f";
6969
const README_NAME_PATTERN = /^readme(\.\w+)?$/i;
70+
const COMMIT_SHA_PATTERN = /^[0-9a-f]{7,40}$/i;
7071

7172
function normalizeRepoFullName(repoFullName: string): string {
7273
if (typeof repoFullName !== "string") throw new Error("invalid_repo_full_name");
@@ -77,7 +78,9 @@ function normalizeRepoFullName(repoFullName: string): string {
7778

7879
function normalizeCommitSha(commitSha: string): string {
7980
if (typeof commitSha !== "string" || !commitSha.trim()) throw new Error("invalid_commit_sha");
80-
return commitSha.trim();
81+
const trimmed = commitSha.trim();
82+
if (!COMMIT_SHA_PATTERN.test(trimmed)) throw new Error("invalid_commit_sha");
83+
return trimmed.toLowerCase();
8184
}
8285

8386
/** Worktree exports live under this dir inside the repo, mirroring worktree-allocator.ts's WORKTREE_SUBDIR. */

0 commit comments

Comments
 (0)