Skip to content

Commit

Permalink
adds oss-fuzz CI and a parser test
Browse files Browse the repository at this point in the history
  • Loading branch information
vroldanbet committed Sep 20, 2022
1 parent ca7754e commit 098302e
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/fuzzing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Fuzzing Testing"
on: # yamllint disable-line rule:truthy
push:
branches:
- "!dependabot/*"
- "main"
pull_request:
branches: ["*"]
jobs:
fuzz:
runs-on: "ubuntu-latest"
steps:
- name: "Build Fuzzers"
id: "build"
uses: "google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master"
with:
oss-fuzz-project-name: "spicedb"
language: "go"
dry-run: "true"
- name: "Run Fuzzers"
uses: "google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master"
with:
oss-fuzz-project-name: "spicedb"
language: "go"
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: "actions/setup-go@v3"
with:
go-version: "~1.19.1"
- uses: "actions/checkout@v3"
- run: |
pkgs=$(git grep 'func Fuzz.*testing\.F' | grep -o '.*\/' | sort | uniq)
for pkg in $pkgs
do
go test -fuzz=. ./$pkg -fuzztime=300s
done
- name: "Upload Failure"
uses: "actions/upload-artifact@v3"
if: failure() && steps.build.outcome == 'success'
with:
name: "artifacts"
path: "**/testdata/fuzz/"
13 changes: 13 additions & 0 deletions pkg/schemadsl/parser/fuzz_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package parser

import (
"testing"

"github.com/authzed/spicedb/pkg/schemadsl/input"
)

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

0 comments on commit 098302e

Please sign in to comment.