Skip to content

Conversation

@uinstinct
Copy link
Contributor

@uinstinct uinstinct commented Nov 6, 2025

Description

Ripgrep searches in gitignore directories such as node_modules. This results in stdout maxbuffer length exceededing. This PR fixes that.

AI Code Review

  • Team members only: AI review runs automatically when PR is opened or marked ready for review
  • Team members can also trigger a review by commenting @continue-review

Checklist

  • [] I've read the contributing guide
  • [] The relevant docs, if any, have been updated or created
  • [] The relevant tests, if any, have been updated or created

Screen recording or screenshot

[ When applicable, please include a short screen recording or screenshot - this makes it much easier for us as contributors to review and understand your changes. See this PR as a good example. ]

Tests

[ What tests were added or updated to ensure the changes work as expected? ]


Summary by cubic

Respect .gitignore in the CLI search tool to exclude ignored paths during ripgrep runs. This prevents scanning node_modules and similar folders, avoids stdout maxBuffer errors, and speeds up searches.

  • Bug Fixes

    • Read nearest .gitignore (via find-up) and add -g "!pattern" flags to ripgrep.
    • Ignore comments, blank lines, and negated rules.
    • Prevents maxBuffer overflows and reduces unnecessary matches.
  • Dependencies

    • Added find-up.

Written for commit f0217d2. Summary will update automatically on new commits.

@uinstinct uinstinct requested a review from a team as a code owner November 6, 2025 13:12
@uinstinct uinstinct requested review from tingwai and removed request for a team November 6, 2025 13:12
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Nov 6, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 2 files

Prompt for AI agents (all 2 issues)

Understand the root cause of the following 2 issues and fix them.


<file name="extensions/cli/src/tools/searchCode.ts">

<violation number="1" location="extensions/cli/src/tools/searchCode.ts:88">
Sanitize the .gitignore-derived glob before interpolating it into the shell command (or switch to a non-shell exec routine) to prevent command injection.</violation>

<violation number="2" location="extensions/cli/src/tools/searchCode.ts:93">
Rule violated: **Don&#39;t use console.log**

Do not introduce console.log calls; use the project&#39;s logger or remove the debug output to comply with the &quot;Don&#39;t use console.log&quot; guideline.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

}

for (const ignorePattern of await getGitignorePatterns()) {
command += ` -g "!${ignorePattern}"`;
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sanitize the .gitignore-derived glob before interpolating it into the shell command (or switch to a non-shell exec routine) to prevent command injection.

Prompt for AI agents
Address the following comment on extensions/cli/src/tools/searchCode.ts at line 88:

<comment>Sanitize the .gitignore-derived glob before interpolating it into the shell command (or switch to a non-shell exec routine) to prevent command injection.</comment>

<file context>
@@ -69,8 +84,13 @@ export const searchCodeTool: Tool = {
     }
 
+    for (const ignorePattern of await getGitignorePatterns()) {
+      command += ` -g &quot;!${ignorePattern}&quot;`;
+    }
+
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant