Skip to content

fix(#308): git clone basePath修正 - CM_ROOT_DIRを使用するよう変更#311

Merged
Kewton merged 4 commits intodevelopfrom
feature/308-worktree
Feb 19, 2026
Merged

fix(#308): git clone basePath修正 - CM_ROOT_DIRを使用するよう変更#311
Kewton merged 4 commits intodevelopfrom
feature/308-worktree

Conversation

@Kewton
Copy link
Owner

@Kewton Kewton commented Feb 18, 2026

Summary

  • CloneManagerのbasePath決定ロジックを修正し、CM_ROOT_DIRを参照するように変更
  • clone/route.tsと[jobId]/route.tsからgetEnv().CM_ROOT_DIRをbasePath としてDIパターンで注入
  • WORKTREE_BASE_PATHの非推奨化(console.warn警告付き後方互換維持)
  • エラーメッセージからの内部パス情報漏洩を修正(D4-001, D4-003)
  • targetDirパラメータの型検証を追加(D4-002)

変更内容

バグ修正

  • src/lib/clone-manager.ts: resolveDefaultBasePath()メソッドを追加し、basePath優先順位を config.basePath > WORKTREE_BASE_PATH(非推奨) > process.cwd() に変更
  • src/app/api/repositories/clone/route.ts: getEnv().CM_ROOT_DIRを取得しbasePath として渡す
  • src/app/api/repositories/clone/[jobId]/route.ts: 同様にbasePath を渡す(一貫性維持)

セキュリティ修正

  • パストラバーサルエラーメッセージからbasePath値を除去(D4-001)
  • ディレクトリ存在エラーメッセージからtargetPath完全パスを除去(D4-003)
  • targetDirパラメータのtypeof型検証を追加(D4-002)

テスト

  • tests/unit/lib/clone-manager.test.ts: basePath resolution関連テスト9件追加(47 tests total)
  • tests/integration/api-clone.test.ts: getEnvモック追加、型検証テスト追加(12 tests total)

Test plan

  • npx tsc --noEmit — 0 errors
  • npm run lint — 0 errors
  • npx vitest run tests/unit/lib/clone-manager.test.ts — 47/47 passed
  • npx vitest run tests/integration/api-clone.test.ts — 12/12 passed
  • 受入条件 8/8 passed

Closes #308

🤖 Generated with Claude Code

Kewton and others added 4 commits February 19, 2026 07:48
…mp/repos

- Inject getEnv().CM_ROOT_DIR as basePath in clone/route.ts and [jobId]/route.ts
- Add resolveDefaultBasePath() with WORKTREE_BASE_PATH deprecation warning
- Fix info disclosure: remove basePath/targetPath from error messages (D4-001/D4-003)
- Add targetDir type validation to prevent injection (D4-002)
- Add basePath resolution tests and security tests
- Update .env.example to document clone directory role

Resolves #308

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove unused imports (CloneResult, UrlNormalizer, getRepositoryByNormalizedUrl)
from clone-manager.test.ts and add @returns JSDoc tag to resolveDefaultBasePath()
for improved code documentation consistency.

Quality Metrics:
- Unit tests: 47 passed
- Integration tests: 12 passed
- TypeScript errors: 0
- ESLint errors: 0

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add design policy document with 4-stage review results
- Add issue review reports (8-stage multi-stage review)
- Add multi-stage design review reports (stages 1-4)
- Add work plan for implementation
- Add pm-auto-dev progress reports
- Update CLAUDE.md with Issue #308 module descriptions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Kewton Kewton merged commit 4d77459 into develop Feb 19, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant