Repository navigation
fix(mcp): let search_code scan a POSIX project root that contains '$' - #3212
Conversation
index_repository accepts a root such as /tmp/repo$cash, but search_code ran the shell-metacharacter check on the stored root and refused every search of that project with "path or file_pattern contains invalid characters", even when neither argument was passed. On POSIX the root never reaches a shell: an indexed project is scanned in process and the unscoped fallback runs as find/sort/grep argv stages (DeusData#2634). So only reject line breaks there (the scan file list is newline-separated). Windows still splices the root into cmd/PowerShell, so it keeps the full check. file_pattern keeps its check on every platform, and a rejected root now gets its own error message. detect_changes is unchanged: it does splice the root into a git shell command and already reports "project path contains invalid characters". Fixes DeusData#3151 Signed-off-by: Guillaume Demay <guillaumedemay@hotmail.fr>
Cover the root-specific error path on every platform by rejecting a stored root_path containing a newline. Signed-off-by: Guillaume Demay <guillaumedemay@hotmail.fr>
|
Thank you, @GDemay! A project whose root contains Because it changes a security-relevant validation, the maintainer gives the final OK before it merges. |
Problem
index_repositoryaccepts a project root that contains$(for example/tmp/repo$cash).search_codethen checks the stored root for shell metacharacters and refuses every search of that project withpath or file_pattern contains invalid characters, even when neither a path nor a file_pattern was passed (#3151).Change
file_patternkeeps its check on every platform.project root_path contains characters search_code cannot pass to the scan command) instead of blaming path/file_pattern.detect_changesis unchanged: it does put the root into a git shell command, and it already reportsproject path contains invalid characters.Tests
search_code_root_path_with_dollar_issue3151(POSIX only): a root namedcbm-search-repo$cash-XXXXXX, searched both through the unscoped find/grep fallback and the indexed in-process scan. Both must returnmain.cwithout an error. On main both calls hit the old root check.search_code_rejects_newline_in_root_path_issue3151(all platforms): a stored root containing a newline returns the root-specific error message.scripts/test.sh --suites mcp(ASan + UBSan): 445 passed, 4 skipped, 0 failed.clang-format-20 --dry-run --Werror src/mcp/mcp.c,scripts/check-no-test-skips.sh,scripts/check-dco.sh: clean.Fixes #3151
written with AI assistance