fuzzing
O que ela faz
Esta skill mostra ao seu agente como escrever e registrar testes de fuzzing usando o framework FuzzTest. Ela é indicada para desenvolvedores que querem testar código que lê entradas não confiáveis.
Quando usar
- ✓Quando você pede à sua IA para adicionar um teste de fuzzing a um arquivo de teste unitário em C++.
- ✓Quando você quer verificar um parser ou um manipulador de dados em busca de falhas com entradas aleatórias.
- ✓Quando você precisa configurar uma pasta de saída de build que habilite o fuzzing.
Link da skill
https://github.com/chromium/chromium/blob/main/agents/skills/fuzzing/SKILL.mdCopie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.
Como usar
O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.
Mensagem pronta para colar
Para Claude Code, Codex ou Cursor: rode na pasta do projeto e a skill fica instalada.
Baixe o SKILL.md e coloque na pasta de skills do seu agente.
Exemplo do que pedir para a IA
“Você pode escrever um teste de fuzzing para o meu parser de URL em C++ para verificar falhas com entradas aleatórias?”
5 skills novas por semana. 1 minuto de leitura.
Como funciona
A skill orienta a IA a escrever uma função de propriedade que verifica alguma regra do código e depois registrá-la com a macro FUZZ_TEST. O fuzzer então testa muitas entradas em busca de falhas.
Conteúdo técnico (SKILL.md original)
Texto original do autor, em inglês, direto do 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",
],
}
Perguntas frequentes
O que é fuzzing?
O fuzzing envia muitas entradas aleatórias ou incomuns para o código para encontrar falhas ou regras quebradas. Ele é bom para encontrar bugs que os testes normais deixam passar.
Preciso ser especialista em C++ para usar isto?
Você precisa de algum conhecimento de C++ para usar bem. A skill ajuda sua IA a escrever o código do teste e as configurações de build.
Esta skill funciona fora do projeto Chromium?
Os exemplos vêm do Chromium, mas o padrão do FuzzTest é um framework geral. Os passos podem ser aplicados a outros projetos C++.
Detalhes
Descrição original do autor
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
Popularidade
- Estrelas no GitHub
- 25 mil
- Posição no ranking
- #10057
- Licença
- BSD-3-Clause
- Atualizada em
- 02/11/2026
Comentários
- …
Mais skills deste repositório
gn-deps-debugging
25 milAjuda seu agente a corrigir erros de build causados por dependências ausentes ou incorretas em arquivos de build GN, sem adicionar dependências amplas e desnecessárias.
java-memory-leaks
25 milAjuda seu agente a encontrar e corrigir vazamentos de memória em Java em apps Android, lendo relatórios de vazamento do LeakCanary.
jni-type-conversion
25 milAjuda seu agente a substituir o código manual de conversão de Java para C++ por anotações @JniType mais simples em código Android.
loadline
25 milAjuda seu agente a rodar benchmarks do LoadLine que medem a velocidade de carregamento de páginas web no Android e no Chrome para desktop.
Skills parecidas
test-driven-development
311 milEnsina seu agente a escrever primeiro um teste que falha, ver a falha e depois escrever o menor código que passa, antes de criar qualquer funcionalidade ou correção.
verification-before-completion
311 milEnsina seu agente a rodar verificações reais e ler a saída antes de afirmar que uma tarefa, correção ou build está concluído ou passando.
migrate-to-shoehorn
310 milSubstitui conversões de tipo arriscadas nos seus arquivos de teste pela biblioteca shoehorn, para que os testes usem dados parciais e ainda passem na checagem de tipos.