一个对您的 GitHub Actions 执行安全扫描的 GitHub Action。
此 Action 基于 octoscan
以下是使用此 Action 的基本示例。该示例同时适用于 push 和 pull_request 事件。
---
name: Octoscan
on:
workflow_dispatch:
pull_request:
paths:
- '.github/workflows/*'
push:
paths:
- '.github/workflows/*'
permissions:
security-events: write
actions: read
contents: read
jobs:
octoscan:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- id: octoscan
name: Run octoscan
uses: synacktiv/action-octoscan@v1
- name: Upload SARIF file to GitHub
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: "${{steps.octoscan.outputs.sarif_output}}"
category: octoscan
如果您对目标仓库具有写入权限,可以在代码安全选项卡中查看安全结果:

或直接在拉取请求中查看:

输入基于 octoscan 的选项,您可以在此处找到它们。
以下均作为 step.with 键,为可选项:
💡 不能同时使用 enable_rules 和 disable_rules。
以下输出可通过此 Action 的 ${{ steps.<step-id>.outputs }} 访问。
| 名称 | 类型 | 说明 |
|---|---|---|
sarif_output | String | 包含 sarif 输出的文件名。 |
此 Action 需要 GitHub 集成令牌具有以下权限:
permissions:
security-events: write
actions: read
contents: read
security-events 用于将 octoscan 的输出推送到 GitHub 代码扫描。
| 名称 | 类型 | 说明 |
|---|
workdir | String | 相对于根目录的工作目录。 |
filter_triggers | String | 使用特定触发器扫描工作流(逗号分隔列表:"push,pull_request_target" 或预配置:external/allnopr)。默认为 external。 |
filter_run | Boolean | 仅在 run shell 脚本中搜索表达式注入。默认为 true。 |
ignore | String | 与您想要忽略的错误消息匹配的正则表达式。 |
disable_rules | String | 禁用特定规则。用 "," 分隔。不能与 enable_rules 同时使用。 |
enable_rules | String | 启用特定规则,这会禁用所有其他规则。用 "," 分隔。不能与 disable_rules 同时使用。 |