Repository navigation
Add fuzz tests to parsers and secret redaction - #353
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds Go fuzz tests across several parsing / string-processing packages and incorporates fixes discovered by fuzzing (preventing a panic in the ssh_config tokenizer and hardening secret redaction against pathological replace patterns).
Changes:
- Add fuzz tests for
sshconfig,kv,powershell, andredact. - Fix a panic in
sshconfigline tokenization when a key has no value after trimming separators/spaces. - Adjust
redact.StringRedacterto avoid infinite-loop scenarios and to fully eliminate re-formed match strings.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
sshconfig/tree.go |
Prevents panic in tokenizeRow by handling “missing value” after trimming. |
sshconfig/fuzz_test.go |
Adds fuzz coverage for sshconfig.NewParser / Apply, stripping Include directives. |
sshconfig/testdata/fuzz/FuzzNewParser/e2b8af39f88d630c |
Adds minimized fuzz corpus reproducer for FuzzNewParser. |
redact/redact.go |
Hardens string redaction against infinite loops and residual matches. |
redact/fuzz_test.go |
Adds fuzz coverage for StringRedacter.Redact (single + multiple matches). |
redact/testdata/fuzz/FuzzStringRedacterRedact/4cacab9f1ab7b541 |
Adds minimized fuzz corpus reproducer for FuzzStringRedacterRedact. |
redact/testdata/fuzz/FuzzStringRedacterRedact/11502329c1957bf1 |
Adds additional minimized fuzz corpus reproducer for FuzzStringRedacterRedact. |
redact/testdata/fuzz/FuzzStringRedacterMultipleMatches/90d183ef785e9760 |
Adds minimized fuzz corpus reproducer for FuzzStringRedacterMultipleMatches. |
powershell/fuzz_test.go |
Adds fuzz tests for command building and quoting helpers. |
kv/fuzz_test.go |
Adds fuzz tests for SplitRune and Decoder.Decode. |
Makefile |
Adds a make fuzz target to run all fuzz tests for a short time budget. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fuzz targets cover the main parser and transformer surfaces: - kv: FuzzSplitRune (key=value splitter), FuzzDecode (full decoder into map[string]string); both verify no panic on arbitrary input - powershell: FuzzCmd (non-empty output invariant), FuzzEncodeCmd (valid base64 output), FuzzSingleQuote (single-quote wrapping), FuzzDoubleQuote (double-quote wrapping) - redact: FuzzStringRedacterRedact (single-match post-condition: result must not contain match when mask does not itself contain match); FuzzStringRedacterMultipleMatches (no-panic only — sequential ReplaceAll with overlapping patterns can produce residual matches, documented) - sshconfig: FuzzNewParser (no panic on arbitrary config text; Include directives stripped to prevent filesystem access during fuzzing) All fuzz functions include UTF-8 validation guards and seed corpora that cover empty input, special characters, quoted values, and syntax errors. Discovered corpus entries are retained in testdata/fuzz/ as regression tests. Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
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.
It already found two panic-inducing bugs which are fixed here.