fix(security): apply file safety rules to Copilot ACP fs handlers#13391
Merged
Conversation
file_safety now uses profile-aware get_hermes_home(), so the test fixture must override HERMES_HOME too — otherwise it resolves to the conftest's isolated tempdir and the hub-cache path doesn't match.
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.
Summary
ACP fs handlers now enforce the same file-safety rules as Hermes's own file tools: permission requests default-deny, reads of internal hub cache are blocked and secrets redacted, writes hit the protected-path denylist +
HERMES_WRITE_SAFE_ROOT.Salvaged from #2195 by @ifrederico — commit authorship preserved via rebase-merge.
Changes
agent/file_safety.py(new): shared helpersis_write_denied,get_read_block_error,build_write_denied_paths/prefixes,get_safe_write_root. Profile-aware (get_hermes_home()for.env+ hub cache).agent/copilot_acp_client.py:session/request_permissionnow returnscancelledinstead ofallow_once;fs/read_text_filegates onget_read_block_error()and runsredact_sensitive_text()on content;fs/write_text_filegates onis_write_denied().tools/file_operations.py,tools/file_tools.py: delegate to the shared module; all existing entries (.docker,.azure,.config/gh, profile-aware.env) preserved.tests/agent/test_copilot_acp_client.py: 5 regression tests.scripts/release.py: AUTHOR_MAP entry for @ifrederico.Validation
tests/agent/test_copilot_acp_client.pytests/tools/test_file_operations.py+test_file_tools.py~/.ssh/id_rsaand~/.hermes/.envdenied • normal writes succeedCloses #2195.