Commit 2656eaa
authored
fix(miner): reject path-traversal-shaped commitSha in replay-snapshot path planner (#7996)
normalizeCommitSha accepted any non-empty string and join()ed it straight into
REPLAY_SNAPSHOT_SUBDIR, so a crafted commitSha like "../../../../tmp/evil" escaped
the intended .loopover-replay-snapshots sandbox entirely -- and would then control
where `git worktree add --detach <path>` writes on disk (#7796). Constrain it to a
single safe path segment (repo-clone.ts's isValidRepoSegment charset for owner/repo,
#5831, plus an explicit "."/".." rejection) before it reaches path.join(). A genuine
commit SHA is hex and always satisfies this, so no legitimate caller regresses.
Adds a regression test covering traversal-/separator-shaped values (and the accepted
hex case). The test now imports the .ts SOURCE via a non-literal specifier instead of
the extensionless/.js path: once build:miner has produced the artifact, a .js import
loads that build output and leaves coverage.include's .ts entry at 0% -- so the new
guard is now actually instrumented (100% patch), while the variable specifier keeps
tsc happy (no TS5097).
Closes #77961 parent 162b7cb commit 2656eaa
2 files changed
Lines changed: 31 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
78 | 85 | | |
79 | 86 | | |
80 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
81 | 90 | | |
82 | 91 | | |
83 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
7 | 12 | | |
8 | 13 | | |
9 | 14 | | |
10 | 15 | | |
11 | 16 | | |
12 | 17 | | |
13 | 18 | | |
14 | | - | |
| 19 | + | |
15 | 20 | | |
16 | 21 | | |
17 | 22 | | |
| |||
77 | 82 | | |
78 | 83 | | |
79 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
80 | 99 | | |
81 | 100 | | |
82 | 101 | | |
| |||
0 commit comments