본문으로 건너뛰기
Skillpedia
테스트25k · #10057

fuzzing

하는 일

이 스킬은 FuzzTest 프레임워크를 사용해 퍼즈 테스트를 작성하고 등록하는 방법을 에이전트에게 보여 줍니다. 신뢰할 수 없는 입력을 읽는 코드를 테스트하려는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓C++ 단위 테스트 파일에 퍼즈 테스트를 추가하라고 AI에 요청할 때.
  • ✓무작위 입력으로 파서나 데이터 처리기의 충돌을 확인하고 싶을 때.
  • ✓퍼징을 켜는 빌드 출력 폴더를 설정해야 할 때.

스킬 링크

https://github.com/chromium/chromium/blob/main/agents/skills/fuzzing/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/chromium/chromium/blob/main/agents/skills/fuzzing/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“제 C++ URL 파서용 퍼즈 테스트를 작성해서, 무작위 입력으로 충돌이 있는지 확인해 주실 수 있나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

이 스킬은 AI가 코드의 어떤 규칙을 확인하는 속성 함수를 작성하도록 안내한 뒤, FUZZ_TEST 매크로로 등록하게 합니다. 그러면 퍼저가 많은 입력을 시도해 실패를 찾습니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Fuzzing (Chromium)

1. Setup

Ensure the output directory is configured:

gn gen out/fuzz --args='enable_fuzztest_fuzz=true is_debug=false is_asan=true \
is_component_build=false use_remoteexec=true'

2. Implement the FUZZ_TEST

Add to *_unittest.cc alongside existing tests:

#include "third_party/fuzztest/src/fuzztest/fuzztest.h"
#include "third_party/googletest/src/googletest/include/gtest/gtest.h"

// 1. Define the property function. Use a descriptive name that reflects
// the property being tested (e.g., "ParseFooDoesNotCrash" or "RoundTripIsLossless").
void MyPropertyFunctionDoesNotCrash(int i, const std::string& s) {
  // Call code under test. Focus on functions parsing untrusted input, complex
  // state machines, or data processing.
  bool result = MyComponent::DoSomething(i, s);
  // Add test assertions about invariants (e.g. "roundtrip equality", "valid
  // output structure"). Sanitizers like ASAN catch crashes.
  EXPECT_TRUE(result);
}

// 2. Register with FUZZ_TEST macro
FUZZ_TEST(MyComponentFuzzTest, MyPropertyFunctionDoesNotCrash)
  .WithDomains(
      fuzztest::InRange(0, 100),
      fuzztest::Arbitrary<std::string>()
  );

For complex types:

  • Construct from primitives: If the object has a parsing constructor (e.g. GURL(string)), accept the primitive and construct it inside your test function.
  • Define a local domain: Use fuzztest::Constructor or fuzztest::Map to build valid objects.
    auto ArbitraryFoo() {
      return fuzztest::Constructor<Foo>(fuzztest::InRange(0, 10));
    }
    

3. Register in BUILD.gn

You MUST register the test in the fuzztests list (in alphabetical order) of the executable test target.

Case A: File is in a test() target

test("my_component_unittests") {
  sources = [ "my_component_unittest.cc" ]

  # Format: SuiteName.TestName
  fuzztests = [
    "MyComponentFuzzTest.MyPropertyFunctionDoesNotCrash",
  ]

  # No dependency changes are needed here. The build system
  # automatically adds FuzzTest dependencies for targets
  # with a `fuzztests` list.

}

Case B: File is in a source_set(): Add //third_party/fuzztest:fuzztest to deps.

source_set("tests") {
  sources = [ "my_component_unittest.cc" ]
  deps = [
    "//third_party/fuzztest:fuzztest",
    # ...
  ]
}

Find the executable test() target that depends on this source_set(): gn refs out/fuzz //path/to:source_set --testonly=true --type=executable --all

Then, ensure it lists the fuzz test in its fuzztests variable (in alphabetical order).

4. Mandatory verification workflow

The task is incomplete until you successfully execute this sequence:

  1. Find the target and Build

Find the executable test() target that contains your test file:

gn refs out/fuzz //path/to/my_component_unittest.cc --type=executable --all

Build the identified target (e.g. unit_tests or browser_tests):

autoninja --quiet -C out/fuzz <target_name>

Note: If the build fails with an include not allowed by DEPS error, see the Common Issues & Fixes section below.

  1. Verify unit tests pass
./out/fuzz/<target_name> \
--gtest_filter="MyComponentFuzzTest.MyPropertyFunctionDoesNotCrash"
  1. Verify fuzzing mode doesn't crash
./out/fuzz/<target_name> \
--fuzz="MyComponentFuzzTest.MyPropertyFunctionDoesNotCrash" --fuzz_for=10s

Resources

  • Chromium Guide: testing/libfuzzer/getting_started.md
  • Macro Usage: third_party/fuzztest/src/doc/fuzz-test-macro.md
  • Domains: third_party/fuzztest/src/doc/domains-reference.md
  • Fixtures: third_party/fuzztest/src/doc/fixtures.md

Common Issues & Fixes

Build failure: include not allowed by DEPS

Symptom: Build fails with an error like: ERROR: include not allowed by DEPS: third_party/fuzztest/...

Fix: You must allow the fuzztest include in the nearest DEPS file (usually in the same directory as your test or a parent directory). Add +third_party/fuzztest to specific_include_rules for your test files:

specific_include_rules = {
  ".*_unittest\\.cc": [
    "+third_party/fuzztest",
  ],
}
자주 묻는 질문

퍼즈 테스트란 무엇인가요?

코드에 많은 무작위 또는 비정상적인 입력을 보내 충돌이나 깨진 규칙을 찾는 테스트입니다. 일반 테스트가 놓치는 버그를 잘 찾습니다.

이것을 쓰려면 C++ 전문가여야 하나요?

잘 사용하려면 C++ 지식이 조금 필요합니다. 이 스킬은 AI가 테스트 코드와 빌드 설정을 작성하도록 돕습니다.

이 스킬은 Chromium 프로젝트 밖에서도 작동하나요?

예시는 Chromium에서 가져왔지만, FuzzTest 방식은 일반적인 프레임워크이므로 다른 C++ 프로젝트에도 적용할 수 있습니다.

상세 정보

작성자의 원본 설명

Implements, registers, and verifies fuzz tests in Chromium. Use when the user asks to add or write fuzzers in C++, or mentions fuzz testing or FUZZ_TEST.

repo: chromium/chromium

인기도

GitHub 스타
25k
순위
#10057
라이선스
BSD-3-Clause
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬