coverage-analysis
하는 일
퍼징 실행이 프로그램의 얼마나 많은 부분을 실행하는지 측정하고 결과를 설명합니다. 퍼즈 테스트가 실제로 효과가 있는지 알고 싶은 개발자를 위한 것입니다.
사용하는 경우
- ✓퍼징이 새 코드를 찾지 못하고 멈춰서 그 이유를 알고 싶을 때.
- ✓퍼즈 테스트를 바꾼 뒤 커버리지가 좋아졌는지 확인하고 싶을 때.
- ✓어떤 코드 영역이 테스트에서 한 번도 도달하지 않는지 이해해야 하는 경우.
스킬 링크
https://github.com/trailofbits/skills/blob/main/plugins/testing-handbook-skills/skills/coverage-analysis/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“제 퍼징 실행이 실제로 도달하는 코드와 놓치는 코드를 보여 주실 수 있나요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 커버리지 추적과 함께 프로그램을 빌드하고, 저장된 테스트 입력을 실행한 다음 커버리지 보고서를 읽습니다. 그다음 테스트되지 않은 영역을 가리키고, 테스트 입력이나 시드 파일을 바꾸는 방법을 제안합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Coverage Analysis
Coverage analysis is essential for understanding which parts of your code are exercised during fuzzing. It helps identify fuzzing blockers like magic value checks and tracks the effectiveness of harness improvements over time.
Overview
Code coverage during fuzzing serves two critical purposes:
- Assessing harness effectiveness: Understand which parts of your application are actually executed by your fuzzing harnesses
- Tracking fuzzing progress: Monitor how coverage changes when updating harnesses, fuzzers, or the system under test (SUT)
Coverage is a proxy for fuzzer capability and performance. While coverage is not ideal for measuring fuzzer performance in absolute terms, it reliably indicates whether your harness works effectively in a given setup.
Key Concepts
| Concept | Description |
|---|---|
| Coverage instrumentation | Compiler flags that track which code paths are executed |
| Corpus coverage | Coverage achieved by running all test cases in a fuzzing corpus |
| Magic value checks | Hard-to-discover conditional checks that block fuzzer progress |
| Coverage-guided fuzzing | Fuzzing strategy that prioritizes inputs that discover new code paths |
| Coverage report | Visual or textual representation of executed vs. unexecuted code |
When to Apply
Apply this technique when:
- Starting a new fuzzing campaign to establish a baseline
- Fuzzer appears to plateau without finding new paths
- After harness modifications to verify improvements
- When migrating between different fuzzers
- Identifying areas requiring dictionary entries or seed inputs
- Debugging why certain code paths aren't reached
Skip this technique when:
- Fuzzing campaign is actively finding crashes
- Coverage infrastructure isn't set up yet
- Working with extremely large codebases where full coverage reports are impractical
- Fuzzer's internal coverage metrics are sufficient for your needs
Quick Reference
| Task | Command/Pattern |
|---|---|
| LLVM coverage instrumentation (C/C++) | -fprofile-instr-generate -fcoverage-mapping |
| GCC coverage instrumentation | -ftest-coverage -fprofile-arcs |
| cargo-fuzz coverage (Rust) | cargo +nightly fuzz coverage <target> |
| Generate LLVM profile data | llvm-profdata merge -sparse file.profraw -o file.profdata |
| LLVM coverage report | llvm-cov report ./binary -instr-profile=file.profdata |
| LLVM HTML report | llvm-cov show ./binary -instr-profile=file.profdata -format=html -output-dir html/ |
| gcovr HTML report | gcovr --html-details -o coverage.html |
Ideal Coverage Workflow
The following workflow represents best practices for integrating coverage analysis into your fuzzing campaigns:
[Fuzzing Campaign]
|
v
[Generate Corpus]
|
v
[Coverage Analysis]
|
+---> Coverage Increased? --> Continue fuzzing with larger corpus
|
+---> Coverage Decreased? --> Fix harness or investigate SUT changes
|
+---> Coverage Plateaued? --> Add dictionary entries or seed inputs
Key principle: Use the corpus generated after each fuzzing campaign to calculate coverage, rather than real-time fuzzer statistics. This approach provides reproducible, comparable measurements across different fuzzing tools.
Step-by-Step
Step 1: Build with Coverage Instrumentation
Choose your instrumentation method based on toolchain:
LLVM/Clang (C/C++):
clang++ -fprofile-instr-generate -fcoverage-mapping \
-O2 -DNO_MAIN \
main.cc harness.cc execute-rt.cc -o fuzz_exec
GCC (C/C++):
g++ -ftest-coverage -fprofile-arcs \
-O2 -DNO_MAIN \
main.cc harness.cc execute-rt.cc -o fuzz_exec_gcov
Rust:
rustup toolchain install nightly --component llvm-tools-preview
cargo +nightly fuzz coverage fuzz_target_1
Step 2: Create Execution Runtime (C/C++ only)
For C/C++ projects, create a runtime that executes your corpus:
// execute-rt.cc
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <stdint.h>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
void load_file_and_test(const char *filename) {
FILE *file = fopen(filename, "rb");
if (file == NULL) {
printf("Failed to open file: %s\n", filename);
return;
}
fseek(file, 0, SEEK_END);
long filesize = ftell(file);
r
자주 묻는 질문
커버리지에는 어떤 도구를 쓰나요?
llvm-cov, lcov, 또는 퍼저 자체의 커버리지 출력을 씁니다.
커버리지가 높으면 항상 좋은가요?
항상 그렇지는 않습니다. 커버리지는 도움이 되는 대리 지표이지, 퍼저의 좋음을 정확히 재는 척도가 아니라고 설명합니다.
퍼저가 더 깊이 가지 못하게 막는 것은 무엇인가요?
정확한 값에 대한 까다로운 검사이며, 보고서에서 커버되지 않은 부분을 읽어서 찾을 수 있습니다.
상세 정보
작성자의 원본 설명
Measures and interprets what a fuzzing campaign actually reaches, using llvm-cov, lcov, or a fuzzer's own coverage output. Covers baselining a new campaign, reading coverage reports, and turning uncovered regions into harness, seed, or dictionary work. Use when a fuzzer plateaus, when judging whether a harness is effective, after changing a harness, or when asking why some code is never reached.
repo: trailofbits/skills
인기도
- GitHub 스타
- 8.0k
- 순위
- #12716
- 라이선스
- CC-BY-SA-4.0
- 업데이트
- 2026. 11. 2.
댓글
- …
이 저장소의 다른 스킬
audit-context-building
8.0k에이전트가 보안 검토 전에 낯선 코드베이스를 익히고, 각 함수가 가정하고 보장하며 의존하는 것을 정리하도록 돕습니다.
algorand-vulnerability-scanner
8.0k에이전트가 TEAL이나 PyTeal 기반 Algorand 스마트 계약에서 키 재설정 공격, 수수료 미검증 등 보안 문제 11가지를 찾도록 돕습니다.
audit-prep-assistant
8.0k에이전트가 외부 보안 검토를 위해 코드베이스를 준비하도록 돕습니다. 정적 분석, 테스트 커버리지, 죽은 코드 정리, 명확한 문서화를 포함합니다.
cairo-vulnerability-scanner
8.0k에이전트가 StarkNet Cairo 스마트 계약에서 오버플로, 위험한 계층 간 메시지, 서명 재사용 등 6가지 문제를 검사하도록 돕습니다.
비슷한 스킬
test-driven-development
311k에이전트가 기능이나 수정을 만들기 전에 실패하는 테스트를 먼저 쓰고, 그것을 통과시키는 가장 작은 코드를 작성하도록 가르칩니다.
verification-before-completion
311k에이전트가 작업, 수정, 빌드가 완료되었거나 통과했다고 말하기 전에 실제 점검을 실행하고 결과를 읽도록 가르칩니다.
migrate-to-shoehorn
310k테스트 파일의 위험한 타입 캐스팅을 shoehorn 라이브러리로 바꿔, 테스트가 일부 데이터만 써도 타입 검사를 통과하도록 돕습니다.