本 skill 提供完整的三层安全体系 + 主动防御:
层级作用状态🛡️ 事前预防AGENTS.md 高危操作二次确认规则✅ 已启用⚠️ 事中拦截飞书两阶段确认 → 执行/拦截✅ 可用📋 事后审计完整操作记录 + 日报/周报✅ 已部署🔒 主动防御速率监控 + 完整性校验 + 内容扫描 + 操作链分析 + URL白名单✅ 已部署
基础记录:
python
from audit_logger import log
log("file_delete", "删除了 ~/.trash/file.txt", session_key="xxx")
操作类型(枚举):
operation 值说明风险等级需确认file_delete文件删除high✅file_write文件写入mediumfile_move文件移动mediumexternal_send外部发送(邮件/消息)high✅config_change配置修改mediumcredential_access凭证访问critical✅permission_change权限变更high✅external_api外部API调用mediumuser_data_access用户数据访问mediumdestruction高危破坏性操作critical✅
查询日志:
python
from audit_logger import query
records = query(limit=20)
high_risk = query(risk_level="high", limit=50)
发送确认请求(用于 cron/自动化流程):
bash
python3 confirm.py request <操作类型> <详情> [执行脚本] [风险等级]
检查所有待确认项状态:
bash
python3 confirm.py check
查询指定确认ID状态:
bash
python3 confirm.py status <confirm_id>
功能:检测同一会话中的危险操作链,发现隐蔽的组合攻击。
bash
python3 chain_analyzer.py
检测的8种危险模式:
模式含义风险credential_access → external_send凭证窃取外传🔴file_delete → external_send销毁+外传🔴destruction → credential_access入侵准备🔴destruction → external_send销毁证据+外传🔴credential_access → file_write凭证被保存🟠credential_access → file_move凭证被转移🟠file_write → external_send敏感文件外传🟠external_api → external_sendAPI数据外传🟠
功能:限制只能从可信域名拉取数据。
bash
python3 url_guard.py check <URL> # 检查URL,返回0=允许/1=拒绝
python3 url_guard.py list # 列出白名单
python3 url_guard.py add <域名> [原因] # 添加白名单
python3 url_guard.py remove <域名> # 移除白名单
功能:检测 5 分钟内的异常操作速率
bash
python3 rate_monitor.py
检查文件是否被篡改:
bash
python3 skill_integrity.py check # 检查 + 告警
python3 skill_integrity.py update # 更新基准hash
python3 skill_integrity.py scan # 仅扫描
检测范围: .openclaw/workspace/skills/ 下的所有文件(排除 .git, node_modules)
在执行从外部 URL 或文本抓取的内容之前,先扫描其中的可疑模式。
支持的扫描类型:
bash
python3 content_scan.py url <URL> # 扫描URL内容
python3 content_scan.py text <文本> # 扫描文本内容
python3 content_scan.py file <路径> # 扫描本地文件
检测的威胁模式:
使用示例(集成到自动化流程):
python
import subprocess
result = subprocess.run(
["python3", "content_scan.py", "url", external_url],
capture_output=True
)
if result.returncode != 0:
print("⚠️ 内容安全审查未通过,中止执行")
# 发送告警
else:
print("✅ 内容安全,继续执行")
bash
python3 audit_report.py daily # 生成昨日审计日报
python3 audit_report.py daily 2026-03-20 # 指定日期
python3 audit_report.py weekly # 生成本周审计周报
bash
python3 audit_feishu.py daily # 发送每日审计日报到飞书
python3 audit_feishu.py weekly # 发送每周审计周报到飞书
必须先确认的操作类型:
确认格式:
text
⚠️ 即将执行高危操作,请确认:
- 操作:XXX
- 对象:XXX
回复「确认」或「取消」
在执行以下操作前,必须先调用 content_scan.py:
python
import subprocess
result = subprocess.run(
["python3", "~/.openclaw/workspace/skills/openclaw-audit-log/scripts/content_scan.py", "text", text],
capture_output=True
)
if result.returncode != 0:
# 内容审查未通过,询问用户确认
ask_user_confirm("内容审查发现可疑模式,是否继续?")
任务时间功能audit-daily-report每日 00:05生成昨日日报 → 推飞书audit-weekly-report每周一 00:10生成上周周报 → 推飞书audit-log-cleanup每月1日 03:00清理90天前旧日志audit-rate-monitor每5分钟检测操作速率异常 → 推飞书audit-chain-analyzer每5分钟检测危险操作链 → 推飞书audit-skill-integrity每日 06:00检查skill文件完整性 → 推飞书
类型路径审计日志~/.openclaw/audit/audit.log(JSONL)待确认队列~/.openclaw/audit/pending_confirms.json速率告警冷却~/.openclaw/audit/rate_alert_cooldown.jsonSkill基准hash~/.openclaw/audit/skill_hashes.json
content_scan.py 扫描代码skill_integrity.py check 检查文件完整性