मुख्य सामग्री पर जाएँ
Skillpedia
टेस्टिंग8.0k · #12716

coverage-analysis

यह क्या करती है

यह स्किल मापती है कि फ़ज़िंग रन प्रोग्राम का कितना हिस्सा चलाता है, और नतीजे समझाती है। यह उन डेवलपर्स के लिए है जो जानना चाहते हैं कि उनके फ़ज़ टेस्ट सच में असरदार हैं या नहीं।

कब इस्तेमाल करें

  • ✓जब फ़ज़िंग रन नया कोड खोजना बंद कर दे और आप जानना चाहते हैं कि क्यों।
  • ✓जब आपने फ़ज़ टेस्ट बदला है और देखना है कि कवरेज सुधरा या नहीं।
  • ✓जब आपको समझना है कि कोड के कौन-से हिस्से आपके टेस्ट से कभी नहीं पहुँचते।

Skill का लिंक

https://github.com/trailofbits/skills/blob/main/plugins/testing-handbook-skills/skills/coverage-analysis/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/trailofbits/skills/blob/main/plugins/testing-handbook-skills/skills/coverage-analysis/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“क्या आप दिखा सकते हैं कि मेरा फ़ज़िंग रन असल में कौन-सा कोड पहुँचता है और क्या छूट जाता है?”

हर हफ़्ते 5 नई skills, 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:

  1. Assessing harness effectiveness: Understand which parts of your application are actually executed by your fuzzing harnesses
  2. 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
अपडेट की गई
2/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

audit-context-building

8.0k

यह आपके एजेंट को सुरक्षा जाँच से पहले किसी अनजान कोड को समझने में मदद करती है, हर फ़ंक्शन की मान्यताएँ और निर्भरताएँ नक्शे में दिखाकर।

कोडिंगसिक्योरिटी

algorand-vulnerability-scanner

8.0k

यह आपके एजेंट को Algorand कॉन्ट्रैक्ट्स में 11 आम सुरक्षा समस्याएँ जाँचने में मदद करती है, जैसे रीकीइंग हमले और बिना जाँची फ़ीस।

कोडिंगसिक्योरिटी

audit-prep-assistant

8.0k

यह आपके एजेंट को बाहरी सुरक्षा समीक्षा के लिए कोड तैयार करने में मदद करती है, जैसे स्टैटिक एनालिसिस, टेस्ट कवरेज और दस्तावेज़ीकरण।

कोडिंगसिक्योरिटी

cairo-vulnerability-scanner

8.0k

यह आपके एजेंट को StarkNet के Cairo कॉन्ट्रैक्ट्स में 6 गंभीर समस्याएँ जाँचने में मदद करती है, जैसे ओवरफ़्लो और सिग्नेचर रीप्ले।

कोडिंगसिक्योरिटी

मिलती-जुलती skills