Skip to content

Harden non-git project support: security, DRY, tests#485

Merged
bborn merged 1 commit intomainfrom
task/1944-non-git-followup
Mar 3, 2026
Merged

Harden non-git project support: security, DRY, tests#485
bborn merged 1 commit intomainfrom
task/1944-non-git-followup

Conversation

@bborn
Copy link
Owner

@bborn bborn commented Mar 2, 2026

Summary

Follow-up to #484 addressing code review findings:

  • Security: isValidWorkDir now requires an explicit allowedProjectDir parameter — only the project's configured path is accepted for non-worktree projects, not any arbitrary directory
  • DRY: Extracted boolToInt() helper to eliminate bool→int conversion duplication
  • Cleanup: Removed duplicate doc comment on isValidWorktreePath
  • Tests: Added 4 new test functions covering config helper, alias lookup, spotlight rejection, and stricter isValidWorkDir security assertions

Test plan

  • All existing tests pass
  • New TestProjectUsesWorktrees (config) — tests empty, unknown, enabled, and disabled projects
  • Alias-based lookup with UseWorktrees flag (db) — verifies flag preserved through alias resolution
  • TestSpotlightRejectsNonWorktreeProject (mcp) — verifies clear error message
  • Enhanced TestIsValidWorkDir — verifies path-matching security and rejects mismatched/arbitrary paths

🤖 Generated with Claude Code

Follow-up to #484 addressing review findings:

1. Security: isValidWorkDir now requires an explicit allowedProjectDir
   parameter instead of accepting any existing directory. createTmuxWindow
   passes the project's configured path, preventing arbitrary dir access.

2. DRY: Extract boolToInt() helper for bool→int SQLite conversion,
   removing duplication in CreateProject/UpdateProject.

3. Cleanup: Remove duplicate doc comment on isValidWorktreePath.

4. Tests: Add TestProjectUsesWorktrees (config), alias-based lookup
   with UseWorktrees flag (db), TestSpotlightRejectsNonWorktreeProject
   (mcp), and improved TestIsValidWorkDir with security assertions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bborn bborn merged commit c9697f9 into main Mar 3, 2026
3 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