Complete operational oversight and security control for OpenClaw.
# 1. Initialize the audit system
python3 scripts/init.py
# 2. Start the web dashboard v3 (multilingual)
python3 scripts/server_v3.py
# Visit http://localhost:8080
# Switch language with 🌐 button (EN/ZH/JA/ES/FR/DE)
# 3. Use automatic auditing with snapshots
python3 << 'EOF'
import sys
sys.path.insert(0, ".")
from scripts.audited_ops import audited_exec
# All commands automatically described + snapshotted
audited_exec("rm important.txt") # EN: "Deleted ~/Desktop/important.txt"
# ZH: "删除了 ~/Desktop/important.txt"
# JA: "~/Desktop/important.txt を削除しました"
# Rollback anytime from the web UI!
EOF
New in v3.0:
Automatic logging of all OpenClaw operations:
Usage:
from logger import OperationLogger
logger = OperationLogger()
op_id = logger.log_operation(
tool_name="exec",
action="run_command",
parameters={"command": "ls -la"},
success=True,
duration_ms=150
)
Define access control rules:
# Check if operation is allowed
allowed, rule = logger.check_permission(
tool_name="exec",
action="run_command",
path="/etc/ssh/sshd_config"
)
if not allowed:
raise PermissionError(f"Blocked by rule: {rule}")
Default protected paths:
/etc/ssh/etc/sudoers~/.ssh/usr/bin/usr/sbinAdd custom rules:
INSERT INTO permission_rules (rule_name, tool_pattern, action_pattern, path_pattern, allowed, priority)
VALUES ('protect-my-data', 'write|edit', '*', '/data/*', False, 100);
Complete web-based management interface - no command line required!
Features:
Access: http://localhost:8080
All operations can be performed through the graphical interface - no need for command-line tools!
Monitor protected paths for changes:
python scripts/monitor.py ~/.ssh /etc/ssh /var/log
Tracks:
Create system state snapshots:
# Create snapshot
python scripts/rollback.py create "before-change" "Snapshot before making changes"
# List snapshots
python scripts/rollback.py list
# Compare snapshots
python scripts/rollback.py compare 1 2
# Restore (dry-run first)
python scripts/rollback.py restore 1 --dry-run
Limitations:
Located at: ~/.openclaw/audit.db
Tables:
operations - All tool calls and actionsfile_changes - File modifications linked to operationssnapshots - System state snapshotspermission_rules - Access control rulesaudit_alerts - Security and compliance alertsConfig file: ~/.openclaw/audit-config.json
Key settings:
{
"retention_days": 90,
"protected_paths": ["/etc/ssh", "~/.ssh"],
"snapshots_enabled": true,
"auto_snapshot_interval_hours": 24,
"web_ui": {
"enabled": true,
"port": 8080
}
}
Statistics:
GET /api/stats - Overview statisticsOperations:
GET /api/operations?limit=50&tool=exec - List operationsGET /api/operations/ - Operation detailsAlerts:
GET /api/alerts?resolved=false - List alertsPOST /api/alerts//resolve - Mark as resolvedSnapshots:
GET /api/snapshots - List all snapshotsPOST /api/snapshots - Create new snapshotPermissions:
GET /api/permissions/rules - List all rulesPOST /api/permissions/check - Check operation permission```bash
chmod 600 ~/.openclaw/audit.db
```
Dashboard not loading:
pip install flask watchdog plotlyFile monitor not working:
pip install watchdogPermission check failing:
SELECT * FROM permission_rules;Wrap OpenClaw tool calls:
from logger import OperationLogger
logger = OperationLogger()
def safe_exec(command):
# Check permission
allowed, rule = logger.check_permission("exec", "run_command", path=None)
if not allowed:
raise PermissionError(f"Blocked: {rule}")
# Log operation
op_id = logger.log_operation(
tool_name="exec",
action="run_command",
parameters={"command": command}
)
# Execute
try:
result = subprocess.run(command, shell=True, capture_output=True)
logger.log_operation_result(op_id, result, success=True)
return result
except Exception as e:
logger.log_operation_result(op_id, None, success=False)
raise
Create audit alerts:
logger.create_alert(
operation_id=op_id,
alert_type="security",
severity="high",
message="Attempted modification of protected file"
)
Get operation statistics:
stats = logger.get_statistics()
print(f"Total: {stats['total_operations']}")
print(f"Success rate: {stats['success_rate']:.2%}")
print(f"Unresolved alerts: {stats['unresolved_alerts']}")
Export data for analysis:
import sqlite3
import pandas as pd
conn = sqlite3.connect("~/.openclaw/audit.db")
df = pd.read_sql_query("SELECT * FROM operations", conn)
df.to_csv("audit_export.csv", index=False)
pip install flask watchdog plotly
For full functionality:
共 1 个版本