mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix: prevent false positives in recursive delete detection
The regex pattern for detecting recursive delete commands (rm -r, rm -rf, etc.) incorrectly matched filenames starting with 'r' — e.g., 'rm readme.txt' was flagged as 'recursive delete' because the dash-flag group was optional. Fix: make the dash mandatory so only actual flags (-r, -rf, -rfv, -fr) are matched. This eliminates false approval prompts for innocent commands like 'rm readme.txt', 'rm requirements.txt', 'rm report.csv', etc. Before: \brm\s+(-[^\s]*)?r — matches 'rm readme.txt' (false positive) After: \brm\s+-[^\s]*r — requires '-' prefix, no false positives
This commit is contained in:
parent
240f33a06f
commit
3227cc65d1
1 changed files with 1 additions and 1 deletions
|
|
@ -22,7 +22,7 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
DANGEROUS_PATTERNS = [
|
||||
(r'\brm\s+(-[^\s]*\s+)*/', "delete in root path"),
|
||||
(r'\brm\s+(-[^\s]*)?r', "recursive delete"),
|
||||
(r'\brm\s+-[^\s]*r', "recursive delete"),
|
||||
(r'\brm\s+--recursive\b', "recursive delete (long flag)"),
|
||||
(r'\bchmod\s+(-[^\s]*\s+)*777\b', "world-writable permissions"),
|
||||
(r'\bchmod\s+--recursive\b.*777', "recursive world-writable (long flag)"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue