fix: enforce .rooignore rules for codebase indexing, search results, and file listing#11798
Open
roomote[bot] wants to merge 1 commit intomainfrom
Open
fix: enforce .rooignore rules for codebase indexing, search results, and file listing#11798roomote[bot] wants to merge 1 commit intomainfrom
roomote[bot] wants to merge 1 commit intomainfrom
Conversation
This was referenced Feb 28, 2026
…file listing - Harden validateAccess() to fall back to original path when realpath resolves outside cwd (fixes submodule/symlink bypass) - Change error handling in validateAccess() to fail closed (deny access) instead of fail open - Add .rooignore post-filtering in CodebaseSearchTool to exclude ignored files from search results even if they were previously indexed - Pass RooIgnoreController from manager through service-factory to scanner so the scanner reuses the workspace-root controller instead of creating its own from the scan directory - Fix FileWatcher to initialize fallback RooIgnoreController in initialize() so .rooignore rules load even when manager controller is not passed - Add tests for realpath-outside-cwd fallback, fail-closed error handling, CodebaseSearchTool rooignore filtering, and scanner controller passthrough Fixes #11797
91f662a to
ba42cbd
Compare
frbrdan-code
approved these changes
Feb 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related GitHub Issue
Closes: #11797
Description
This PR attempts to address Issue #11797 where
.rooignorerules were not being enforced for codebase indexing, file reads, or environment file listing. Feedback and guidance are welcome.Three interconnected fixes:
Harden
validateAccess()inRooIgnoreController.ts: WhenrealpathSyncresolves a path outsidecwd(common with git submodules and symlinks), the code now falls back to the original absolute path for relative path computation instead of producing../paths that the ignore library cannot match. The outer catch block now fails closed (deny access) instead of silently allowing access on errors.Add
.rooignorepost-filtering inCodebaseSearchTool.ts: Search results from the vector store are now filtered throughtask.rooIgnoreController.validateAccess()before being returned to the LLM. This ensures files that were indexed before being added to.rooignore(or that bypassed filtering during indexing) are excluded from search results.Pass
RooIgnoreControllerfrom manager to scanner via service-factory: The scanner previously created its ownRooIgnoreControllerusing the scan directory path, which could differ from the workspace root where.rooignorelives. Now the manager's controller is passed through to the scanner, ensuring consistent.rooignoreenforcement.Note on environment_details lock icons: Fix 1 directly addresses the missing lock icons in the environment_details file listing, since
formatResponse.formatFilesListcallsvalidateAccess()on the sameRooIgnoreController. The existingresponses-rooignore.spec.tstests verify this behavior.Test Procedure
validateAccesscovering:cwdviarealpathSync(submodule scenario) -- falls back to original pathcwdnow denied (fail closed)validateAccessnow deny access (fail closed)codebaseSearchTool.spec.tstest file covering:Run tests:
Pre-Submission Checklist
Documentation Updates
Additional Notes
cwd(now denied instead of allowed) is intentional -- this is a security-focused "fail closed" approach. If there are legitimate use cases for accessing files outsidecwdwhile.rooignoreis active, this could be revisited.rooIgnoreControllerparameter is optional, and the scanner falls back to creating its own if none is provided.Interactively review PR in Roo Code Cloud