安全审计
- 作者仓库星标 3,406
- 作者更新于 实时读取
- 作者仓库 claude-octopus
- 领域
- 安全
- 兼容 Agent
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- 信任分
- 88 / 100 · 社区维护
- 作者 / 版本 / 许可
- @nyldn · 未声明 license
- Token 消耗评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部 API Key
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 底层运行要求
- 无特殊要求
- 文件与系统权限
-
- 只读
- 允许写入 / 修改
- Shell 执行
- 网络行为
- 仅限本地
- 安装命令数
- 26 条
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: skill-coverage-audit
description: Trace codepaths in diffs, map against tests, auto-generate missing coverage — use before shippin…
category: 安全
runtime: 无特殊运行时
---
# skill-coverage-audit 输出预览
## PART A: 任务判断
- 适用问题:安全审计、密钥扫描、权限检查或风险分析。
- 输入要求:目标材料、限制条件、期望输出和验收方式。
- 证据边界:围绕“Overview / Caps and Limits / Phase 1: Codepath Tracing”读取原文规则,不把推断写成作者承诺。
## PART B: 执行结果
- **01** 任务判断:确认你的需求是否属于安全审计、密钥扫描、权限检查或风险分析,并标出输入、限制和预期结果。
- **02** 执行计划:优先按“Overview / Caps and Limits / Phase 1: Codepath Tracing”拆成步骤,说明每一步会读取什么、修改什么、产出什么。
- **03** 交付结果:给出可复制的命令、文件改动、检查清单或内容草稿,并说明如何继续迭代。
- **04** 风险边界:结合 读取文件、写入/修改文件、执行终端命令、主要在本地完成、通常不需要额外 API Key 给出执行前确认项。
## Running Rules
- 读取文件、写入/修改文件、执行终端命令;主要在本地完成;通常不需要额外 API Key。
- 先小样例验证,再放大到真实任务。
- 交付时同时给结果、检查口径和下一步迭代建议。 原文出现了 `/octo` 这类斜杠命令;如果你的 Agent 支持命令触发,优先用命令开场,再补充目标和边界。
告诉 Agent 目标文件或材料、期望结果、不可改范围、是否允许联网或执行命令。本 Skill 的权限画像是:读取文件、写入/修改文件、执行终端命令。
先用一个小任务确认它会围绕“Overview / Caps and Limits / Phase 1: Codepath Tracing”工作;涉及文件或命令时,先看 diff、日志、预览或测试结果。
检查最终产物是否包含明确结果、必要证据和下一步动作;如果输出泛泛而谈,就补充输入、边界和验收标准后重跑。
---
name: skill-coverage-audit
description: Trace codepaths in diffs, map against tests, auto-generate missing coverage — use before shippin…
category: 安全
source: nyldn/claude-octopus
---
# skill-coverage-audit
## 什么时候使用
- 用于组织测试、定位失败并形成修复闭环 适合处理安全审计、密钥扫描、权限检查和风险分析,核心价值是把输入、判断、执行、验证和交付边界固定下来,避免 Agent 泛泛回答。 把任务拆成可执行、可检查、可继续迭代的步骤;通常不需要额外 API…
- 面向安全审计、密钥扫描、权限检查或风险分析,优先处理能明确输入、步骤和验收标准的工作。
## 需要提供什么
- 目标材料、目录范围、期望结果和不可改动内容。
- 是否允许联网、执行命令、读写文件或调用外部服务。
## 执行规则
- 围绕「Overview / Caps and Limits / Phase 1: Codepath Tracing」组织步骤,不把推断写成作者事实。
- 读取文件、写入/修改文件、执行终端命令;主要在本地完成;通常不需要额外 API Key。
- 先跑小样例,确认结果可检查后再扩大任务范围。
## 输出要求
- 给出最终产物、关键证据、验证方式和下一步动作。
- 信息不足时标记 unknown,不编造命令、平台或依赖。 作者原文负责流程事实;仓库文件负责来源和命令;流狐只补充适用场景、限制和质量判断。
skill "skill-coverage-audit" {
输入层 -> 用户目标 + 目标文件 + 禁止范围 + 验收标准
上下文层 -> Overview / Caps and Limits / Phase 1: Codepath Tracing
规则层 -> SKILL.md 触发条件 / 执行顺序 / 输出格式
运行层 -> 无特殊运行时 | 读取文件、写入/修改文件、执行终端命令 | 主要在本地完成
安全层 -> 通常不需要额外 API Key + 小任务验证 + diff / 日志复核
输出层 -> 可复制结果 + 检查清单 + 下一步迭代
} Host: Codex CLI — This skill was designed for Claude Code and adapted for Codex. Cross-reference commands use installed skill names in Codex rather than
/octo:*slash commands. Use the active Codex shell and subagent tools. Do not claim a provider, model, or host subagent is available until the current session exposes it. For host tool equivalents, seeskills/blocks/codex-host-adapter.md.
Test Coverage Audit
Overview
Trace every codepath in a diff, map each path against existing tests, visualize coverage gaps, and auto-generate tests for uncovered paths.
Core principle: Trace codepaths in changed files -> Map against existing tests -> Score coverage quality -> Generate tests for gaps -> Report before/after counts.
Caps and Limits
These hard limits prevent runaway analysis:
- 30 code paths max per audit. If a diff yields more than 30, prioritize by complexity and risk (error paths, security-sensitive branches, public API surfaces first).
- 20 tests generated max per audit. Focus on highest-impact gaps first.
- 2-minute per-test exploration cap. If understanding a single test path takes longer than 2 minutes, mark it as "needs manual review" and move on.
Phase 1: Codepath Tracing
Step 1: Identify Changed Files
Determine the diff scope. Use the most relevant source:
# PR diff
git diff --name-only main...HEAD
# Staged changes
git diff --name-only --cached
# Last commit
git diff --name-only HEAD~1..HEAD
Filter to source code files only (exclude configs, docs, generated files).
Step 2: Trace Data Flow Through Every Branch
For each changed file, you MUST trace:
- Conditionals -- Every
if/else,switch/case, ternary, and pattern match. Each branch is a separate codepath. - Error paths -- Every
catch,throw, error return, validation failure, and early return with error. WHY: Error paths are the most common source of untested bugs. - Function calls -- Every function invoked from changed code. Trace one level deep into callees to identify integration boundaries.
- Loop boundaries -- Empty collection, single item, and multi-item paths through loops.
- Guard clauses -- Every early return, null check, and permission gate.
Step 3: Build the Codepath Inventory
Produce a structured inventory:
## Codepath Inventory: [filename]
| # | Path Description | Type | Risk |
|---|-----------------|------|------|
| 1 | validateUser() happy path | conditional | low |
| 2 | validateUser() missing email | error | medium |
| 3 | validateUser() invalid format | error | medium |
| 4 | processOrder() empty cart guard | guard | high |
| 5 | processOrder() payment timeout | error | high |
| 6 | processOrder() success | conditional | low |
Type categories: conditional, error, guard, loop-boundary, integration, async
Risk assessment: high = user-facing failure or data loss, medium = degraded behavior, low = cosmetic or logging
Phase 2: Test Mapping and Quality Scoring
Step 1: Search for Existing Tests
For each file in the diff, search the test directory for related tests:
# Find test files that reference the changed file or its exports
# Search by filename pattern
find tests/ -name "*[changed_file_stem]*" -type f
# Search by import/require of the changed module
grep -rl "import.*from.*[module_name]" tests/
grep -rl "require.*[module_name]" tests/
# Search by function name references
grep -rl "[function_name]" tests/
Step 2: Score Test Quality
For each codepath, assess existing test coverage with this rubric:
| Rating | Meaning | Criteria |
|---|---|---|
| ★★★ | Behavior + edge cases tested | Tests assert behavior AND cover boundary conditions, error cases, and edge inputs |
| ★★ | Happy path tested | Tests cover the success path but miss error branches or edge cases |
| ★ | Smoke test only | Test exists but only checks the function runs without error (no meaningful assertions) |
| ☆ | No test found | No test references this codepath at all |
Step 3: Produce Coverage Map
Map each codepath to its test coverage:
## Coverage Map: [filename]
| # | Codepath | Test File | Rating | Notes |
|---|----------|-----------|--------|-------|
| 1 | validateUser() happy path | test-user.sh:42 | ★★★ | Asserts valid + invalid inputs |
| 2 | validateUser() missing email | test-user.sh:58 | ★★ | Tests missing, not malformed |
| 3 | validateUser() invalid format | -- | ☆ | No test for format validation |
| 4 | processOrder() empty cart guard | -- | ☆ | Guard clause untested |
| 5 | processOrder() payment timeout | test-orders.sh:30 | ★ | Checks no crash, no assertions |
| 6 | processOrder() success | test-orders.sh:15 | ★★★ | Full integration test |
Phase 3: Coverage Diagram
After completing the map, produce an ASCII coverage summary. This is the primary output artifact.
COVERAGE: 5/12 paths tested (42%)
Code paths: 3/5 (60%)
User flows: 2/7 (29%)
GAPS: 7 paths need tests
Break down by category:
BY TYPE:
conditional: 3/4 tested (75%) ████████░░
error: 1/5 tested (20%) ██░░░░░░░░
guard: 0/2 tested (0%) ░░░░░░░░░░
integration: 1/1 tested (100%) ██████████
BY RISK:
high: 1/3 tested (33%) ███░░░░░░░
medium: 2/5 tested (40%) ████░░░░░░
low: 2/4 tested (50%) █████░░░░░
Use full block for covered and light shade for uncovered. 10-character bar. Always show exact fractions and percentages.
Phase 4: Auto-Generate Tests
Step 1: Detect Project Test Conventions
Before generating any tests, you MUST detect the project's testing patterns:
**Detected Test Conventions:**
- Framework: [jest/vitest/pytest/bash/go test/etc.]
- Location: [tests/ | __tests__/ | src/**/*.test.* | etc.]
- Naming: [test-*.sh | *.test.ts | *_test.go | etc.]
- Style: [BDD describe/it | xUnit | TAP | custom]
- Helpers: [test-utils.ts | conftest.py | helpers/ | etc.]
- Assertion library: [built-in | chai | assert | etc.]
Step 2: Generate Tests for Uncovered Paths
For each no-test and smoke-only codepath, generate a test that:
- Follows project naming conventions -- same directory structure, same file naming pattern
- Uses existing test helpers -- import from the same test utilities the project already uses
- Tests behavior, not implementation -- assert observable outcomes, not internal state
- Covers the specific gap -- targets the exact branch or error path identified in Phase 1
- Includes edge cases -- aim for full coverage on each generated test
Step 3: Present Generated Tests
For each generated test, show:
### Generated: test for [codepath description]
**Covers:** Codepath #N from [filename]
**Raises coverage:** from no-test to full coverage
[test code block]
Step 4: Report Before/After
After generating all tests, show the coverage change:
BEFORE: 5/12 paths tested (42%)
AFTER: 11/12 paths tested (92%)
New tests generated: 6
Remaining gaps: 1 (manual review needed)
Integration with Other Skills
With flow-deliver / skill-code-review
Coverage audit runs as a complement to code review. When invoked during deliver phase:
- Code review assesses quality and correctness
- Coverage audit assesses test completeness
- Both feed into the ship/no-ship decision
With skill-tdd
If coverage audit finds gaps in new code, recommend the user adopt TDD for the next iteration. Coverage audit fixes existing gaps; TDD prevents future ones.
With skill-verification-gate
After generating tests, use skill-verification-gate to run the test suite and confirm the new tests pass.
Red Flags -- Do Not Do This
| Action | Why It Is Wrong |
|---|---|
| Count lines instead of paths | Line coverage misses branch coverage entirely |
| Generate tests without checking conventions | Tests that do not match project style will be rejected |
| Test implementation details | Brittle tests that break on refactoring |
| Skip error paths | Error paths are where most bugs live |
| Exceed the 30-path cap | Analysis becomes unfocused and slow |
| Generate more than 20 tests | Diminishing returns; focus on highest impact |
| Spend more than 2 min on one path | Mark as needs-manual-review and move on |
Quick Reference
1. TRACE -> Identify all codepaths in the diff (max 30)
2. MAP -> Find existing tests for each path
3. SCORE -> Rate coverage quality (no-test / smoke / happy-path / full)
4. DIAGRAM -> ASCII coverage visualization
5. GENERATE -> Auto-create tests for gaps (max 20)
6. REPORT -> Before/after test counts
先判断是否适合
作者设计意图
作者的方法与取舍
边界和复核