integrating-dast-with-owasp-zap-in-pipeline
本技能涵盖在 CI/CD 管道中集成 OWASP ZAP(Zed Attack Proxy)进行动态应用安全测试。 内容包括配置基线、完整和 API 扫描以针对运行中的应用程序,解读 ZAP 发现,调整扫描策略, 以及在 GitHub Actions 和 GitLab CI 中建立 DAST 质量门禁。
Best use case
integrating-dast-with-owasp-zap-in-pipeline is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
本技能涵盖在 CI/CD 管道中集成 OWASP ZAP(Zed Attack Proxy)进行动态应用安全测试。 内容包括配置基线、完整和 API 扫描以针对运行中的应用程序,解读 ZAP 发现,调整扫描策略, 以及在 GitHub Actions 和 GitLab CI 中建立 DAST 质量门禁。
Teams using integrating-dast-with-owasp-zap-in-pipeline should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/integrating-dast-with-owasp-zap-in-pipeline/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How integrating-dast-with-owasp-zap-in-pipeline Compares
| Feature / Agent | integrating-dast-with-owasp-zap-in-pipeline | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
本技能涵盖在 CI/CD 管道中集成 OWASP ZAP(Zed Attack Proxy)进行动态应用安全测试。 内容包括配置基线、完整和 API 扫描以针对运行中的应用程序,解读 ZAP 发现,调整扫描策略, 以及在 GitHub Actions 和 GitLab CI 中建立 DAST 质量门禁。
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 在管道中集成 DAST 与 OWASP ZAP
## 使用场景
- 测试运行中的 Web 应用程序以发现 XSS、SQLi、CSRF 和配置错误等漏洞时
- 仅 SAST 不够且需要运行时行为测试时
- 合规要求在生产前对 Web 应用程序进行动态安全测试时
- 测试 API(REST/GraphQL)的身份验证、授权和注入缺陷时
- 在生产部署前在预发布环境中建立持续 DAST 扫描时
**不适用于**扫描源代码(使用 SAST)、扫描依赖项(使用 SCA)或基础设施配置扫描(使用 IaC 扫描工具)。
## 前置条件
- OWASP ZAP Docker 镜像或本地安装(zaproxy/zap-stable 或 zaproxy/action-*)
- 可从 CI/CD runner 访问的运行中目标应用(预发布 URL 或 Docker 服务)
- ZAP 扫描规则配置(可选,用于调优)
- API 扫描的 OpenAPI/Swagger 规范(可选)
## 操作流程
### 步骤 1:在 GitHub Actions 中配置 ZAP 基线扫描
```yaml
# .github/workflows/dast-scan.yml
name: DAST Security Scan
on:
deployment_status:
workflow_dispatch:
inputs:
target_url:
description: 'Target URL to scan'
required: true
jobs:
zap-baseline:
name: ZAP Baseline Scan
runs-on: ubuntu-latest
services:
webapp:
image: ${{ github.repository }}:${{ github.sha }}
ports:
- 8080:8080
options: --health-cmd="curl -f http://localhost:8080/health" --health-interval=10s --health-timeout=5s --health-retries=5
steps:
- uses: actions/checkout@v4
- name: ZAP Baseline Scan
uses: zaproxy/action-baseline@v0.12.0
with:
target: 'http://webapp:8080'
rules_file_name: '.zap/rules.tsv'
cmd_options: '-a -j'
allow_issue_writing: false
- name: Upload ZAP Report
if: always()
uses: actions/upload-artifact@v4
with:
name: zap-baseline-report
path: report_html.html
```
### 步骤 2:配置 ZAP 完整扫描进行全面测试
```yaml
zap-full-scan:
name: ZAP Full Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: ZAP Full Scan
uses: zaproxy/action-full-scan@v0.12.0
with:
target: ${{ github.event.inputs.target_url || 'https://staging.example.com' }}
rules_file_name: '.zap/rules.tsv'
cmd_options: '-a -j -T 60'
- name: Upload Reports
if: always()
uses: actions/upload-artifact@v4
with:
name: zap-full-report
path: |
report_html.html
report_json.json
```
### 步骤 3:使用 OpenAPI 规范配置 API 扫描
```yaml
zap-api-scan:
name: ZAP API Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: ZAP API Scan
uses: zaproxy/action-api-scan@v0.12.0
with:
target: 'https://staging.example.com/api/openapi.json'
format: openapi
rules_file_name: '.zap/api-rules.tsv'
cmd_options: '-a -j'
```
### 步骤 4:配置 ZAP 扫描规则
```tsv
# .zap/rules.tsv
# 规则 ID 操作 (IGNORE/WARN/FAIL) 描述
10003 IGNORE # 易受攻击的 JS 库(由 SCA 处理)
10015 WARN # 缓存控制头不完整或缺失
10021 FAIL # 缺少 X-Content-Type-Options
10035 FAIL # 缺少 Strict-Transport-Security
10038 FAIL # 缺少内容安全策略
10098 IGNORE # 跨域配置错误(CDN)
40012 FAIL # 跨站脚本攻击(反射型)
40014 FAIL # 跨站脚本攻击(持久型)
40018 FAIL # SQL 注入
40019 FAIL # SQL 注入(MySQL)
40032 FAIL # .htaccess 信息泄露
90033 FAIL # Cookie 范围过宽
```
### 步骤 5:使用 Docker Compose 在本地运行 ZAP
```yaml
# docker-compose.zap.yml
version: '3.8'
services:
webapp:
build: .
ports:
- "8080:8080"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 10s
retries: 5
zap:
image: zaproxy/zap-stable:latest
depends_on:
webapp:
condition: service_healthy
command: >
zap-baseline.py
-t http://webapp:8080
-r /zap/wrk/report.html
-J /zap/wrk/report.json
-c /zap/wrk/rules.tsv
-I
volumes:
- ./zap-reports:/zap/wrk
- ./.zap/rules.tsv:/zap/wrk/rules.tsv
```
## 关键概念
| 术语 | 定义 |
|------|------|
| DAST | 动态应用安全测试 — 通过发送请求并分析响应来测试运行中的应用程序 |
| 基线扫描 | 快速被动扫描,爬取应用程序而不进行主动攻击,适合 CI/CD |
| 完整扫描 | 包括 XSS、SQLi 和其他注入漏洞攻击载荷的主动扫描 |
| API 扫描 | 使用 OpenAPI/Swagger 规范测试所有已记录 API 端点的针对性扫描 |
| 爬虫 | ZAP 通过跟踪链接发现应用程序页面和端点的爬取器 |
| 主动扫描 | ZAP 向已发现端点发送攻击载荷以查找可利用漏洞的阶段 |
| 被动扫描 | 分析 HTTP 响应中的安全头、Cookie 和信息泄露,无需发送攻击 |
| 扫描策略 | 定义启用哪些攻击类型及其强度级别的配置 |
## 工具与系统
- **OWASP ZAP**:用于 DAST 测试的开源 Web 应用安全扫描器
- **zaproxy/action-baseline**:用于 ZAP 被动基线扫描的 GitHub Action
- **zaproxy/action-full-scan**:用于 ZAP 主动完整扫描的 GitHub Action
- **zaproxy/action-api-scan**:支持 OpenAPI 的 API 专注扫描 GitHub Action
- **Nuclei**:具有基于模板检测功能的替代漏洞扫描器,适合 CI/CD 集成
## 常见场景
### 场景:将 DAST 集成到预发布部署管道
**背景**:团队在生产前部署到预发布环境,需要在阶段之间自动化 DAST 扫描以捕获运行时漏洞。
**方法**:
1. 在成功预发布部署后触发的管道中添加 DAST 作业
2. 先运行 ZAP 基线扫描以快速获得被动反馈(2-5 分钟)
3. 使用应用程序的 OpenAPI 规范进行针对性 API 扫描
4. 配置 rules.tsv 以对严重发现(XSS、SQLi)设为 FAIL,对头/Cookie 设为 WARN
5. 将 ZAP 报告作为管道产物上传以供审查
6. 如果检测到任何 FAIL 级别发现,则阻止生产部署
7. 安排每周对预发布环境进行完整扫描以获得更深入覆盖
**注意事项**:ZAP 完整扫描可能需要 30+ 分钟,并可能以攻击流量淹没预发布服务器。在 CI 中使用基线扫描,按计划进行完整扫描。在未协调的情况下对生产运行 DAST 可能触发 WAF 阻止和事件告警。
## 输出格式
```
ZAP DAST 扫描报告
======================
目标:https://staging.example.com
扫描类型:基线 + API
日期:2026-02-23
时长:4m 32s
发现:
FAIL: 3
WARN: 7
INFO: 12
PASS: 45
失败告警:
[高危] 40012 - 跨站脚本攻击(反射型)
URL:https://staging.example.com/search?q=<script>
方法:GET
证据:<script>alert(1)</script>
[中危] 10021 - 缺少 X-Content-Type-Options
URL:https://staging.example.com/api/v1/*
证据:响应头缺失
[中危] 10035 - 缺少 Strict-Transport-Security
URL:https://staging.example.com/
证据:HSTS 头不存在
质量门禁:失败(1 个高危,2 个中危发现)
```Related Skills
testing-api-security-with-owasp-top-10
使用自动化和手工测试技术,针对 OWASP API 安全 Top 10 风险对 REST 和 GraphQL API 端点进行系统性评估。
performing-threat-modeling-with-owasp-threat-dragon
使用 OWASP Threat Dragon 创建数据流图,运用 STRIDE 和 LINDDUN 方法论识别威胁,并生成威胁模型报告用于安全设计审查。
integrating-sast-into-github-actions-pipeline
本技能涵盖将静态应用安全测试(SAST)工具 CodeQL 和 Semgrep 集成到 GitHub Actions CI/CD 管道中。 内容包括配置对 pull request 和推送的自动代码扫描、调整规则以减少误报、将 SARIF 结果上传到 GitHub Advanced Security,以及建立在检测到高严重性漏洞时阻止合并的质量门禁。
building-ioc-enrichment-pipeline-with-opencti
OpenCTI 是一个以 STIX 2.1 为原生数据模型的开源网络威胁情报知识管理平台。本技能涵盖使用 OpenCTI 连接器生态系统构建自动化 IOC 富化流水线,通过 VirusTotal、Shodan、AbuseIPDB、GreyNoise 等来源对指标进行富化。
building-ioc-defanging-and-sharing-pipeline
构建自动化流水线,对失陷指标(URL、IP、域名、邮件)进行去危化处理以便安全共享,并通过 TAXII 推送和威胁情报平台以 STIX 格式分发。
building-automated-malware-submission-pipeline
构建自动化恶意软件提交和分析流水线,从终端和邮件网关收集可疑文件, 将其提交至沙箱环境和多引擎扫描器,并生成带有失陷指标(IOC)的研判结论以集成到 SIEM。 适用于 SOC 团队需要将恶意软件分析扩展到高容量告警分诊的场景,超越手动沙箱提交的限制。
triaging-vulnerabilities-with-ssvc-framework
使用 CISA 的利益相关方特定漏洞分类(SSVC)决策树框架对漏洞进行分类和优先排序,产出可操作的修复优先级:Track、Track*、Attend 或 Act。
triaging-security-incident
使用 NIST SP 800-61r3 和 SANS PICERL 框架对安全事件进行初始分类,确定严重性、范围和所需响应行动。 按类型对事件分类,根据业务影响分配优先级,并路由到相应的响应团队。适用于事件分类、 安全告警分类、严重性评估、事件优先级排序或初始事件分析等请求场景。
triaging-security-incident-with-ir-playbook
使用结构化 IR Playbook 对安全事件进行分类和优先排序,确定严重性、分配响应团队并启动适当的响应程序。
triaging-security-alerts-in-splunk
在 Splunk Enterprise Security 中对安全告警进行分类,通过 SPL 查询和事件审查(Incident Review) 仪表板对重要事件进行严重性分类、调查、关联相关遥测并做出升级或关闭决策。 适用于 SOC 分析师需要处理关联搜索产生的告警队列、确定调查优先级, 或需要为交接给二/三级分析师记录分类决策时。
tracking-threat-actor-infrastructure
威胁行为者基础设施追踪涉及使用被动 DNS、证书透明度日志、Shodan/Censys 扫描、WHOIS 分析和网络指纹技术,对对手控制的 C2 服务器、钓鱼域名和暂存服务器等资产进行监控、映射和持续追踪
testing-websocket-api-security
测试 WebSocket API 实现中的安全漏洞,包括 WebSocket 升级时缺少身份认证、跨站 WebSocket 劫持(Cross-Site WebSocket Hijacking,CSWSH)、通过 WebSocket 消息进行的注入攻击、输入校验不足、通过消息泛洪实施拒绝服务,以及通过 WebSocket 帧造成的信息泄露。测试人员使用 Burp Suite 拦截 WebSocket 握手和消息,构造恶意 payload,并测试 WebSocket 通道上的授权绕过。适用于 WebSocket 安全测试、WS 渗透测试、CSWSH 攻击或实时 API 安全评估相关请求。