AutoCyber-AI/crp-scan

GitHub: AutoCyber-AI/crp-scan

一款面向 LLM 集成代码库的 AI 治理扫描器,以 GitHub Action 和 CLI 形式检测不受管理的 LLM 调用及 CRP 合规问题。

Stars: 0 | Forks: 0

# CRP-Scan **面向集成 LLM 代码库的 AI 治理扫描器** [![GitHub Action](https://img.shields.io/badge/GitHub%20Action-CRP--Scan%20v1-blue?logo=github)](https://github.com/marketplace/actions/crp-scan) [![crprotocol](https://img.shields.io/pypi/v/crprotocol?label=crprotocol&logo=pypi)](https://pypi.org/project/crprotocol/) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE) 这是一个 GitHub Action 和 CLI,用于扫描你的代码库以检查 AI 治理合规性 — 检测启用了 CRP 的项目中的**不受管理的 LLM 调用**、**缺失的安全** **策略**、**缺失的审计** **追踪**以及**版本漂移**。 扫描结果将上传至 **GitHub Security 标签页**(SARIF),并 附加到 GitHub Actions 的步骤摘要中。
## 快速开始 将以下内容添加到你的 workflow(`.github/workflows/crp-scan.yml`)中: ``` name: CRP-Scan on: push: branches: [main, master] pull_request: branches: [main, master] schedule: - cron: '0 0 * * 1' # weekly Monday scan permissions: contents: read security-events: write # required for SARIF upload jobs: crp-scan: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: AutoCyber-AI/crp-scan@v1 ``` 就是这样。推送代码后,扫描将自动运行。 ## 检测内容 | 规则 | 严重程度 | 描述 | |------|----------|-------------| | **CRP001** | HIGH | 不受管理的 LLM 调用 — 调用路径中没有 CRP adapter 的直接 API 调用 | | **CRP002** | MEDIUM | 使用了 CRP 但未定义安全策略 | | **CRP003** | HIGH | 缺失中止 / 策略执行路径 | | **CRP004** | MEDIUM | 缺失来源 / 审计追踪 | | **CRP005** | LOW | 策略 lint — 仅报告、弱 grounding、不受信任的来源 | | **CRP006** | LOW | `crprotocol` 版本漂移 — 正在运行过时的包 | ## 输入项 | 输入项 | 默认值 | 描述 | |-------|---------|-------------| | `paths` | `.` | 要扫描的逗号分隔路径 | | `fail-on` | `HIGH` | 导致构建失败的最低严重程度(`LOW\|MEDIUM\|HIGH\|CRITICAL`) | | `format` | `text` | 控制台输出格式(`text\|json\|markdown\|sarif\|junit`) | | `upload-sarif` | `true` | 将 SARIF 上传到 GitHub Security 标签页 | | `summary` | `true` | 将 markdown 摘要附加到步骤摘要中 | | `report-only` | `false` | 从不导致构建失败(始终退出状态为 0) | | `min-version` | `''` | 要求的最低 `crprotocol` 版本 | | `min-grounding` | `0.0` | 策略 lint 的最低 grounding 得分(0.0–1.0) | | `python-version` | `3.11` | 要使用的 Python 版本 | | `crprotocol-version` | `''` | 锁定特定的 `crprotocol` 版本 | ## 输出项 | 输出项 | 描述 | |--------|-------------| | `sarif-file` | 生成的 SARIF 文件的路径 | | `findings-count` | 扫描发现结果的总数 | | `highest-severity` | 最高严重程度(`NONE\|LOW\|MEDIUM\|HIGH\|CRITICAL`) | ## 完整 workflow 示例 ``` name: CRP Governance Scan on: [push, pull_request] permissions: contents: read security-events: write jobs: governance: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Run CRP-Scan id: crp uses: AutoCyber-AI/crp-scan@v1 with: paths: 'src,app,lib' fail-on: MEDIUM format: markdown upload-sarif: true summary: true min-version: '3.1.0' min-grounding: '0.6' - name: Comment findings on PR if: github.event_name == 'pull_request' uses: actions/github-script@v7 with: script: | const count = '${{ steps.crp.outputs.findings-count }}'; const sev = '${{ steps.crp.outputs.highest-severity }}'; github.rest.issues.createComment({ ...context.repo, issue_number: context.issue.number, body: `## CRP-Scan Results\n\n**Findings:** ${count} \n**Highest severity:** ${sev}` }); ``` ## CLI 用法 在本地安装并运行: ``` pip install "crprotocol[cli]>=3.1.0" # 扫描当前目录 python -m crp scan # 扫描特定路径,遇到 HIGH+ 失败 python -m crp scan --paths src,lib --fail-on HIGH # 输出 SARIF 以供本地检查 python -m crp scan --format sarif --sarif results.sarif . # 完整选项 python -m crp scan --help ``` ## 在本地测试 Action 使用 [act](https://github.com/nektos/act) 在本地运行 Action: ``` # 安装 act brew install act # macOS # 运行 crp-scan workflow act push -W .github/workflows/crp-scan.yml ``` ## 安全与隐私 CRP-Scan 完全**在本地运行** — 不会将任何代码发送到外部服务器。 扫描器会读取你的源文件,应用静态分析规则,并 报告结果。 SARIF 上传使用标准的 GitHub Code Scanning API(经过 token 认证, 范围限制为你的代码库)。 ## 许可证 MIT — 详见 [LICENSE](LICENSE)。 底层的 `crprotocol` 包版权归 © AutoCyber-AI 所有,并根据 [crprotocol 许可证](https://github.com/AutoCyber-AI/context-relay-protocol/blob/main/LICENSE.md) 分发。 ## 链接 - [Context Relay Protocol 规范](https://github.com/AutoCyber-AI/context-relay-protocol) - [PyPI 上的 crprotocol](https://pypi.org/project/crprotocol/) - [完整设置与测试指南](https://github.com/AutoCyber-AI/context-relay-protocol/blob/main/docs/CRP_SCAN_ACTION_GUIDE.md) - [报告 Bug / 请求规则](https://github.com/AutoCyber-AI/crp-scan/issues) 完成
标签:AI治理, GitHub Action, SARIF, 安全合规, 文档结构分析, 网络代理, 自动化攻击, 逆向工具, 静态代码扫描