nrdiiin/ai-code-security-reviewer-action
GitHub: nrdiiin/ai-code-security-reviewer-action
一款集成于 GitHub Actions 的 AI 代码安全扫描工具,可在 CI/CD 流程中自动发现漏洞并将结果以 SARIF 和 PR 评论形式反馈给开发者。
Stars: 0 | Forks: 0
# AI 代码安全审查器 — GitHub Action
此 **composite action** 可在您的 CI/CD pipeline 中调度 [AI Code Security Reviewer CLI](https://github.com/nrdiiin/ai-code-security-reviewer-cli)。它会扫描您的代码,为 GitHub Code Scanning 生成 SARIF 报告,并在 PR 中发布包含检查结果的评论。
## 快速开始
将以下内容添加到您的工作流中(例如 `.github/workflows/security.yml`):
```
name: Security Scan
on: [pull_request]
permissions:
contents: read
security-events: write
pull-requests: write
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: nrdiiin/ai-code-security-reviewer-action@v1
```
就这些!该 action 将自动扫描您的代码并对 PR 进行评论。
## 输入
| 输入 | 描述 | 默认值 |
|-------|-------------|---------|
| `path` | 要扫描的目录或文件路径 | `.` |
| `fail-on` | 导致 action 失败的严重性阈值(`critical`、`high`、`medium`、`low`、`info`) | `high` |
| `ignore` | 逗号分隔的 glob 模式以排除文件 | `""` |
| `comment-pr` | 在 PR 上发布带有扫描结果的评论(`true`/`false`) | `true` |
| `github-token` | 用于 API 调用的 GitHub token | `${{ github.token }}` |
## 输出
| 输出 | 描述 |
|--------|-------------|
| `findings-count` | 发现结果总数 |
| `sarif-file` | 生成的 SARIF 文件路径 |
## PR 评论预览
当 action 发现问题时,它会发布如下评论:
### 🛡️ AI Code Security Reviewer — 扫描结果
发现 **3 项问题**: 🔴 1 项 critical | 🟠 1 项 high | 🟡 1 项 medium
| 严重性 | 文件 | 描述 |
|----------|------|-------------|
| 🔴 critical | `auth.py` | SQL injection 漏洞 |
| 🟠 high | `api.py` | 缺少身份验证检查 |
| 🟡 medium | `utils.py` | 不安全的反序列化 |
📊 [在 Security 标签页中查看所有发现结果](https://github.com/owner/repo/security/code-scanning)
当没有发现结果时:
## 自定义配置
```
- uses: nrdiiin/ai-code-security-reviewer-action@v1
with:
path: "src/"
fail-on: "medium"
ignore: "**/test/**,**/vendor/**"
comment-pr: "true"
```
## 所需权限
您的工作流需要以下权限:
```
permissions:
contents: read
security-events: write # Upload SARIF to Code Scanning
pull-requests: write # Post PR comments
```
## 生态系统
| Repo | 用途 |
|------|---------|
| [ai-code-security-reviewer](https://github.com/nrdiiin/ai-code-security-reviewer) | 核心 SDK — 扫描引擎 |
| [ai-code-security-reviewer-cli](https://github.com/nrdiiin/ai-code-security-reviewer-cli) | CLI 工具 — 封装 SDK |
| **ai-code-security-reviewer-action** ← 您在这里 | GitHub Action — 在 CI 中运行 CLI |
## License
MIT
标签:AI, DevSecOps, GitHub Action, SAST, 上游代理, 代码安全审计, 盲注攻击, 自动化代码审查, 错误基检测, 静态代码分析