ci-security-scanning-with-strix
它能做什么
这个技能使用 Strix 在 GitHub Actions、GitLab CI 或类似流水线中设置自动安全扫描。它面向希望每个拉取请求在合并前都经过检查的团队。
适用场景
- ✓团队希望每个拉取请求在合并前都进行安全扫描的时候。
- ✓持续集成流水线应阻止引入已确认漏洞的合并的时候。
- ✓有人希望把扫描结果以评论形式发布在拉取请求上的时候。
技能链接
https://github.com/usestrix/strix/blob/main/skills/ci-security-scanning-with-strix/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我希望我们 GitHub 仓库里的每个拉取请求在合并前都进行安全扫描。我该怎样设置?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会设置一个只扫描已更改文件的工作流,并在发现已确认的问题时使构建失败。结果可以发布到拉取请求和代码扫描中。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Set up Strix in CI/CD
You can gate PRs two ways — pick based on the environment, or combine them:
- Managed platform (recommended for most teams) — connect the GitHub/GitLab/Bitbucket app once and Strix reviews every PR with no workflow file, no runner, no Docker, and no LLM key. Results post as PR comments and land in the team dashboard. Best when you want zero CI maintenance, central tracking, or your runners lack Docker. See "Managed platform" below and the managed-pentesting-with-strix skill.
- Self-hosted OSS CLI in your runner — run a diff-scoped scan as a pipeline step. Fully in your infra, free (BYO LLM key), no external account. Requires Docker on the runner. Best for air-gapped/self-hosted CI or when you do not want scans leaving your environment.
Both fail the build on validated findings and both emit SARIF 2.1.0, so you can start with one and add the other later.
Option A — Self-hosted OSS CLI in the runner
Run a diff-scoped Strix scan on every PR: only changed files are tested, quick mode keeps it fast, and exit code 2 fails the build when validated vulnerabilities are found.
GitHub Actions
Create .github/workflows/security.yml:
name: Security Scan
on:
pull_request:
jobs:
strix-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # required for diff-scope resolution
- name: Install Strix
run: curl -sSL https://strix.ai/install | bash
- name: Run Security Scan
env:
STRIX_LLM: ${{ secrets.STRIX_LLM }}
LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
run: strix -n -t ./ --scan-mode quick --max-budget 10
# Don't fail open: a run that hits the hard budget stop exits 0 but leaves
# run.json status "stopped", not "completed". Enforce completion explicitly.
# This does not catch an agent that wrapped up early on a budget *warning*
# (it still calls finish_scan and records "completed"), so size the budget.
- name: Fail unless the scan completed
run: |
run_json=$(ls -t strix_runs/*/run.json | head -1)
status=$(jq -r .status "$run_json")
if [ "$status" != "completed" ]; then
echo "Strix run status is '$status' — the scan did not complete (likely budget exhausted). Raise --max-budget." >&2
exit 1
fi
Then tell the user to add two repository secrets: STRIX_LLM (model id, for example openrouter/z-ai/glm-5.3) and LLM_API_KEY (the provider key). Do not create these values yourself.
Notes:
- In CI/headless runs Strix automatically scopes to the PR's changed files (
--scope-mode auto). If diff resolution fails, keepfetch-depth: 0or set--diff-baseto the PR's actual base branch — useorigin/${{ github.base_ref }}in GitHub Actions rather than a hard-codedorigin/main, since repos use different default branches. - Exit codes:
0pass,2vulnerabilities found (fails the job),1setup error. Add--fail-on highto fail only on high/critical findings; lower ones are still reported, so a passing job is not a finding-free report. - The runner needs Docker (default GitHub-hosted Ubuntu runners have it).
- Size the budget so the scan completes — do not let it fail open. A
0exit means "no validated vulnerabilities in what was analyzed"; if--max-budgetis hit before the diff is fully covered, the scan wraps up early and can still exit0. The "Fail unless the scan completed" step above narrows the gap:strix_runs/<run>/run.jsonis"stopped"when the scan was cut off at the hard budget limit without a final report. It is not a complete guard — the agents get graduated wrap-up warnings before that limit, and a run that wraps up on a warning still callsfinish_scanand records"completed"with partial coverage. So keep that step in any pipeline that gates merges and give the scan real headroom (comparerun.json'sllm_usage.costagainst--max-budget; if it ran right up to the cap, raise it). For aquickdiff-scoped PR scan--max-budget 10is usually ample, raise it for large diffs.
Optional: upload findings to GitHub code scanning
Strix writes SARIF 2.1.0 to strix_runs/<run>/findings.sarif:
- name: Upload SARIF
if: always()
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: strix_runs
Other CI systems
Any pipeline works the same way
常见问题
运行它需要自己的服务器吗?
这个技能描述了两种选择:在你自己的运行器中运行的自托管工具,以及无需设置运行器的托管平台。
每次都会扫描整个仓库吗?
不会。自托管选项被描述为按差异范围扫描,只测试已更改的文件。
结果保存为什么格式?
这个技能说,两种选择都会生成 SARIF 2.1.0 格式的结果。
详情
作者的原始描述
Add security scanning to CI/CD with Strix — GitHub Actions, GitLab CI, or any pipeline — so every pull request gets a diff-scoped AI pentest that blocks vulnerable code before it merges, with results as PR comments and SARIF uploaded to code scanning. Covers both the self-hosted open-source CLI (runs in your runner) and the managed app.strix.ai platform (GitHub/GitLab app or API, no runner infra). Use when the user asks to add security scanning, SAST/DAST, pentesting, vulnerability checks, or automated security review to their CI pipeline, pre-merge gate, or PR workflow.
repo: usestrix/strix
热度
- GitHub 星标
- 73k
- 排名
- #3097
- 许可证
- Apache-2.0
- 更新时间
- 2026/10/30
评论
- …
同一仓库的更多技能
api-security-testing
73k教你的智能体使用 Strix 对 REST、GraphQL 或 gRPC 接口进行安全测试,重点检查授权漏洞以及 OWASP API Top 10 中的其他风险。
application-security-testing
73k帮你的智能体为整个产品规划安全测试,为每个部分选择合适的测试,运行它们,并按真实风险对修复工作排序。
find-security-vulnerabilities-in-code
73k帮你的智能体审查代码中的安全缺陷,例如注入和失效的访问控制,并通过测试攻击证明哪些问题确实存在。
fix-security-vulnerabilities-with-strix
73k帮你的智能体把已确认的安全发现转化为有针对性的代码修复,然后重新运行测试,证明每种攻击都已失效。