fix: wire destructive_command_guard plugin into hook engine (#316)#2
Closed
fix: wire destructive_command_guard plugin into hook engine (#316)#2
Conversation
- Register a run_shell_command hook that detects destructive shell commands before they execute - Prompt for confirmation in interactive terminals so risky commands can still be run intentionally - Hard-block destructive commands in non-interactive contexts to prevent accidental data loss in automation and agents - Return structured rejection details and user-facing warnings to make failures explicit and actionable
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.
Problem
The
destructive_command_guardplugin (mpfaffenberger#316) is silently dead code. The plugin loader atcode_puppy/plugins/__init__.py:29requires every built-in plugin to have aregister_callbacks.py. This plugin didn't have one — it shipped onlydetector.py+__init__.py+ a passing test suite. The detection patterns were defined, tested, and never wired.Compare to
force_push_guard/(mpfaffenberger#310): that plugin hasdetector.pyplusregister_callbacks.pythat callsregister_callback("run_shell_command", ...). That's why mpfaffenberger#310 actually works and mpfaffenberger#316 doesn't.Fix
Added
register_callbacks.pytodestructive_command_guard/, following the exact same pattern asforce_push_guard:run_shell_commandphaseget_user_approval_asyncwith a Rich panel (pattern name, description, full command){"blocked": True}and a descriptive error messageVerification
run_shell_commandhook chaingit status) →None(allowed)rm -rf /) → blocked with reasoningFixes mpfaffenberger#316