Skip to content

fix(miner): validate commit SHA format in replay-snapshot path planner (#7796) - #7827

Closed
RealDiligent wants to merge 1 commit into
JSONbored:mainfrom
RealDiligent:fix/replay-snapshot-commit-sha-validation-7796
Closed

fix(miner): validate commit SHA format in replay-snapshot path planner (#7796)#7827
RealDiligent wants to merge 1 commit into
JSONbored:mainfrom
RealDiligent:fix/replay-snapshot-commit-sha-validation-7796

Conversation

@RealDiligent

Copy link
Copy Markdown
Contributor

Summary

  • Add /^[0-9a-f]{7,40}$/i validation to normalizeCommitSha (matching replay-task-generation.ts) so path-traversal-shaped values are rejected before path.join()n- Normalize valid SHAs to lowercase for deterministic snapshot paths
  • Regression test for ../../../../../../tmp/evil-worktree-shaped input; update fixture SHAs to meet the 7-char minimum

Closes #7796

Test plan

  • npm run typecheck passes locally
  • npm run build:tsc in miner workspace emits matching .js
  • CI validate-code (incl. Miner build drift check) + validate-tests green
  • codecov/patch >= 99% on changed lines

Made with Cursor

@RealDiligent
RealDiligent requested a review from JSONbored as a code owner July 21, 2026 13:59
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
65 1 64 0
View the top 1 failed test(s) by shortest run time
test/unit/miner-store-seam-rollout.test.ts > SqliteDriver seam rollout — non-transactional store round-trips (#7282) > replay-snapshot: saveSnapshot writes through the seam and getSnapshot reads the identical bundle back
Stack Traces | 0.0151s run time
Error: invalid_commit_sha
 ❯ normalizeCommitSha .../loopover-miner/lib/replay-snapshot.ts:82:48
 ❯ Object.getSnapshot .../loopover-miner/lib/replay-snapshot.ts:240:76
 ❯ test/unit/miner-store-seam-rollout.test.ts:102:18

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@RealDiligent
RealDiligent force-pushed the fix/replay-snapshot-commit-sha-validation-7796 branch from e6956f5 to 05db29c Compare July 21, 2026 14:07
@loopover-orb loopover-orb Bot closed this Jul 21, 2026
@loopover-orb

loopover-orb Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

This repository reviews pull requests one-shot: the PR must be correct as originally opened. Pushing an additional commit closes it automatically instead of restarting review — open a fresh pull request with every fix included.

@loopover-orb loopover-orb Bot added the review-evasion Gittensor contributor context label Jul 21, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-evasion Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

replay-snapshot.ts's normalizeCommitSha has no format validation, letting a crafted value escape the intended snapshot directory via path.join

1 participant