Skip to content

fix(miner): reject path-traversal repo segments in the 4 remaining normalizeRepoFullName parsers - #8065

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
davion-knight:fix-normalize-repo-path-guard-v2
Jul 22, 2026
Merged

fix(miner): reject path-traversal repo segments in the 4 remaining normalizeRepoFullName parsers#8065
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
davion-knight:fix-normalize-repo-path-guard-v2

Conversation

@davion-knight

Copy link
Copy Markdown
Contributor

What & why

repo-clone.ts exports isValidRepoSegment, which rejects a repo owner or
repo segment containing ./../control-characters/whitespace before it is
persisted to SQLite or echoed back through a sibling CLI. #5831 and #7525 rolled
this guard out across the miner's normalizeRepoFullName parsers, but four were
missed and still only checked "exactly one slash, both halves non-empty":

  • packages/loopover-miner/lib/contribution-profile-cache.ts
  • packages/loopover-miner/lib/prediction-ledger.ts
  • packages/loopover-miner/lib/replay-snapshot.ts
  • packages/loopover-miner/lib/run-state.ts

Inputs like owner/.., ../repo, or a tab/newline segment passed these four
while being rejected by every already-guarded sibling — and each of these four
backs a SQLite key and is echoed through its sibling CLI, the exact rationale
#5831/#7525 cited.

Change

Call isValidRepoSegment on both the owner and repo segment in all four
parsers, using the identical call shape as the ten already-fixed siblings
(rename/remove nothing else). Adds a per-file regression test asserting a
path-traversal / invalid-character segment throws invalid_repo_full_name,
covering both operands, mirroring test/unit/miner-claim-ledger.test.ts.

Closes #7795

…rmalizeRepoFullName parsers

repo-clone.ts's isValidRepoSegment rejects a ./../control-char owner or repo
segment before it's persisted to SQLite or echoed through a CLI. JSONbored#5831 and
JSONbored#7525 rolled it out to ten sibling parsers, but four were missed:
contribution-profile-cache.ts, prediction-ledger.ts, replay-snapshot.ts, and
run-state.ts still only checked 'exactly one slash, both halves non-empty'.
Inputs like 'owner/..', '../repo', or tab/newline segments passed these four
while being rejected everywhere else -- and each backs a SQLite key and is
echoed through its sibling CLI, the exact rationale JSONbored#5831/JSONbored#7525 used.

Call isValidRepoSegment on both owner and repo in all four, matching the exact
call shape of the ten already-fixed siblings. Adds a per-file regression test
asserting a path-traversal/invalid-character segment throws invalid_repo_full_name,
covering both operands, mirroring test/unit/miner-claim-ledger.test.ts.

Closes JSONbored#7795
@davion-knight
davion-knight requested a review from JSONbored as a code owner July 22, 2026 18:04
@superagent-security

Copy link
Copy Markdown
Contributor

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

@superagent-security superagent-security Bot added pr:flagged PR flagged for review by security analysis. and removed pr:flagged PR flagged for review by security analysis. labels Jul 22, 2026
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 22, 2026
@loopover-orb

loopover-orb Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-22 18:12:44 UTC

8 files · 1 AI reviewer · no blockers · readiness 100/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This is a narrow, well-targeted security fix: it adds the missing `isValidRepoSegment(owner)`/`isValidRepoSegment(repo)` guard to the four `normalizeRepoFullName` parsers in contribution-profile-cache.ts, prediction-ledger.ts, replay-snapshot.ts, and run-state.ts, using the identical call shape already present in the ten fixed siblings. Each file's guard is placed correctly after the existing shape check and before the value is used as a SQLite key, and each gets a regression test covering both the owner and repo operand for `..` and whitespace segments, matching the pattern in miner-run-state.test.ts. The change closes #7795 exactly as described and does not touch unrelated code.

Nits — 2 non-blocking
  • The four near-identical regression tests (in miner-run-state.test.ts, miner-contribution-profile-cache.test.ts, miner-prediction-ledger.test.ts, miner-replay-snapshot.test.ts) repeat the same six-assertion pattern almost verbatim — worth noting as expected duplication across sibling stores rather than something to dedupe, since each store has its own read/write API.
  • None beyond what's already covered — the fix is minimal and matches the established pattern exactly.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7795
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 35 registered-repo PR(s), 19 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor davion-knight; Gittensor profile; 35 PR(s), 0 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
All four flagged files (contribution-profile-cache.ts, prediction-ledger.ts, replay-snapshot.ts, run-state.ts) now import and call isValidRepoSegment on both owner and repo in normalizeRepoFullName, matching the exact call shape used by the ten already-fixed siblings, and each file gets a regression test asserting a path-traversal/invalid-character segment throws invalid_repo_full_name for both op

Review context
  • Author: davion-knight
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 35 PR(s), 0 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask <question> answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat <question> answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit b788945 into JSONbored:main Jul 22, 2026
10 checks passed
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.40%. Comparing base (25e2df1) to head (09ad4e1).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
...s/loopover-miner/lib/contribution-profile-cache.ts 0.00% 1 Missing ⚠️
packages/loopover-miner/lib/prediction-ledger.ts 0.00% 1 Missing ⚠️
packages/loopover-miner/lib/run-state.ts 0.00% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (25.00%) is below the target coverage (99.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #8065       +/-   ##
===========================================
- Coverage   91.82%   38.40%   -53.42%     
===========================================
  Files         734        4      -730     
  Lines       75019      276    -74743     
  Branches    23037       59    -22978     
===========================================
- Hits        68885      106    -68779     
+ Misses       5034      170     -4864     
+ Partials     1100        0     -1100     
Flag Coverage Δ
rees ?
shard-1 38.40% <25.00%> (-15.87%) ⬇️
shard-2 0.00% <0.00%> (-52.58%) ⬇️
shard-3 0.00% <0.00%> (-55.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/loopover-miner/lib/replay-snapshot.ts 100.00% <100.00%> (ø)
...s/loopover-miner/lib/contribution-profile-cache.ts 0.00% <0.00%> (-100.00%) ⬇️
packages/loopover-miner/lib/prediction-ledger.ts 0.00% <0.00%> (-80.60%) ⬇️
packages/loopover-miner/lib/run-state.ts 0.00% <0.00%> (-100.00%) ⬇️

... and 730 files with indirect coverage changes

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

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 sibling normalizeRepoFullName parsers still skip the path-safety guard #5831/#7525 already added to every other sibling

2 participants