test(graphrag): add Drain miner fuzz target (Scorecard Fuzzing)#115
Merged
Conversation
Add FuzzDrainMatch, a Go native fuzz test over the Drain log-template miner's Match() — the ingestion hot path every untrusted log body flows through (LogsServer.Export -> LogCallback -> Drain.Match). It asserts Match never panics on malformed input and holds two invariants: empty or whitespace-only tokenization yields a nil template, and any non-nil result is well-formed (non-empty tokens, ID == templateID(tokens)). It also checks Preprocess+tokenize determinism. Seeds cover empty, whitespace, IPs/UUIDs/timestamps/emails/hex pointers, NUL + high-byte binary, multibyte UTF-8, and an over-depth token run. Satisfies OpenSSF Scorecard's Fuzzing check (detects a native Go fuzz function). Verified: go build/vet/test green (101 tests), and go test -fuzz=FuzzDrainMatch -fuzztime=10s found no crashers. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LDQVJrixs2nJoea67a8pEG
|
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.



What
Adds
FuzzDrainMatch, a Go native fuzz test over the Drain log-template miner'sMatch()(internal/graphrag/drain_fuzz_test.go).Match()is the ingestion hot path every untrusted log body flows through (LogsServer.Export → LogCallback → Drain.Match), so it's the right surface to fuzz. The test assertsMatchnever panics on malformed input and holds two invariants:niltemplate;ID == templateID(tokens)).It also checks that
Preprocess+tokenizeare deterministic. Seeds cover empty, whitespace, IPs/UUIDs/timestamps/emails/hex pointers, NUL + high-byte binary, multibyte UTF-8, and an over-depth token run.Why
OpenSSF Scorecard's Fuzzing check currently scores 0 — it detects no native Go fuzz function. One
FuzzXxx(*testing.F)flips it. This is the highest-value parser on the untrusted-input path that wasn't already fuzzed.Verification
go build ./...— successgo vet ./internal/graphrag/— cleango test ./internal/graphrag/— 101 pass (fuzz seed corpus runs as unit tests)go test -fuzz=FuzzDrainMatch -fuzztime=10s— no crashers🤖 Generated with Claude Code