Skip to content

Commit

Permalink
use ClusterFuzzLite instead
Browse files Browse the repository at this point in the history
Co-authored-by: AdamKorcz <[email protected]>
  • Loading branch information
vroldanbet and AdamKorcz committed Sep 21, 2022
1 parent 78267c9 commit 3dd705d
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 43 deletions.
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

1 change: 1 addition & 0 deletions .clusterfuzzlite/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
language: "go"
54 changes: 24 additions & 30 deletions .github/workflows/fuzzing.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,34 @@
name: "Fuzzing Testing"
on: # yamllint disable-line rule:truthy
push:
branches:
- "!dependabot/*"
- "main"
---
name: "ClusterFuzzLite PR fuzzing"
on:
pull_request:
branches: ["*"]
paths:
- '**'
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"
steps:
- name: "Build Fuzzers"
- name: "Build Fuzzers (${{ matrix.sanitizer }})"
id: "build"
uses: "google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master"
uses: "google/clusterfuzzlite/actions/build_fuzzers@v1"
with:
oss-fuzz-project-name: "spicedb"
language: "go"
dry-run: "true"
- name: "Run Fuzzers"
uses: "google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master"
github-token: "${{ secrets.GITHUB_TOKEN }}"
sanitizer: "${{ matrix.sanitizer }}"
- name: "Run Fuzzers (${{ matrix.sanitizer }})"
id: "run"
uses: "google/clusterfuzzlite/actions/run_fuzzers@v1"
with:
oss-fuzz-project-name: "spicedb"
language: "go"
github-token: "${{ secrets.GITHUB_TOKEN }}"
fuzz-seconds: 300
dry-run: "true"
- name: "Upload Crash"
uses: "actions/upload-artifact@v3"
if: failure() && steps.build.outcome == 'success'
with:
name: "artifacts"
path: "./out/artifacts"

go-test-fuzz:
name : "go test -fuzz"
runs-on: "ubuntu-latest"
steps:
- uses: "jidicula/[email protected]"
with:
fuzz-time: 30s
mode: "code-change"
sanitizer: "${{ matrix.sanitizer }}"
13 changes: 0 additions & 13 deletions pkg/schemadsl/parser/fuzz_test.go

This file was deleted.

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)
})
}

0 comments on commit 3dd705d

Please sign in to comment.