Programowanie · Testowanie
fuzzing
/fuzzing
Pisze, rejestruje i sprawdza fuzzery w C++ w projekcie Chromium, w tym testy z makrem FUZZ_TEST.
- Autor
- chromium ↗
- Repozytorium
- chromium ↗
- Licencja
- BSD-3-Clause
- Ostatnia zmiana repozytorium
- 13.11.2026
Ocena i bezpieczeństwo
100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
- Pliki w paczce
- 2
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Przestarzałość
Brak sygnałów. Repozytorium zmienione 13.11.2026, bez odwołań do wycofanych modeli i API.
Licencja
BSD-3-Clause, otwarta.
Co robi i kiedy
Pisze, rejestruje i sprawdza fuzzery w C++ w projekcie Chromium, w tym testy z makrem FUZZ_TEST.
Oryginalny opis (EN)
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.
Jak działa
- 1. Setup
- Resources
- Common Issues & Fixes
Sekcje z nagłówków SKILL.md, w oryginale · 170 linii, 578 słów
Podgląd SKILL.md
---
name: fuzzing
description: 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.
---
# Fuzzing (Chromium)
## 1. Setup
Ensure the output directory is configured:
```bash
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:
```cpp
#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.
```cpp
auto ArbitraryFoo() {
return fuzztest::Constructor<Foo>(fuzztest::InRange(0, 10));
}
```
For seeds or dictionaries: prefer inline `.WithSeeds({...})` or
`fuzztest::String().WithDictionary({...})` when small, which need no file
packaging. If loading on-disk files from `base::DIR_SRC_TEST_DATA_ROOT`
(`fuzztest::ReadFilesFromDirectory`, `fuzztest::ReadDictionaryFromFile`), pass a
**function pointer** (e.g. `.WithSeeds(ReadMyCorpus)`)—never an eager call,
which runs before `main()` and crashes on Android before
`DIR_SRC_TEST_DATA_ROOT` is configured.
### 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**
```gn
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`.
```gn
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).
If your test reads on-disk seed or dictionary files from
`DIR_SRC_TEST_DATA_ROOT`, add them to `data = [ ... ]`—and if the enclosing
`test()` target runs on iOS, also bundle them via `bundle_data` or
`bundle_data_from_filelist` (GN `data` is not copied into iOS `.app` bundles;
see **Seed corpora and dictionaries** in
`testing/libfuzzer/getting_started.md`).
### 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:
```bash
gn refs out/fuzz //path/to/my_component_unittest.cc --type=executable --all
```
Build the identified target (e.g. `unit_tests` or `browser_tests`):
```bash
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.*
2. Verify unit tests pass
```bash
./out/fuzz/<target_name> \
--gtest_filter="MyComponentFuzzTest.MyPropertyFunctionDoesNotCrash"
```
3. Verify fuzzing mode doesn't crash
```bash
./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:
```python
specific_include_rules = {
".*_unittest\\.cc": [
"+third_party/fuzztest",
],
}
```
Pliki w paczce (2)
- OWNERS 1 KB
- SKILL.md 5 KB
Wersje
| Repozytorium | Wynik | Licencja |
|---|---|---|
| Ta strona · chromium/chromium | 100 | BSD-3-Clause |
| gosuda/dalcom-skills | 100 | Apache-2.0 |
| cybasecurity/clarity-skills | 100 | MIT |
| OutlineDriven/outline-driven-development | 100 | Apache-2.0 |
| mohitmishra786/low-level-dev-skills | 100 | MIT |
Migawka bazy z 13.11.2026 · wersja paczki e2ac719f4d25 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100fuzzing-harness
Pisze i uruchamia fuzzery oraz testy właściwości dla kodu czytającego niezaufane bajty, a potem sortuje znalezione awarie i pisze testy regresji. - 100cargo-fuzz
Prowadzi fuzzing kodu Rust w projektach Cargo narzędziem cargo-fuzz z backendem libFuzzer. - 90quality-engineering-api-fuzz-testing
Pisze i uruchamia testy fuzzingowe API, testy odporności na dane wejściowe i kontrole autoryzacji w działającym systemie. - 100coverage-guided-fuzzing
Pomaga dodać fuzzing do projektu w Go, Ruście, C/C++, Pythonie lub Javie: pisze cele dla parserów, dobiera korpusy startowe i szuka awarii na źle sformatowanych danych. - 100cargo-fuzz
Prowadzi fuzzing kodu Rust w projektach Cargo narzędziem cargo-fuzz z backendem libFuzzer. - 100clarity-fuzzing
Testuje kontrakty Clarity metodą fuzzingu z Rendezvous: inwarianty, testy właściwości i odtwarzanie kontrprzykładów.