Skip to content

Add fuzz tests to parsers and secret redaction - #353

Merged
kke merged 6 commits into
mainfrom
fuzz-tests-parsers
Jun 1, 2026
Merged

kke merged 6 commits into
mainfrom
fuzz-tests-parsers

Conversation

@kke

@kke kke commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

It already found two panic-inducing bugs which are fixed here.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and redact.
  • Fix a panic in sshconfig line tokenization when a key has no value after trimming separators/spaces.
  • Adjust redact.StringRedacter to 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.

Comment thread Makefile Resolved
Comment thread redact/redact.go Resolved
@kke
kke requested a review from Copilot May 27, 2026 07:27
@kke
kke force-pushed the fuzz-tests-parsers branch from 205fd40 to 7bd3102 Compare May 27, 2026 07:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Comment thread Makefile Resolved
Comment thread redact/redact.go Resolved
Comment thread sshconfig/tree.go Resolved
Comment thread redact/redact.go Resolved
@kke
kke force-pushed the fuzz-tests-parsers branch from 7bd3102 to db1e836 Compare May 27, 2026 07:48
@kke
kke requested a review from Copilot May 27, 2026 07:48
@kke
kke marked this pull request as ready for review May 27, 2026 07:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Comment thread sshconfig/fuzz_test.go Resolved
Comment thread Makefile Resolved
@kke
kke force-pushed the fuzz-tests-parsers branch from db1e836 to 76b3d35 Compare May 27, 2026 10:26
@kke
kke requested a review from Copilot May 27, 2026 10:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Comment thread Makefile Resolved
Comment thread redact/fuzz_test.go Resolved
Comment thread redact/redact.go Resolved
@kke
kke force-pushed the fuzz-tests-parsers branch from bdd6e94 to b148f3b Compare May 27, 2026 11:04
@kke
kke requested a review from Copilot May 27, 2026 11:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Comment thread sshconfig/tree_test.go Resolved
@kke
kke force-pushed the fuzz-tests-parsers branch from 0a90a40 to 1596402 Compare May 28, 2026 11:26
@kke
kke requested a review from Copilot May 28, 2026 11:26
@kke
kke force-pushed the fuzz-tests-parsers branch from 1596402 to 6bf0ed2 Compare May 28, 2026 11:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Comment thread Makefile Resolved
kke added 3 commits May 28, 2026 14:57
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>
@kke
kke force-pushed the fuzz-tests-parsers branch from 0d328d9 to 5d85361 Compare May 28, 2026 11:57
@kke
kke requested a review from Copilot May 28, 2026 11:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Comment thread sshconfig/fuzz_test.go Resolved
Comment thread sshconfig/fuzz_test.go Resolved
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Comment thread redact/redact.go Resolved
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Comment thread sshconfig/tree_test.go Resolved
Comment thread redact/redact.go Resolved
Comment thread redact/redact.go Resolved
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.

@kke
kke merged commit ee2d568 into main Jun 1, 2026
13 of 16 checks passed
@kke
kke deleted the fuzz-tests-parsers branch June 1, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants