π§ͺ Add unit tests for GitExecutor path validation#25
Conversation
- Implement comprehensive unit tests for `GitExecutor._validateFilePath` via public methods (`diff`, `stage`, `unstage`, `checkoutFile`, `cleanFile`, `blame`). - Mock internal `_run` method to avoid executing actual Git commands. - Update `src/types.ts` to use `import type` for `vscode` and convert enums to const objects to support Node.js native test runner (`--experimental-strip-types`). - Fix import paths in `src/git/gitExecutor.ts` to include `.ts` extensions for test runner compatibility. - Standardize path traversal error messages. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
π Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a π emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
π― What:
The testing gap addressed was the lack of unit tests for the
GitExecutor._validateFilePathmethod, which is responsible for preventing path traversal vulnerabilities when executing Git commands.π Coverage:
The following scenarios are now tested in
src/git/gitExecutor.test.ts:../outside.txt,../../etc/passwd, absolute paths outside the repo, and deep traversal attempts (sub/../../../outside).src/index.ts), local references (./local.file), and the repo root ("").diff,stage(multiple files),unstage,checkoutFile,cleanFile, andblame.β¨ Result:
vscodeimports and removingenumsyntax in shared types.PR created automatically by Jules for task 5599091117584387295 started by @giankpetrov