feat: add fuzzing example and documentation - #469
Open
Pastalikek65 wants to merge 1 commit into
Open
Conversation
Provides a ready-to-run native Go fuzz target for participle parsers, demonstrating how any grammar can be fuzzed for panics and hangs, plus a Fuzzing section in the README and a seed corpus that also runs in CI. Partially addresses alecthomas#204.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Partially addresses #204
Grammar-driven generation (
parser.Fuzz(&ast)producing random valid strings) would be a larger project — it needs a regex-to-string generator in the lexer to invert captures. This PR instead delivers the immediately useful half of the request: an official, ready-to-run native Go fuzz target for participle parsers.Changes:
fuzz_test.go:FuzzParse— a concrete example target that exercises a grammar with arbitrary input (panic/hang detection), with a seed corpus that also runs in CI as a regular testREADME.md: new "Fuzzing" section explaining the pattern and usage (go test -fuzz=FuzzParse -fuzztime 30s ./...)If grammar-driven generation is still desired, it would fit well as a separate issue with a design for a
lexer.Pattern→ string generator.