Repository navigation
[AI-665] Normalize workspaceFolder before Cursor path redaction - #87
Conversation
CursorPayloadAssembler.RedactPaths previously did a single exact-string
Replace(repoPath, "/repo"). On Windows that misses any path that doesn't
exactly match repoPath's normalisation — different separator, different
case, trailing-slash variant, JSON-escaped backslashes — and absolute
paths leak to the server.
Two coordinated fixes:
* CursorCommand.ResolveWorkspaces normalises folderPath once (Path.GetFullPath
+ TrimEnd) and yields the normalised value to all call sites, so the
redaction repoPath always arrives in canonical native form.
* CursorPayloadAssembler.RedactPaths now tries three variants of the
trimmed repoPath against the bubble JSON: forward-slash, native
backslash, and the JSON-escaped backslash form ("\\\\"). Comparison is
case-insensitive on Windows, case-sensitive on POSIX. The escaped form
is replaced before the raw backslash form so we don't consume half of
an escape sequence mid-string.
Follow-up from Qodo review on #85 (bug #3 — Windows correctness).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Review Summary by QodoFix Windows path redaction with normalized workspace folders
WalkthroughsDescription• Normalize folderPath in CursorCommand.ResolveWorkspaces to canonical native form • Enhance RedactPaths to handle path separator variants (forward, backward, escaped) • Fix Windows path-leak where workspace.json and bubble JSON use different separators • Add comprehensive tests for cross-platform path redaction scenarios Diagramflowchart LR
A["workspace.json<br/>folderPath"] -->|NormalizePath| B["Canonical<br/>Native Form"]
B -->|ResolveWorkspaces| C["Normalized<br/>repoPath"]
C -->|RedactPaths| D["Path Variants<br/>forward/backward/escaped"]
D -->|Replace| E["Redacted JSON<br/>with /repo"]
File Changes1. src/Kapacitor.Cli.Core/Cursor/CursorPayloadAssembler.cs
|
Code Review by Qodo
1.
|
Previous catch silently continued when NormalizePath threw, leaving users with only the generic "No matching Cursor workspace found." message and no clue which workspace.json was malformed. Now writes a one-line diagnostic to stderr including the workspace storage subdir, the problematic folder path, and the exception message before continuing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Pushed fix for the silent-skip finding in 13f1c79: The new All 26 Cursor unit tests still pass. |
Summary
CursorCommand.ResolveWorkspacesnow normalisesfolderPathonce (Path.GetFullPath+TrimEnd) and yields the canonical native form to all call sites.CursorPayloadAssembler.RedactPathstries three variants of the (trimmed)repoPath— forward-slash, native backslash, and JSON-escaped backslash (\\\\) — replacing the escaped form first so we don't consume half of an escape sequence. Comparison isOrdinalIgnoreCaseon Windows,Ordinalon POSIX.workspace.jsonused forward slashes (or vice versa).Follow-up from Qodo review on #85 (bug #3 — Windows correctness).
Linear: AI-665
Test plan
Redacts_paths_with_trailing_separator_on_repoPath— trailing-slash variant matches.Redacts_backslash_paths_when_repoPath_uses_forward_slash— escaped Windows form in bubble JSON is stripped.Redacts_forward_slash_paths_when_repoPath_uses_backslash— inverse case.Redacts_unescaped_backslash_paths_in_object_typed_params— object-typed params via GetRawText().Redacts_absolute_paths_to_relativestill passes.🤖 Generated with Claude Code