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

fuzzing: Add ClusterfuzzLite #448

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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/
WORKDIR umoci
COPY .clusterfuzzlite/build.sh $SRC/
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
go mod tidy && go mod vendor
go get github.com/AdaLogics/go-fuzz-headers@latest
go mod vendor

compile_go_fuzzer github.com/opencontainers/umoci/oci/casext Fuzz casext_fuzz
compile_go_fuzzer github.com/opencontainers/umoci/oci/layer FuzzUnpack fuzz_unpack
compile_go_fuzzer github.com/opencontainers/umoci/oci/layer FuzzGenerateLayer fuzz_generate_layer
compile_go_fuzzer github.com/opencontainers/umoci/mutate FuzzMutate fuzz_mutate
compile_go_fuzzer github.com/opencontainers/umoci/pkg/hardening Fuzz fuzz_hardening


1 change: 1 addition & 0 deletions .clusterfuzzlite/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
language: go
29 changes: 29 additions & 0 deletions .github/workflows/cflite_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: ClusterFuzzLite PR fuzzing
on:
workflow_dispatch:
pull_request:
paths:
- '**'
permissions: read-all
jobs:
PR:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sanitizer: [address]
steps:
- name: Build Fuzzers (${{ matrix.sanitizer }})
id: build
uses: google/clusterfuzzlite/actions/build_fuzzers@v1
with:
sanitizer: ${{ matrix.sanitizer }}
language: go
- name: Run Fuzzers (${{ matrix.sanitizer }})
id: run
uses: google/clusterfuzzlite/actions/run_fuzzers@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fuzz-seconds: 400
mode: 'code-change'
sanitizer: ${{ matrix.sanitizer }}
12 changes: 9 additions & 3 deletions mutate/mutate_fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,22 @@ func FuzzMutate(data []byte) int {
}

// This isn't a valid image, but whatever.
fuzzedString, err := c.GetString()
fuzzedBytes, err := c.GetBytes()
if err != nil {
return -1
}
buffer := bytes.NewBufferString(fuzzedString)
buffer := bytes.NewReader(fuzzedBytes)

m := make(map[string]string)
err = c.FuzzMap(&m)
if err != nil {
return 0
}

// Add a new layer.
_, err = mutator.Add(context.Background(), ispec.MediaTypeImageLayer, buffer, &ispec.History{
Comment: "new layer",
}, GzipCompressor)
}, GzipCompressor, m)
if err != nil {
return 0
}
Expand Down
2 changes: 0 additions & 2 deletions oci/layer/layer_fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,7 @@ func FuzzUnpack(data []byte) int {
Rootless: os.Geteuid() != 0,
}}

called := false
unpackOptions.AfterLayerUnpack = func(m ispec.Manifest, d ispec.Descriptor) error {
called = true
return nil
}

Expand Down