fix: skip unreadable directories during trust scan#173
fix: skip unreadable directories during trust scan#173antitree wants to merge 1 commit intoalways-further:mainfrom
Conversation
…rror When find_files_recursive() encounters a directory with restricted permissions (e.g., mode 000), std::fs::read_dir() returns EACCES. Previously this was propagated as a fatal NonoError::Io, aborting the entire pre-exec trust scan and preventing the sandboxed command from launching. Now permission-denied errors on read_dir() and entry iteration are handled gracefully by skipping the inaccessible directory, consistent with the existing pattern for metadata errors on individual files (line 289). Adds a regression test that creates a mode-000 subdirectory and verifies find_instruction_files() succeeds without error. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Mark <[email protected]>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the stability of the trust scanning mechanism by implementing more resilient error handling for file system access. Previously, encountering directories or files with restricted permissions would cause the entire sandbox launch to fail. The changes ensure that such permission issues are now gracefully skipped, allowing the trust scan to complete successfully while logging debug information about the skipped items, thereby improving the overall robustness of the system. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
The pull request effectively addresses the issue of the trust scanner failing when encountering unreadable directories or files due to permission denied errors. The find_files_recursive function now gracefully skips such entries, logging them at a debug level, which significantly improves the robustness of the scan. The addition of a dedicated regression test case, find_instruction_files_skips_unreadable_dirs, thoroughly validates this fix, ensuring that the scanner correctly identifies accessible files while ignoring unreadable ones without aborting the entire process. This change aligns well with the goal of making the scanner more resilient to varying filesystem permissions.
|
good find @antitree ! One small change would balance things well. The trust policy has three enforcement levels:
What might be useful is if enforcement is Deny, treat an unreadable directory as an error (fail closed). If it's Warn or Audit, skipping with a warning is fine - the user has already opted into a more permissive posture. Should not be much of a change as wdyt? |
|
@antitree just on previous comment, we can follow up with that - then we just have a rust format simple fix and we can land. |
Summary
find_files_recursive) fatally errors when encountering a directory with restricted permissions (e.g., mode000)std::fs::read_dir()returnsEACCESon such directories, which was propagated as a fatalNonoError::Iovia?, aborting the entire sandbox launchcontinueFix
PermissionDeniederrors fromread_dir()by logging a debug message and returningOk(())(skip the directory)PermissionDeniederrors from entry iteration withcontinueHow to reproduce
Test plan
find_instruction_files_skips_unreadable_dirsthat creates a mode-000 subdirectory and verifiesfind_instruction_files()succeeds-D warnings -D clippy::unwrap_used🤖 Generated with Claude Code