Install
openclaw skills install runtime-security-guard企业级 AI 运行时安全防护技能 v2.1。提供 406+ 条安全规则,支持跨平台检测(Windows/macOS/Linux),检测 9 大类安全威胁。完全本地运行,无云端 API,无配额限制。配备现代化 Web 监控界面和自动化测试系统。
openclaw skills install runtime-security-guard🛡️ 406+ 条安全规则 | 10 大类威胁检测 + OpenClaw 特定威胁 + IM 机器人安全 | Web 监控界面 | 自动化测试 | 完全本地运行
v2.1.0 新增 (2026-03-26):
v2.0.0 已有:
# 搜索技能
clawhub search runtime-security-guard
# 安装技能
clawhub install runtime-security-guard
# 验证安装
openclaw skills list | grep runtime-security
# 下载并运行安装脚本
curl -fsSL https://raw.githubusercontent.com/nanlin300624/runtime-security-guard/main/install-no-sudo.sh | bash
# 或者手动下载
wget https://raw.githubusercontent.com/nanlin300624/runtime-security-guard/main/install-no-sudo.sh
chmod +x install-no-sudo.sh
./install-no-sudo.sh
特点:
# 克隆仓库
git clone https://github.com/nanlin300624/runtime-security-guard.git
cd runtime-security-guard
# 安装依赖
npm install
# 构建项目
npm run build
# 复制到 OpenClaw 技能目录
cp -r . ~/.openclaw/workspace/skills/runtime-security-guard/
# 下载技能包
wget https://github.com/nanlin300624/runtime-security-guard/releases/latest/download/runtime-security-guard.zip
# 解压到技能目录
unzip runtime-security-guard.zip -d ~/.openclaw/workspace/skills/
技能安装后自动运行,无需额外配置:
// 在 OpenClaw 中自动拦截和检测
// 所有文件读取、工具结果、用户输入都会被检测
# 启动 Web 服务器(默认端口 3000)
npm run web
# 访问监控界面
# http://localhost:3000
# 运行快速功能测试
npm run test:quick
# 运行单元测试
npm test
# 运行所有测试
npm run test:all
curl http://localhost:3000/api/stats
响应示例:
{
"total": 156,
"byType": {
"PROMPT_INJECTION": 45,
"DATA_EXFILTRATION": 32
},
"bySeverity": {
"CRITICAL": 12,
"HIGH": 54,
"MEDIUM": 67,
"LOW": 23
},
"timeRange": {
"start": "2026-03-07T12:00:00.000Z",
"end": "2026-03-07T13:30:00.000Z"
}
}
curl http://localhost:3000/api/alerts?limit=50
curl http://localhost:3000/api/performance
curl http://localhost:3000/api/health
// 风险阈值(0.0-1.0)
// 默认:0.6
// 低于此值的内容不会被标记为风险
// 缓存 TTL(毫秒)
// 默认:60000(60 秒)
// 缓存内容超过此时长后过期
// 最大缓存条目
// 默认:1000 条
// 预编译正则 - 启动时自动编译所有规则
// 双层缓存 - RuleEngine + DetectorManager
// 优先级执行 - CRITICAL → HIGH → MEDIUM → LOW
// 快速失败 - CRITICAL 规则命中立即返回
| 测试类型 | 测试数 | 通过率 |
|---|---|---|
| 单元测试 | 29 | 100% ✅ |
| 功能测试 | 6 | 100% ✅ |
| 压力测试 | 4 场景 | 优秀 ✅ |
| 覆盖率测试 | 21 | 100% ✅ |
# 快速功能测试
npm run test:quick
# 单元测试
npm test
# 压力测试
npm run test:stress
# 覆盖率测试
npm run test:coverage
# 所有测试
npm run test:all
| 场景 | 目标 | 实际 |
|---|---|---|
| 单次检测 | < 50ms | 0.01ms ✅ |
| 缓存命中 | < 5ms | < 1ms ✅ |
| CRITICAL 规则 | < 20ms | ~10ms ✅ |
| 批量检测 (100 次) | < 5000ms | ~1500ms ✅ |
| 负载 | 并发数 | QPS | 平均延迟 |
|---|---|---|---|
| 低负载 | 1 | ~65 | ~15ms |
| 中负载 | 5 | ~145 | ~7ms |
| 高负载 | 10 | ~200 | ~5ms |
| 超高负载 | 20 | ~250 | ~4ms |
| 指标 | 目标 | 实际 |
|---|---|---|
| 峰值内存 | < 150MB | ~100MB ✅ |
| 平均内存 | < 100MB | ~80MB ✅ |
src/rules/patterns/ 创建或编辑规则文件src/rules/rule-engine.ts 导入新规则import { plugin } from './runtime-security-guard';
// 获取告警统计
const stats = await plugin.getStats();
// 健康检查
const health = plugin.healthCheck();
// 性能报告
const report = plugin.getPerformanceReport();
import { RuntimeSecurityGuard } from './runtime-security-guard';
const guard = new RuntimeSecurityGuard();
// 启动 Web 监控
await guard.startWebServer(3000);
// 实时监控告警
guard.alerter.startMonitoring((alert) => {
console.log('新告警:', alert);
});
| 文档 | 说明 |
|---|---|
| SKILL.md | 技能说明 |
| README.md | 使用指南 |
| RELEASE.md | 发布说明 |
| PUBLISH-GUIDE.md | 发布指南 |
| WEB-MONITOR.md | Web 监控使用 |
| AUTO-TEST.md | 自动化测试 |
| ALERT-VIEWER.md | 告警查看 |
| PERFORMANCE-OPTIMIZATION.md | 性能优化 |
新增功能:
性能优化:
测试覆盖:
初始发布:
MIT License - 详见 LICENSE
感谢以下项目提供的灵感:
Made with ❤️ by nanlin@outlook.com
安全使用 AI,从 Runtime Security Guard 开始! 🦞🛡️