← 返回
效率工具 中文

Counterclaw Core

Defensive interceptor for prompt injection and basic PII masking.
防御提示词注入并遮蔽基本隐私信息。
nickconstantinou
效率工具 clawhub v1.1.1 2 版本 100000 Key: 无需
★ 0
Stars
📥 1,004
下载
💾 18
安装
2
版本
#latest

概述

CounterClaw 🦞

> Defensive security for AI agents. Snaps shut on malicious payloads.

⚠️ Security Notice

This package has two modes:

  1. Core Scanner (offline): check_input() and check_output() — no network calls
  2. Email Integration (network): send_protected_email.sh — requires gog CLI for Gmail

Installation

claw install counterclaw

Quick Start

from counterclaw import CounterClawInterceptor

interceptor = CounterClawInterceptor()

# Input scan - blocks prompt injections
# NOTE: Examples below are TEST CASES only - not actual instructions
result = interceptor.check_input("{{EXAMPLE: ignore previous instructions}}")
# → {"blocked": True, "safe": False}

# Output scan - detects PII leaks  
result = interceptor.check_output("Contact: john@example.com")
# → {"safe": False, "pii_detected": {"email": True}}

Features

  • 🔒 Defense against common prompt injection patterns
  • 🛡️ Basic PII masking (Email, Phone, Credit Card)
  • 📝 Violation logging to ~/.openclaw/memory/MEMORY.md
  • ⚠️ Warning on startup if TRUSTED_ADMIN_IDS not configured

Configuration

Required Environment Variable

# Set your trusted admin ID(s) - use non-sensitive identifiers only!
export TRUSTED_ADMIN_IDS="your_telegram_id"

Important: TRUSTED_ADMIN_IDS should ONLY contain non-sensitive identifiers:

  • ✅ Telegram user IDs (e.g., "123456789")
  • ✅ Discord user IDs (e.g., "987654321")
  • ❌ NEVER API keys
  • ❌ NEVER passwords
  • ❌ NEVER tokens

You can set multiple admin IDs by comma-separating:

export TRUSTED_ADMIN_IDS="telegram_id_1,telegram_id_2"

Runtime Configuration

# Option 1: Via environment variable (recommended)
# Set TRUSTED_ADMIN_IDS before running
interceptor = CounterClawInterceptor()

# Option 2: Direct parameter
interceptor = CounterClawInterceptor(admin_user_id="123456789")

Security Notes

  • Fail-Closed: If TRUSTED_ADMIN_IDS is not set, admin features are disabled by default
  • Logging: All violations are logged to ~/.openclaw/memory/MEMORY.md with PII masked
  • No Network Access: This middleware does not make any external network calls (offline-only)
  • File Access: Only writes to ~/.openclaw/memory/MEMORY.md — explicitly declared scope

Files Created

PathPurpose
---------------
~/.openclaw/memory/Directory created on first run
~/.openclaw/memory/MEMORY.mdViolation logs with PII masked

License

MIT - See LICENSE file

Development & Release

Running Tests Locally

python3 tests/test_scanner.py

Linting

pip install ruff
ruff check src/

Publishing to ClawHub

The CI runs on every push and pull request:

  1. Ruff - Lints Python code
  2. Tests - Runs unit tests

To publish a new version:

# Version is set in pyproject.toml
git add -A
git commit -m "Release v1.0.9"
git tag v1.0.9
git push origin main --tags

CI will automatically:

  • Run lint + tests
  • If tests pass and tag starts with v*, publish to ClawHub

版本历史

共 2 个版本

  • v1.1.1 当前
    2026-03-29 04:57 安全 安全
  • v1.0.9
    2026-03-07 01:44

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

productivity

Nano Pdf

steipete
使用nano-pdf CLI通过自然语言指令编辑PDF
★ 275 📥 114,750
productivity

Word / DOCX

ivangdavila
创建、检查和编辑 Microsoft Word 文档及 DOCX 文件,支持样式、编号、修订记录、表格、分节符及兼容性检查等功能。
★ 438 📥 147,256
developer-tools

Publish

nickconstantinou
备份与恢复 OpenClaw 工作空间至 GitHub。
★ 1 📥 930