Skip to content

Add basic fuzzing jig#72

Merged
whymarrh merged 3 commits intomainfrom
basic-fuzz
Apr 25, 2026
Merged

Add basic fuzzing jig#72
whymarrh merged 3 commits intomainfrom
basic-fuzz

Conversation

@whymarrh
Copy link
Copy Markdown
Member

This PR adds a basic fuzzing setup which has already identified some error handling improvements!

The new workflow will run 10s of fuzzing and upload any seed corpus that fails as an artifact.

See also: Tutorial: Getting started with fuzzing, a great intro. I don't expect this to catch much over the long term, but it's free!

Found via fuzz testing:

fuzz: elapsed: 0s, gathering baseline coverage: 0/4 completed
fuzz: elapsed: 0s, gathering baseline coverage: 4/4 completed, now fuzzing with 4 workers
fuzz: elapsed: 1s, execs: 1955 (1385/sec), new interesting: 6 (total: 10)
--- FAIL: FuzzTemplatefile (1.41s)
    --- FAIL: FuzzTemplatefile (0.00s)
        testing.go:1825: panic: not a string
            goroutine 1245 [running]:
            runtime/debug.Stack()
            	/opt/hostedtoolcache/go/1.25.9/x64/src/runtime/debug/stack.go:26 +0x9b
            testing.tRunner.func1()
            	/opt/hostedtoolcache/go/1.25.9/x64/src/testing/testing.go:1825 +0x1d0
            panic({0x9ed640?, 0xb16cb0?})
            	/opt/hostedtoolcache/go/1.25.9/x64/src/runtime/panic.go:783 +0x132
            github.com/zclconf/go-cty/cty.Value.AsString({{{0xb1be40?, 0xebf8e0?}}, {0x0?, 0x0?}})
            	/home/runner/go/pkg/mod/github.com/zclconf/go-cty@v1.18.1/cty/value_ops.go:1458 +0x218
            github.com/TypedSoftware/templatefile.templatefile({0xc0053aebd0, 0x23}, {0xc0053aec30, 0x2d}, {0xc0052c7c50, 0x4})
            	/home/runner/work/templatefile/templatefile/templatefile.go:141 +0x391d
            github.com/TypedSoftware/templatefile.FuzzTemplatefile.func1(0xc005399880, {0xc004decd59, 0x6}, {0xc0052c7c50, 0x4})
            	/home/runner/work/templatefile/templatefile/templatefile_test.go:51 +0x146
            reflect.Value.call({0x9fb9c0?, 0xa99598?, 0x13?}, {0xa6bf86, 0x4}, {0xc0053cf6e0, 0x3, 0x4?})
            	/opt/hostedtoolcache/go/1.25.9/x64/src/reflect/value.go:581 +0xcc6
            reflect.Value.Call({0x9fb9c0?, 0xa99598?, 0xd8a540?}, {0xc0053cf6e0?, 0xa6b300?, 0xd21ae0?})
            	/opt/hostedtoolcache/go/1.25.9/x64/src/reflect/value.go:365 +0xb9
            testing.(*F).Fuzz.func1.1(0xc005399880?)
            	/opt/hostedtoolcache/go/1.25.9/x64/src/testing/fuzz.go:341 +0x32a
            testing.tRunner(0xc005399880, 0xc0053e0090)
            	/opt/hostedtoolcache/go/1.25.9/x64/src/testing/testing.go:1934 +0xea
            created by testing.(*F).Fuzz.func1 in goroutine 21
            	/opt/hostedtoolcache/go/1.25.9/x64/src/testing/fuzz.go:328 +0x637

    Failing input written to testdata/fuzz/FuzzTemplatefile/a3034cdd38718cd7
    To re-run:
    go test -run=FuzzTemplatefile/a3034cdd38718cd7

I've added the seed corpus as well.
@whymarrh whymarrh merged commit 345e9ed into main Apr 25, 2026
10 checks passed
@whymarrh whymarrh deleted the basic-fuzz branch April 25, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant