Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/loopover-miner/lib/replay-snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,14 @@ function normalizeRepoFullName(repoFullName: string): string {
return `${owner}/${repo}`;
}

/** Same format guard as replay-task-generation.ts — reject path-traversal / non-hex values before path.join (#7796). */
const COMMIT_SHA_PATTERN = /^[0-9a-f]{7,40}$/i;

function normalizeCommitSha(commitSha: string): string {
if (typeof commitSha !== "string" || !commitSha.trim()) throw new Error("invalid_commit_sha");
return commitSha.trim();
const trimmed = commitSha.trim();
if (!COMMIT_SHA_PATTERN.test(trimmed)) throw new Error("invalid_commit_sha");
return trimmed.toLowerCase();
}

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