fix(miner): reject path-traversal repo segments in the 4 remaining normalizeRepoFullName parsers - #8060
Closed
davion-knight wants to merge 1 commit into
Closed
Conversation
…rmalizeRepoFullName parsers repo-clone.ts's isValidRepoSegment rejects a ./../control-char owner or repo segment before it is persisted to SQLite or echoed through a CLI. JSONbored#5831 and JSONbored#7525 rolled it out to ten sibling parsers, but four were missed and still only checked 'exactly one slash, both halves non-empty': contribution-profile-cache.ts, prediction-ledger.ts, replay-snapshot.ts, and run-state.ts. Inputs like 'owner/..', '../repo', or segments with tab/newline characters passed these four while being correctly rejected everywhere else. Import and 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
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Contributor
Author
|
Superseded — rebasing onto current main to resolve a base overlap; a clean PR will follow. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
repo-clone.ts'sisValidRepoSegmentrejects a./../control-char owner or repo segment before it's persisted to SQLite or echoed through a CLI. #5831 and #7525 rolled it out to ten sibling parsers, but four were missed and still only check "exactly one slash, both halves non-empty":contribution-profile-cache.ts,prediction-ledger.ts,replay-snapshot.ts,run-state.tsInputs like
"owner/..","../repo", and segments with tab/newline pass these four but are correctly rejected by the already-fixed siblings — and each backs a SQLite key (*.sqlite3) and is echoed through its sibling CLI, exactly the rationale #5831/#7525 used.Fix
Import and call
isValidRepoSegment(owner)/isValidRepoSegment(repo)in all fournormalizeRepoFullNamefunctions, matching the exact call shape of the ten already-fixed siblings (claim-ledger.ts,governor-state.ts, …) — no new validation approach.Tests
A per-file regression test drives each module's own store method (
get/put,appendPrediction/readPredictions,getSnapshot,getRunState/setRunState) with"../etc"(owner-invalid) and"o/.."(repo-invalid) — covering both operands of the new||branch — plus invalid-character cases, asserting.toThrow("invalid_repo_full_name"), mirroringtest/unit/miner-claim-ledger.test.ts's existing assertion. 84 tests pass across the 4 files.Verification
Each file's new guard + import lines are covered (guard-line hits 30/25/83/47); the only uncovered lines in the report are pre-existing, unrelated to this diff. Root
typecheckclean. The compiled.jsare gitignored, so the diff is the 4.tssources + 4 test files.Closes #7795