代理sec
用于AI试剂安装的静态配置扫描仪和硬化剂。 检测配置错误、凭据泄漏、供应链风险和MCP工具中毒,然后将每个发现映射到 代理应用程序的OWASP前10名(2026).
支持OpenClaw、Claude Code、Cursor、Windsurf、Gemini CLI和MCP服务器生态系统。
范围: agentsec执行静态配置和文件分析。它不提供运行时保护、行为监控或实时威胁检测。作为深度防御策略中的一层。
快速开始
pip install agentsec-ai
agentsec scan扫描特定安装:
agentsec scan ~/.openclawagentsec检查什么
| 模块 | 范围 |
|---|---|
installation | 网关暴露、身份验证状态、DM/组策略、工具/沙盒设置、SSRF和安全检查、已知CVE版本检查、敏感文件/目录权限 |
skill | 指令恶意软件、危险代码模式(eval/exec/subprocess)、快速注入模式、前端能力风险、依赖/安装挂钩风险 |
mcp | 工具中毒模式、远程端点上的身份验证漏洞、危险的模式/权限、未经验证 npx 用法 |
credential | 检测秘密引擎(23个插件)+16个自定义模式(OpenAI、Anthropic、AWS、Databricks、HuggingFace、Groq、Mistral等)、高熵检测、git证书泄漏 |
参考目录:
核心命令
# Full installation scan (all scanners, default target=. )
agentsec scan
# JSON report for CI parsing and pipelines
agentsec scan -o json -f report.json
# SARIF output for GitHub code scanning upload
agentsec scan -o sarif -f results.sarif
# Run only selected scanners for focused checks
agentsec scan -s installation,mcp
# Fail build only at/above selected severity
agentsec scan --fail-on critical# Preview profile changes without writing config
agentsec harden -p workstation
# Apply profile and write hardened config values
agentsec harden -p workstation --apply
# Watch files and auto re-scan on security-relevant changes
agentsec watch ~/.openclaw -i 2
# Pre-install package gate (scan before install)
agentsec gate npm install express
# Pin MCP tool descriptions for rug-pull detection
agentsec pin-tools
# Generate shell hook wrappers for npm/pip install flows
agentsec hook --shell zsh列出可用的扫描仪(名称+描述):
agentsec list-scanners硬化型材
| 简介 | 预期用途 |
|---|---|
workstation | 单一所有者本地使用 |
vps | 远程/自托管部署 |
public-bot | 对不受信任的公共输入的最高限制 |
使用 agentsec show-profile 在应用之前检查确切的变化。
输出和退出代码
输出格式:
terminal(默认)jsonsarif
退出代码:
0:没有达到/超过阈值的发现1:调查结果达到/超过阈值2:使用错误(例如,未知的扫描仪名称)3:运行时错误(例如,文件访问失败)
GitHub操作
使用捆绑的复合动作:
name: Agent Security
on: [push, pull_request]
jobs:
agentsec:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- uses: debu-sinha/agentsec@v0.4.5
with:
fail-on: high
output: sarif
upload-sarif: 'true'动作定义:
截图
下面的截图显示了实验演示沙盒流(故意不安全的配置用于检测和强化演示)。闸门和吊钩行为记录在 docs/case-studies/003-preinstall-gate-blocked-malicious-package.md 和 docs/adr/ADR-0004-pre-install-gate.md.
步骤1:对故意不安全的演示配置进行初始扫描
步骤2:应用工作站硬化轮廓
步骤3:硬化后重新扫描结果
步骤4:硬化后的OWASP姿势视图
MCP生态系统安全仪表板
每周对排名前50的MCP服务器存储库进行自动安全扫描,评级为A至F。
查看完整的仪表板 -每周一通过GitHub Actions更新。
基准和研究
- 夹具基准 --精度/召回率/F1超过20个夹具套件(自制夹具,未独立验证)。
- Top-50 MCP研究 --agentsec只运行带有标准化结果输出的repro。
- Top-50学习套件 --模式、选择CSV、JSONL结果和摘要JSON。
当前已登记的Top-50汇总数据:
docs/benchmarks/top50/reports/top50_summary_20260215.jsondocs/benchmarks/top50/reports/top50_findings_20260215.jsonl
可重复性
夹具基准:
python docs/benchmarks/run_benchmark.py前50名研究报告:
powershell -ExecutionPolicy Bypass -File scripts\reproduce_top50_study.ps1 -DateStamp 20260215注意:semgrep和gitleaks基线运行在PowerShell repro脚本中是可选的,需要在PATH上使用这些工具。
对抗一致性审计(文档与工件):
python scripts/repo_consistency_audit.py案例研究
启动证据
发展
git clone https://github.com/debu-sinha/agentsec.git
cd agentsec
pip install -c requirements/constraints-dev.txt -e ".[dev]"
ruff check src tests
pytest贡献指南:
安全策略:
治理
问题接收是基于模板驱动的 .github/ISSUE_TEMPLATE/ 以保持高分诊和繁殖质量。
许可证
阿帕奇-2.0
