代理安全GitHub操作
](https://github.com/marketplace/actions/agent-security-scan) ](https://www.npmjs.com/package/@empowered-humanity/agent-security)
扫描您的AI代理代码,查看每个拉取请求是否存在安全漏洞。由...驱动 @增强人性/代理人安全.
190+检测模式 涵盖:
- OWASP代理安全问题(ASI)前10名
- 快速注射和指令超控
- MCP协议漏洞(慢雾清单中的44种模式)
- 凭证暴露和硬编码秘密
- 跨代理权限升级(CAPE)
- 通过参数注入远程执行代码
- CWE为GitHub安全选项卡映射了结果
快速开始
增添 .github/workflows/agent-security.yml:
name: Agent Security Scan
on:
pull_request:
push:
branches: [main]
permissions:
security-events: write
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: empowered-humanity/agent-security-action@v1
with:
path: '.'
severity: 'medium'
fail-on: 'high'输入
| 输入 | 描述 | 默认值 |
|---|---|---|
path | 扫描路径(相对于仓库根) | . |
severity | 报告的最低严重程度(critical, high, medium, low) | medium |
format | 输出格式(console, json, sarif) | sarif |
fail-on | 如果发现达到或超过此严重程度,则工作流失败 | high |
upload-sarif | 将SARIF结果上传到GitHub代码扫描 | true |
version | 要使用的扫描仪版本 | latest |
输出
| 输出 | 描述 |
|---|---|
findings-count | 安全调查结果总数 |
risk-level | 总体风险评估(passed 或 failed) |
sarif-file | SARIF输出文件的路径 |
GitHub安全选项卡集成
当 upload-sarif 是 true (默认),结果直接显示在 安全 存储库的选项卡,其中包含:
- CWE ID链接到MITRE定义
- OWASP ASI类别标签
- 基于严重性的过滤
- pull请求上的内联代码注释
例子
仅扫描关键问题
- uses: empowered-humanity/agent-security-action@v1
with:
severity: 'critical'
fail-on: 'critical'扫描特定目录
- uses: empowered-humanity/agent-security-action@v1
with:
path: 'src/agents'JSON输出,不上传SARIF
- uses: empowered-humanity/agent-security-action@v1
with:
format: 'json'
upload-sarif: 'false'在后续步骤中使用扫描结果
- uses: empowered-humanity/agent-security-action@v1
id: security
with:
fail-on: 'critical'
- name: Comment on PR
if: steps.security.outputs.findings-count > 0
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Agent Security found ${{ steps.security.outputs.findings-count }} issue(s).`
})它检测到什么
| 类别 | 模式 | CWE覆盖范围 |
|---|---|---|
| 快速注射 | 25+ | CWE-74、CWE-94 |
| 学历暴露 | 15+ | CWE-798、CWE-522 |
| MCP安全 | 44 | CWE-346、CWE-918 |
| OWASP ASI01-ASI10 | 34 | CWE-74至CWE-506 |
| 参数注入/RCE | 15+ | CWE-88、CWE-78 |
| 跨代理升级 | 10+ | CWE-269 |
| 防御规避 | 10+ | CWE-693 |
许可证
麻省理工学院- 赋权人类,股份有限公司。
