acidghost/renovate-vuln-report
GitHub: acidghost/renovate-vuln-report
一个 GitHub Action 和 CLI 工具,从 Renovate 创建的 PR 中解析元数据,对新容器镜像进行漏洞扫描并生成报告。
Stars: 0 | Forks: 0
# Renovate 漏洞报告
GitHub Action 和 CLI 会读取 pull request 正文中的 Renovate 元数据,并报告更新后的容器镜像的漏洞。
初版范围:报告 Renovate Docker 数据源更新中每个**新镜像修订版本**(New Image Revision)发现的漏洞。它**不会**与之前的镜像修订版本进行比较,也**不会**生成漏洞差异或 SBOM 差异。
## GitHub Action 用法
```
name: Renovate vulnerability report
on:
pull_request:
permissions:
contents: read
jobs:
renovate-vuln-report:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v6
with:
python-version: '3.14'
- name: Install Grype
run: |
curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh \
| sh -s -- -b /usr/local/bin
# Optional: log in before scanning private registry images.
# - uses: docker/login-action@v4
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
- uses: acidghost/renovate-vuln-report@main
```
默认情况下,该操作会将镜像更新漏洞报告写入 actions Step Summary。
### 针对 Forgejo/Gitea 的 Pull request 评论
Forgejo 和 Gitea 可能仅在作业输出中公开 `GITHUB_STEP_SUMMARY`,而不会在 pull request 界面中显示。请使用 `report-surface: pr-comment` 来发布受管理的 Pull Request 评论:
```
permissions:
contents: read
issues: write
steps:
- uses: actions/setup-python@v6
with:
python-version: '3.14'
- name: Install Grype
run: |
curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh \
| sh -s -- -b /usr/local/bin
- uses: acidghost/renovate-vuln-report@main
with:
report-surface: pr-comment
forge: forgejo # or gitea / github
forge-api-url: ${{ github.api_url }}
token: ${{ github.token }}
```
评论模式会在 pull request 对话中使用常规的 issue 评论,并通过隐藏标记来更新一条受管理的评论。Token 必须具备列出、创建和更新 pull request 评论的权限。摘要模式不需要写入权限。
## 必需的 Renovate 配置
配置 Renovate,使其在 PR 正文中为每个更新条目生成一条机器可读的元数据注释。
推荐:扩展此仓库的 Renovate Metadata Preset:
```
{
"extends": ["github>acidghost/renovate-vuln-report"]
}
```
或者直接内联复制配置:
```
{
"prBodyNotes": [
""
]
}
```
如果找不到 Renovate 元数据注释,该操作将会失败,因为它无法得知 Renovate 更新了什么内容。
## CLI
安装该软件包后,运行:
```
renovate-vuln-report
```
CLI 需要 actions 环境变量:
- `GITHUB_EVENT_NAME` 必须为 `pull_request`
- `GITHUB_EVENT_PATH` 必须指向 pull request 事件 payload
- `GITHUB_STEP_SUMMARY`,在使用摘要模式时,用于接收 markdown 报告
选项:
- `--report-surface summary|pr-comment` 默认为 `summary`
- `--forge github|forgejo|gitea` 默认为 `github`
- `--forge-api-url URL` 默认为 `GITHUB_API_URL`,然后是 `https://api.github.com`
环境变量:
- `RENOVATE_VULN_REPORT_SURFACE` 可设置默认的报告展示位置
- `RENOVATE_VULN_REPORT_FORGE` 可设置默认的 forge
- 当使用 `--report-surface pr-comment` 时,必须提供 `FORGE_TOKEN`
必须已安装 `grype` 并可在 `PATH` 中找到。Registry 凭证(如需要)必须在运行 CLI 之前准备好。
标签:DevSecOps, GitHub Action, Web截图, 上游代理, 依赖管理, 容器安全, 开源框架, 持续集成, 请求拦截, 逆向工具