Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .clusterfuzzlite/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ClusterFuzzLite build container: compiles the repo's native Go fuzz targets
# with the OSS-Fuzz toolchain. See https://google.github.io/clusterfuzzlite/
FROM gcr.io/oss-fuzz-base/base-builder-go:v1
COPY . $SRC/structalign
COPY .clusterfuzzlite/build.sh $SRC/build.sh
WORKDIR $SRC/structalign
12 changes: 12 additions & 0 deletions .clusterfuzzlite/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash -eu
# Build the repo's native Go fuzz targets (go test -fuzz style) as libFuzzer
# binaries via the OSS-Fuzz toolchain's compile_native_go_fuzzer helper.
# Usage: compile_native_go_fuzzer <import path> <FuzzFunc> <output binary>

# The rewrite shim used by compile_native_go_fuzzer; added to go.mod only
# inside the build container, never in the repo.
go get github.com/AdamKorcz/go-118-fuzz-build/testing

compile_native_go_fuzzer github.com/peczenyj/structalign/internal/match FuzzMatchAny fuzz_match_any
compile_native_go_fuzzer github.com/peczenyj/structalign/internal/match FuzzSplitCSV fuzz_split_csv
compile_native_go_fuzzer github.com/peczenyj/structalign/internal/ui FuzzTruncPad fuzz_trunc_pad
1 change: 1 addition & 0 deletions .clusterfuzzlite/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
language: go
42 changes: 42 additions & 0 deletions .github/workflows/cflite_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: ClusterFuzzLite PR fuzzing

on:
pull_request:
paths:
- "**.go"
- "go.mod"
- "go.sum"
- ".clusterfuzzlite/**"
- ".github/workflows/cflite_pr.yml"

permissions:
contents: read

jobs:
fuzz:
name: fuzz (${{ matrix.sanitizer }})
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ matrix.sanitizer }}-${{ github.ref }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
sanitizer: [address]
steps:
- name: Build fuzzers (${{ matrix.sanitizer }})
id: build
uses: google/clusterfuzzlite/actions/build_fuzzers@884713a6c30a92e5e8544c39945cd7cb630abcd1 # v1
with:
language: go
github-token: ${{ secrets.GITHUB_TOKEN }}
sanitizer: ${{ matrix.sanitizer }}

- name: Run fuzzers (${{ matrix.sanitizer }})
id: run
uses: google/clusterfuzzlite/actions/run_fuzzers@884713a6c30a92e5e8544c39945cd7cb630abcd1 # v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fuzz-seconds: 300
mode: code-change
sanitizer: ${{ matrix.sanitizer }}
15 changes: 7 additions & 8 deletions internal/match/fuzz_test.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package match_test
// Package-internal (not match_test) so ClusterFuzzLite's
// compile_native_go_fuzzer can rewrite this file: an external test package
// would clash with the non-test package during the go-118-fuzz-build rewrite.
package match

import (
"testing"

"github.com/peczenyj/structalign/internal/match"
)
import "testing"

func FuzzMatchAny(f *testing.F) {
f.Add("Mixed", "Mixed")
f.Add("*", "Mixed")
f.Add("", "Mixed")

f.Fuzz(func(t *testing.T, pattern string, name string) {
_ = match.MatchAny([]string{pattern}, name)
_ = MatchAny([]string{pattern}, name)
})
}

Expand All @@ -22,6 +21,6 @@ func FuzzSplitCSV(f *testing.F) {
f.Add("")

f.Fuzz(func(t *testing.T, s string) {
_ = match.SplitCSV(s)
_ = SplitCSV(s)
})
}
Loading