Skip to content

Commit d2ce224

Browse files
author
matdev83
committed
WIP; fixes
1 parent 861c121 commit d2ce224

9 files changed

+1689
-1545
lines changed

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ graph TD
8181
- [Gemini Backends Overview](#gemini-backends-overview)
8282
- [Quick Start](#quick-start)
8383
- [Using It Day-To-Day](#using-it-day-to-day)
84+
- [Dangerous Command Protection](#dangerous-command-protection)
8485
- [Security](#security)
8586
- [Debugging (Wire Capture)](#debugging-wire-capture)
8687
- [Optional Capabilities (Short List)](#optional-capabilities-short-list)
@@ -487,6 +488,78 @@ if response.metadata.get("reasoning"):
487488
display_clean_response(response.content)
488489
```
489490

491+
## Dangerous Command Protection
492+
493+
The proxy includes built-in protection against dangerous git commands that could potentially destroy your work or repository history. This safety feature detects and blocks destructive git operations before they can cause damage.
494+
495+
### Key Features
496+
497+
- **Pattern-Based Detection**: Uses regex patterns to identify dangerous git commands
498+
- **Real-Time Blocking**: Intercepts dangerous commands at the tool call level
499+
- **Comprehensive Coverage**: Blocks 30+ dangerous git operations including:
500+
- `git reset --hard` (discards all local changes)
501+
- `git clean -f` (deletes untracked files)
502+
- `git push --force` (overwrites remote history)
503+
- `git branch -D` (force deletes branches)
504+
- `git restore .` (discards unstaged changes)
505+
- And many more destructive operations
506+
507+
### Configuration
508+
509+
**Configuration (precedence: CLI > Environment > Config File)**:
510+
511+
**CLI Flags**:
512+
- `--disable-dangerous-git-commands-protection` to disable protection (overwrites config file and environment variable)
513+
514+
**Environment Variables**:
515+
- `DANGEROUS_COMMAND_PREVENTION_ENABLED=true|false` (default: true)
516+
517+
**Config File** (`config.yaml`):
518+
```yaml
519+
session:
520+
dangerous_command_prevention_enabled: true
521+
```
522+
523+
### Usage Examples
524+
525+
```bash
526+
# Default: protection enabled
527+
python -m src.core.cli --default-backend openai
528+
529+
# Explicitly disable protection
530+
python -m src.core.cli --disable-dangerous-git-commands-protection
531+
532+
# Enable via environment variable
533+
export DANGEROUS_COMMAND_PREVENTION_ENABLED=true
534+
python -m src.core.cli
535+
536+
# Disable via environment variable
537+
export DANGEROUS_COMMAND_PREVENTION_ENABLED=false
538+
python -m src.core.cli
539+
```
540+
541+
### Behavior
542+
543+
When a dangerous git command is detected, the proxy:
544+
1. Blocks the tool call execution
545+
2. Returns a descriptive steering message explaining why the command was blocked
546+
3. Logs the blocked attempt for debugging and security auditing
547+
4. Suggests safer alternatives when appropriate
548+
549+
### Example Blocked Commands
550+
551+
```bash
552+
# These commands will be blocked:
553+
git reset --hard HEAD
554+
git clean -f
555+
git push --force origin main
556+
git restore .
557+
git branch -D feature-branch
558+
git filter-branch --prune-empty
559+
```
560+
561+
**Note**: This protection is enabled by default for security. Only disable it if you understand the risks and need to execute these specific commands for legitimate reasons.
562+
490563
## Killer Features
491564

492565
### Compatibility

0 commit comments

Comments
 (0)