fuzzing
यह क्या करती है
यह स्किल आपके एजेंट को FuzzTest फ़्रेमवर्क से फ़ज़ टेस्ट लिखना और रजिस्टर करना दिखाती है। यह उन डेवलपर्स के लिए है जो ऐसे कोड का टेस्ट करना चाहते हैं जो भरोसे के बाहर से आया इनपुट पढ़ता है।
कब इस्तेमाल करें
- ✓जब आप अपने AI से C++ यूनिट टेस्ट फ़ाइल में फ़ज़ टेस्ट जोड़ने को कहते हैं।
- ✓जब आप यादृच्छिक इनपुट से किसी parser या डेटा हैंडलर में क्रैश जाँचना चाहते हैं।
- ✓जब आपको ऐसा build आउटपुट फ़ोल्डर सेट करना है जो फ़ज़िंग चालू करे।
Skill का लिंक
https://github.com/chromium/chromium/blob/main/agents/skills/fuzzing/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरे C++ URL parser के लिए एक फ़ज़ टेस्ट लिखिए, जो यादृच्छिक इनपुट से क्रैश जाँचे।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
स्किल AI को एक property function लिखने का मार्गदर्शन देती है जो कोड के किसी नियम को जाँचता है, फिर उसे 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 को टेस्ट कोड और build सेटिंग्स लिखने में मदद करती है।
क्या यह स्किल 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
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
gn-deps-debugging
25kयह आपके एजेंट को GN build फ़ाइलों में गायब या गलत निर्भरताओं से होने वाली build त्रुटियाँ ठीक करने में मदद करती है, बिना बड़ी और अनावश्यक निर्भरताएँ जोड़े।
java-memory-leaks
25kयह आपके एजेंट को LeakCanary की लीक रिपोर्ट पढ़कर Android ऐप्स में Java मेमोरी लीक खोजने और ठीक करने में मदद करती है।
jni-type-conversion
25kयह आपके एजेंट को Android कोड में हाथ से लिखे Java-से-C++ रूपांतरण कोड की जगह सरल @JniType annotations लगाने में मदद करती है।
loadline
25kयह आपके एजेंट को LoadLine बेंचमार्क चलाने में मदद करती है, जो मापते हैं कि Android और डेस्कटॉप Chrome पर वेब पेज कितनी तेज़ी से लोड होते हैं।
मिलती-जुलती skills
test-driven-development
311kयह आपके एजेंट को किसी भी फ़ीचर या सुधार से पहले पहले असफल होने वाला टेस्ट लिखना, उसे असफल होते देखना, फिर पास करने वाला सबसे छोटा कोड लिखना सिखाती है।
verification-before-completion
311kयह आपके एजेंट को किसी काम, सुधार या build के पूरा या पास होने का दावा करने से पहले असली जांच चलाकर उसका आउटपुट पढ़ना सिखाती है।
migrate-to-shoehorn
310kआपकी टेस्ट फ़ाइलों में जोखिम भरे type casts की जगह shoehorn लाइब्रेरी लगाती है, ताकि टेस्ट अधूरे डेटा से भी type checks पास कर सकें।