Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ClusterFuzzLite with go native fuzzing #830

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 4 additions & 0 deletions .clusterfuzzlite/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM gcr.io/oss-fuzz-base/base-builder-go
COPY . $SRC/spicedb
WORKDIR $SRC/spicedb
COPY ./.clusterfuzzlite/build.sh $SRC/
10 changes: 10 additions & 0 deletions .clusterfuzzlite/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash -eu

go install github.com/AdamKorcz/go-118-fuzz-build@latest
go get github.com/AdamKorcz/go-118-fuzz-build/utils

# Workaround https://github.com/AdamKorcz/go-118-fuzz-build/issues/2
mv $SRC/spicedb/pkg/schemadsl/parser/parser_test.go $SRC/spicedb/pkg/schemadsl/parser/parser_test_fuzz.go

compile_native_go_fuzzer github.com/authzed/spicedb/pkg/schemadsl/parser FuzzParser FuzzParser

2 changes: 2 additions & 0 deletions .clusterfuzzlite/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
language: "go"
39 changes: 39 additions & 0 deletions .github/workflows/fuzzing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: "ClusterFuzzLite PR fuzzing"
on:
push:
branches:
- "!dependabot/*"
- "main"
pull_request:
branches: ["*"]
permissions: "read-all"
jobs:
fuzz:
runs-on: "ubuntu-latest"
concurrency:
group: "${{ github.workflow }}-${{ matrix.sanitizer }}-${{ github.ref }}"
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
sanitizer:
- "address"
- "undefined"
- "memory"
steps:
- name: "Build Fuzzers (${{ matrix.sanitizer }})"
id: "build"
uses: "google/clusterfuzzlite/actions/build_fuzzers@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@v1"
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
fuzz-seconds: 30
mode: "code-change"
sanitizer: "${{ matrix.sanitizer }}"
6 changes: 6 additions & 0 deletions pkg/schemadsl/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,9 @@ func getParseTree(currentNode *testNode, indentation int) string {

return parseTree
}

func FuzzParser(f *testing.F) {
f.Fuzz(func(t *testing.T, path, in string) {
_ = Parse(createAstNode, input.Source(path), in)
})
}