fuzzing
하는 일
이 스킬은 FuzzTest 프레임워크를 사용해 퍼즈 테스트를 작성하고 등록하는 방법을 에이전트에게 보여 줍니다. 신뢰할 수 없는 입력을 읽는 코드를 테스트하려는 개발자를 위한 스킬입니다.
사용하는 경우
- ✓C++ 단위 테스트 파일에 퍼즈 테스트를 추가하라고 AI에 요청할 때.
- ✓무작위 입력으로 파서나 데이터 처리기의 충돌을 확인하고 싶을 때.
- ✓퍼징을 켜는 빌드 출력 폴더를 설정해야 할 때.
스킬 링크
https://github.com/chromium/chromium/blob/main/agents/skills/fuzzing/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
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::Constructororfuzztest::Mapto 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:
- 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.
- Verify unit tests pass
./out/fuzz/<target_name> \
--gtest_filter="MyComponentFuzzTest.MyPropertyFunctionDoesNotCrash"
- 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.
댓글
- …
이 저장소의 다른 스킬
gn-deps-debugging
25k에이전트가 GN 빌드 파일의 누락되거나 잘못된 의존성으로 생기는 빌드 오류를 고치도록 돕습니다. 넓고 불필요한 의존성은 추가하지 않습니다.
java-memory-leaks
25k에이전트가 LeakCanary의 누수 보고서를 읽어 Android 앱의 Java 메모리 누수를 찾고 고치도록 돕습니다.
jni-type-conversion
25k에이전트가 Android 코드에서 수동으로 작성한 Java와 C++ 간 변환 코드를 더 간단한 @JniType 주석으로 바꾸도록 돕습니다.
loadline
25k에이전트가 Android와 데스크톱 Chrome에서 웹 페이지가 얼마나 빨리 로드되는지 측정하는 LoadLine 벤치마크를 실행하도록 돕습니다.
비슷한 스킬
test-driven-development
311k에이전트가 기능이나 수정을 만들기 전에 실패하는 테스트를 먼저 쓰고, 그것을 통과시키는 가장 작은 코드를 작성하도록 가르칩니다.
verification-before-completion
311k에이전트가 작업, 수정, 빌드가 완료되었거나 통과했다고 말하기 전에 실제 점검을 실행하고 결과를 읽도록 가르칩니다.
migrate-to-shoehorn
310k테스트 파일의 위험한 타입 캐스팅을 shoehorn 라이브러리로 바꿔, 테스트가 일부 데이터만 써도 타입 검사를 통과하도록 돕습니다.