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
12 changes: 12 additions & 0 deletions projects/goipp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Fuzzing Harness for goipp

This directory contains fuzzers for the [`goipp`](https://github.com/OpenPrinting/goipp) project.

## Fuzzer

- `fuzz_decode_bytes.go`: Fuzzes the `DecodeBytes` function in `message.go`.
- `fuzz_decode_bytes_ex.go`: Fuzzes the `DecodeBytesEx` function in `message.go`.

### TODO:

- after successfully building and running the harnesses using oss-fuzz locally, update readme with instructions for the same
20 changes: 20 additions & 0 deletions projects/goipp/fuzzer/fuzz_decode_bytes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Fuzz target for goipp's `DecodeBytes` function.
*/


package fuzzer

import (
"testing"
"github.com/OpenPrinting/goipp"
)

func FuzzDecodeBytes(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
var m goipp.Message
if err := m.DecodeBytes(data); err != nil {
t.Skip()
}
})
}
26 changes: 26 additions & 0 deletions projects/goipp/fuzzer/fuzz_decode_bytes_ex.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Fuzz target for goipp's `DecodeBytesEx` function.
*/


package fuzzer

import (
"testing"
"github.com/OpenPrinting/goipp"
)

func FuzzDecodeBytesEx(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte, enableWorkarounds bool) {
var m goipp.Message
opt := goipp.DecoderOptions{EnableWorkarounds: enableWorkarounds}
if err := m.DecodeBytesEx(data, opt); err != nil {
t.Skip()
}

// Test message properties
if !m.Equal(m) {
t.Error("Message should be equal to itself")
}
})
}
26 changes: 26 additions & 0 deletions projects/goipp/oss_fuzz_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash -eu

mkdir -p $SRC/goipp/fuzzer
cp $SRC/fuzzing/projects/goipp/fuzzer/fuzz_decode_bytes.go $SRC/goipp/fuzzer/
cp $SRC/fuzzing/projects/goipp/fuzzer/fuzz_decode_bytes_ex.go $SRC/goipp/fuzzer/

# seed corpus for FuzzDecodeBytes
mkdir -p $WORK/fuzz_decode_bytes_corpus
cp $SRC/fuzzing/projects/goipp/seeds/fuzz_decode_bytes_seed_corpus/* $WORK/fuzz_decode_bytes_corpus/
cd $WORK
zip -r $OUT/fuzz_decode_bytes_seed_corpus.zip fuzz_decode_bytes_corpus/

# seed corpus for FuzzDecodeBytesEx
mkdir -p $WORK/fuzz_decode_bytes_ex_corpus
cp $SRC/fuzzing/projects/goipp/seeds/fuzz_decode_bytes_ex_seed_corpus/* $WORK/fuzz_decode_bytes_ex_corpus/
zip -r $OUT/fuzz_decode_bytes_ex_seed_corpus.zip fuzz_decode_bytes_ex_corpus/


# build dependencies and fiuzzers
cd $SRC/goipp
go mod tidy
go install github.com/AdamKorcz/go-118-fuzz-build@latest
go get github.com/AdamKorcz/go-118-fuzz-build/testing

compile_native_go_fuzzer github.com/OpenPrinting/goipp/fuzzer FuzzDecodeBytes fuzz_decode_bytes
compile_native_go_fuzzer github.com/OpenPrinting/goipp/fuzzer FuzzDecodeBytesEx fuzz_decode_bytes_ex
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.