security-scanner
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSecurity Scanner
安全扫描器
Proactive pre-deployment security assessment. SAST pattern matching, secrets detection,
dependency scanning, OWASP/CWE mapping, and compliance heuristics.
Scope: Pre-deployment security audit only. NOT for code review (use ),
authorized live offensive testing (use with signed ROE), penetration
testing without static audit context, runtime security monitoring, or supply chain
deep analysis.
reviewpentest主动式部署前安全评估。包含SAST模式匹配、密钥检测、依赖项扫描、OWASP/CWE映射以及合规性启发式分析。
适用范围: 仅用于部署前安全审核。不适用于代码评审(请使用)、未经授权的实时攻击性测试(需签署ROE后使用)、无静态审核上下文的渗透测试、运行时安全监控或供应链深度分析。
reviewpentestCanonical Vocabulary
标准术语表
| Term | Definition |
|---|---|
| finding | A discrete security issue with severity, CWE mapping, confidence, and remediation |
| severity | CRITICAL / HIGH / MEDIUM / LOW / INFO classification per CVSS-aligned heuristics |
| confidence | Score 0.0-1.0 per finding; >=0.7 report, 0.3-0.7 flag as potential, <0.3 discard |
| CWE | Common Weakness Enumeration identifier mapping the finding to a known weakness class |
| OWASP | Open Web Application Security Project Top 10 category mapping |
| SAST | Static Application Security Testing — pattern-based source code analysis |
| secret | Hardcoded credential, API key, token, or private key detected in source |
| lockfile | Dependency manifest with pinned versions (package-lock.json, uv.lock, etc.) |
| compliance | Lightweight heuristic scoring against SOC2/GDPR/HIPAA controls |
| triage | Risk-stratify files by security relevance before deep scanning |
| remediation | Specific fix guidance with code examples when applicable |
| SARIF | Static Analysis Results Interchange Format for CI integration |
| false positive | Detection matching a pattern but not an actual vulnerability |
| 术语 | 定义 |
|---|---|
| finding | 一个具有严重性、CWE映射、置信度和修复建议的独立安全问题 |
| severity | 基于CVSS对齐启发式规则的CRITICAL / HIGH / MEDIUM / LOW / INFO分类 |
| confidence | 每个问题的评分(0.0-1.0);≥0.7则报告,0.3-0.7标记为潜在问题,<0.3则丢弃 |
| CWE | 通用弱点枚举标识符,将问题映射到已知的弱点类别 |
| OWASP | Open Web Application Security Project Top 10类别映射 |
| SAST | Static Application Security Testing — 基于模式的源代码分析 |
| secret | 在源代码中检测到的硬编码凭证、API密钥、令牌或私钥 |
| lockfile | 包含固定版本的依赖清单(package-lock.json、uv.lock等) |
| compliance | 针对SOC2/GDPR/HIPAA控制项的轻量级启发式评分 |
| triage | 在深度扫描前按安全相关性对文件进行风险分层 |
| remediation | 特定的修复指导,适用时提供代码示例 |
| SARIF | 用于CI集成的静态分析结果交换格式 |
| false positive | 匹配模式但并非实际漏洞的检测结果 |
Dispatch
调度指令
| $ARGUMENTS | Mode | Action |
|---|---|---|
| Empty | — | Show dispatch menu and example invocations; do not start a scan |
| | Full security scan of path (default: cwd) |
| | Targeted security check on specific files |
| | Dependency lockfile analysis |
| | Secrets-only regex scan |
| | SOC2/GDPR/HIPAA heuristic checklist |
| | Dashboard visualization of findings |
| Unrecognized input | — | Ask for clarification |
| $ARGUMENTS | 模式 | 操作 |
|---|---|---|
| 空参数 | — | 显示调度菜单和调用示例;请勿启动扫描 |
| | 对指定路径进行完整安全扫描(默认:当前工作目录) |
| | 对特定文件/目录进行针对性安全检查 |
| | 依赖项锁定文件分析 |
| | 仅密钥正则扫描 |
| | SOC2/GDPR/HIPAA启发式检查清单 |
| | 问题的可视化仪表盘展示 |
| 无法识别的输入 | — | 请求用户澄清 |
Empty / Help Gallery
空参数/帮助展示
When is empty, show the dispatch table above plus examples:
$ARGUMENTS/security-scanner scan/security-scanner check src/auth//security-scanner deps/security-scanner secrets/security-scanner compliance soc2/security-scanner report
State that a full scan runs only after the user picks a mode (for example ); empty invocation is menu-only.
scan当为空时,显示上述调度表及示例:
$ARGUMENTS/security-scanner scan/security-scanner check src/auth//security-scanner deps/security-scanner secrets/security-scanner compliance soc2/security-scanner report
需说明:仅当用户选择模式(例如)后才会运行完整扫描;空调用仅显示菜单。
scanMode: scan
模式:scan
Full codebase security assessment with triage and sampling for large codebases.
针对大型代码库进行全代码库安全评估,包含分类筛选和抽样。
Step 1: Triage
步骤1:分类筛选
- Enumerate files: or Glob to build file inventory
find - Risk-stratify files into HIGH/MEDIUM/LOW security relevance:
- HIGH: auth, crypto, payments, user input handling, API endpoints, config with secrets
- MEDIUM: data models, middleware, utilities touching external I/O
- LOW: static assets, tests, documentation, pure computation
- For 100+ files: sample — all HIGH, 50% MEDIUM, 10% LOW
- Build dependency graph of HIGH-risk files
- 枚举文件:使用或Glob构建文件清单
find - 将文件按安全相关性分为高/中/低风险:
- 高风险:认证、加密、支付、用户输入处理、API端点、含密钥的配置文件
- 中风险:数据模型、中间件、涉及外部I/O的工具类
- 低风险:静态资源、测试、文档、纯计算代码
- 文件数量≥100时进行抽样:扫描所有高风险文件、50%中风险文件、10%低风险文件
- 构建高风险文件的依赖关系图
Step 2: SAST Pattern Scan
步骤2:SAST模式扫描
Read HIGH and sampled MEDIUM/LOW files. Match against patterns from :
references/owasp-patterns.md- Injection flaws (SQL, command, path traversal, template, LDAP)
- Authentication/session weaknesses
- Sensitive data exposure (logging PII, plaintext storage)
- XXE, SSRF, deserialization
- Security misconfiguration
- XSS (reflected, stored, DOM)
- Insecure direct object references
- Missing access controls
- CSRF vulnerabilities
- Using components with known vulnerabilities
读取高风险及抽样的中/低风险文件,匹配中的模式:
references/owasp-patterns.md- 注入漏洞(SQL、命令、路径遍历、模板、LDAP)
- 认证/会话弱点
- 敏感数据暴露(记录PII、明文存储)
- XXE、SSRF、反序列化漏洞
- 安全配置错误
- XSS(反射型、存储型、DOM型)
- 不安全的直接对象引用
- 缺失访问控制
- CSRF漏洞
- 使用存在已知漏洞的组件
Step 3: Secrets Scan
步骤3:密钥扫描
Run:
Parse JSON output. Cross-reference findings with coverage.
uv run python scripts/secrets-detector.py <path>.gitignore运行:
解析JSON输出,将结果与覆盖范围交叉验证。
uv run python scripts/secrets-detector.py <path>.gitignoreStep 4: Dependency Check
步骤4:依赖项检查
If lockfiles exist, run:
Parse JSON output. Flag outdated or unmaintained dependencies.
uv run python scripts/dependency-checker.py <path>若存在锁定文件,运行:
解析JSON输出,标记过时或无人维护的依赖项。
uv run python scripts/dependency-checker.py <path>Step 5: CWE/OWASP Mapping
步骤5:CWE/OWASP映射
Map each finding to CWE IDs and OWASP Top 10 categories using .
Assign severity (CRITICAL/HIGH/MEDIUM/LOW/INFO) and confidence (0.0-1.0).
references/cwe-patterns.md使用将每个问题映射到CWE ID和OWASP Top 10类别。
分配严重性(CRITICAL/HIGH/MEDIUM/LOW/INFO)和置信度(0.0-1.0)。
references/cwe-patterns.mdStep 6: Remediation
步骤6:修复建议
For each finding with confidence >= 0.7, provide:
- CWE reference link
- Specific remediation guidance
- Code example when applicable
针对置信度≥0.7的每个问题,提供:
- CWE参考链接
- 特定修复指导
- 适用时提供代码示例
Step 7: Report
步骤7:报告
Present findings grouped by severity. Include:
- Executive summary with finding counts by severity
- Detailed findings with CWE, OWASP, evidence, remediation
- Dependency health summary (if lockfiles scanned)
- Secrets summary (count by type, no values exposed)
按严重性分组展示问题,包含:
- 按严重性统计问题数量的执行摘要
- 包含CWE、OWASP、证据、修复建议的详细问题列表
- 依赖项健康摘要(若扫描了锁定文件)
- 密钥摘要(按类型统计数量,不暴露实际值)
Mode: check
模式:check
Targeted security check on specific files or directories.
- Read the specified file(s)
- Apply full SAST pattern matching (no triage/sampling — scan everything)
- Run secrets detection on the path
- Map findings to CWE/OWASP
- Present findings with remediation
对特定文件或目录进行针对性安全检查。
- 读取指定文件
- 应用完整SAST模式匹配(无分类筛选/抽样 — 扫描所有内容)
- 对路径进行密钥检测
- 将问题映射到CWE/OWASP
- 展示问题及修复建议
Mode: deps
模式:deps
Dependency lockfile analysis.
- Detect lockfiles: ,
package-lock.json,yarn.lock,pnpm-lock.yaml,requirements.txt,uv.lock,Cargo.lock,go.sum,Gemfile.lockcomposer.lock - Run:
uv run python scripts/dependency-checker.py <path> - Parse output: dependency names, versions, ecosystem
- Flag: outdated packages, packages with known CVE patterns, unusual version pinning
- Present dependency health report
依赖项锁定文件分析。
- 检测锁定文件:、
package-lock.json、yarn.lock、pnpm-lock.yaml、requirements.txt、uv.lock、Cargo.lock、go.sum、Gemfile.lockcomposer.lock - 运行:
uv run python scripts/dependency-checker.py <path> - 解析输出:依赖项名称、版本、生态系统
- 标记:过时包、存在已知CVE模式的包、异常版本固定
- 展示依赖项健康报告
Mode: secrets
模式:secrets
Secrets-only scan using regex patterns.
- Run:
uv run python scripts/secrets-detector.py <path> - Parse JSON findings
- Cross-reference with — flag secrets in tracked files as CRITICAL
.gitignore - Check git history for previously committed secrets:
git log --diff-filter=D -p -- <file> - Present findings grouped by secret type, never exposing actual values
使用正则模式进行仅密钥扫描。
- 运行:
uv run python scripts/secrets-detector.py <path> - 解析JSON结果
- 与交叉验证 — 已跟踪文件中的密钥标记为CRITICAL
.gitignore - 检查git历史中已提交的密钥:
git log --diff-filter=D -p -- <file> - 按密钥类型分组展示结果,绝不暴露实际值
Mode: compliance
模式:compliance
Lightweight compliance heuristic scoring.
- Validate is one of:
<standard>,soc2,gdprhipaa - Run:
uv run python scripts/compliance-scorer.py <path> --standard <standard> - Read reference checklist from
references/compliance-checklists.md - Score each control as PASS/FAIL/PARTIAL with evidence
- Present compliance scorecard with overall percentage and failing controls
轻量级合规性启发式评分。
- 验证为以下之一:
<standard>、soc2、gdprhipaa - 运行:
uv run python scripts/compliance-scorer.py <path> --standard <standard> - 读取中的参考检查清单
references/compliance-checklists.md - 将每个控制项评分标记为PASS/FAIL/PARTIAL并提供证据
- 展示合规性评分卡,包含总体百分比和未通过的控制项
Mode: report
模式:report
Generate visual security dashboard.
- Collect all findings from the current session (or re-run scan if none exist)
- Format findings as JSON matching the dashboard schema
- Convert to SARIF if requested:
uv run python scripts/sarif-formatter.py - Inject JSON into
templates/dashboard.html - Copy to a temporary file, open in browser
生成可视化安全仪表盘。
- 收集当前会话中的所有问题(若无则重新运行扫描)
- 将问题格式化为符合仪表盘 schema 的JSON
- 若请求则转换为SARIF格式:
uv run python scripts/sarif-formatter.py - 将JSON注入
templates/dashboard.html - 复制到临时文件并在浏览器中打开
Scaling Strategy
扩展策略
| Scope | Strategy |
|---|---|
| 1-10 files | Direct scan, no triage |
| 11-100 files | Triage + prioritized scan |
| 100-500 files | Triage + sampling (all HIGH, 50% MEDIUM, 10% LOW) |
| 500+ files | Triage + sampling + parallel subagents by risk tier |
| 范围 | 策略 |
|---|---|
| 1-10个文件 | 直接扫描,无需分类筛选 |
| 11-100个文件 | 分类筛选 + 优先级扫描 |
| 100-500个文件 | 分类筛选 + 抽样(所有高风险、50%中风险、10%低风险) |
| 500+个文件 | 分类筛选 + 抽样 + 按风险层级并行调用子Agent |
Reference Files
参考文件
Load ONE reference at a time. Do not preload all references into context.
| File | Content | Read When |
|---|---|---|
| references/owasp-patterns.md | OWASP Top 10 with code patterns and detection heuristics | During SAST scan (Step 2) |
| references/cwe-patterns.md | Top 50 CWEs with detection patterns and remediation | During CWE mapping (Step 5) |
| references/secrets-guide.md | Secret patterns, false positive hints, triage guidance | During secrets scan |
| references/dependency-audit.md | Dependency audit protocol and CVE lookup workflow | During deps mode |
| references/compliance-checklists.md | SOC2/GDPR/HIPAA control checklists with scoring | During compliance mode |
| references/triage-protocol.md | Risk stratification methodology for security files | During triage (Step 1) |
| references/scope-boundary.md | Boundary with review, pen testing, runtime monitoring | When scope is unclear |
| Script | When to Run |
|---|---|
| scripts/secrets-detector.py | Secrets scan — regex-based detection |
| scripts/dependency-checker.py | Dependency analysis — lockfile parsing |
| scripts/sarif-formatter.py | SARIF conversion — CI integration output |
| scripts/compliance-scorer.py | Compliance scoring — heuristic checklist |
| Template | When to Render |
|---|---|
| templates/dashboard.html | After scan — inject findings JSON into data tag |
每次仅加载一个参考文件。请勿预先将所有参考文件加载到上下文。
| 文件 | 内容 | 加载时机 |
|---|---|---|
| references/owasp-patterns.md | 包含代码模式和检测启发式规则的OWASP Top 10 | SAST扫描期间(步骤2) |
| references/cwe-patterns.md | 包含检测模式和修复建议的Top 50 CWE | CWE映射期间(步骤5) |
| references/secrets-guide.md | 密钥模式、误报提示、分类筛选指导 | 密钥扫描期间 |
| references/dependency-audit.md | 依赖项审核协议和CVE查询流程 | deps模式期间 |
| references/compliance-checklists.md | 包含评分规则的SOC2/GDPR/HIPAA控制项检查清单 | compliance模式期间 |
| references/triage-protocol.md | 安全文件的风险分层方法 | 分类筛选期间(步骤1) |
| references/scope-boundary.md | 与评审、渗透测试、运行时监控的边界划分 | 范围不明确时 |
| 脚本 | 运行时机 |
|---|---|
| scripts/secrets-detector.py | 密钥扫描 — 基于正则的检测 |
| scripts/dependency-checker.py | 依赖项分析 — 锁定文件解析 |
| scripts/sarif-formatter.py | SARIF转换 — CI集成输出 |
| scripts/compliance-scorer.py | 合规性评分 — 启发式检查清单 |
| 模板 | 渲染时机 |
|---|---|
| templates/dashboard.html | 扫描后 — 将问题JSON注入数据标签 |
Critical Rules
关键规则
- Never expose actual secret values in output — show type, file, line only
- Every finding must map to at least one CWE ID
- Confidence < 0.3 = discard; 0.3-0.7 = flag as potential; >= 0.7 = report
- Run secrets-detector.py before reporting — regex patterns catch what LLM scanning misses
- Do not report phantom vulnerabilities requiring impossible conditions
- For 100+ files, always triage before scanning — never brute-force the full codebase
- Dependency findings require version evidence — never flag without checking the actual version
- Compliance mode is heuristic only — state this explicitly in output, never claim certification
- Present findings before suggesting fixes — always use an approval gate
- Cross-reference with .gitignore — secrets in untracked files are INFO, in tracked files are CRITICAL
- Load ONE reference file at a time — do not preload all references into context
- This skill is for pre-deployment audit only — redirect to review for code review, refuse pen testing requests
- SARIF output must conform to SARIF v2.1 schema — validate with sarif-formatter.py
- Never modify source files — this skill is read-only analysis
- 绝不在输出中暴露实际密钥值 — 仅显示类型、文件、行号
- 每个问题必须至少映射到一个CWE ID
- 置信度<0.3 = 丢弃;0.3-0.7 = 标记为潜在问题;≥0.7 = 报告
- 报告前必须运行secrets-detector.py — 正则模式可捕获LLM扫描遗漏的内容
- 不得报告需要不可能条件的虚假漏洞
- 文件数量≥100时,扫描前必须先进行分类筛选 — 绝不暴力扫描全代码库
- 依赖项问题需要版本证据 — 未经实际版本检查不得标记
- compliance模式仅为启发式分析 — 输出中需明确说明,绝不声称认证
- 建议修复前先展示问题 — 始终使用审批环节
- 与.gitignore交叉验证 — 未跟踪文件中的密钥标记为INFO,已跟踪文件中的密钥标记为CRITICAL
- 每次仅加载一个参考文件 — 请勿预先将所有参考文件加载到上下文
- 本工具仅用于部署前审核 — 代码评审请转向review,拒绝渗透测试请求
- SARIF输出必须符合SARIF v2.1 schema — 使用sarif-formatter.py验证
- 绝不修改源代码 — 本工具仅为只读分析