containerd/vendor/github.com/AdaLogics/go-fuzz-headers
Kazuyoshi Kato 040babe003 Vendor dependencies with module graph pruning
The empty-mod hack no longer works with Go 1.18.

This commit fixes #6586.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-03-18 16:49:09 +00:00
..
consumer.go Fuzzing: Add archive fuzzer 2021-07-22 16:39:27 +01:00
LICENSE Fuzzing: Add archive fuzzer 2021-07-22 16:39:27 +01:00
README.md Fuzzing: Add archive fuzzer 2021-07-22 16:39:27 +01:00

go-fuzz-headers

This repository contains various helper functions to be used with go-fuzz.

Goal

The current goal of go-fuzz-headers is: To maintain a series of helper utilities that can be used for golang projects that are integrated into OSS-fuzz and use the go-fuzz engine to fuzz more complicated types than merely strings and data arrays. While go-fuzz-headers can be used when using go-fuzz outside of OSS-fuzz, we do not test such usage and cannot confirm that it is supported.

Status

The project is under development and will be updated regularly.

Fuzzers that use GenerateStruct will not require modifications as more types get supported.

Usage

To make use of the helper functions, a ConsumeFuzzer has to be instantiated:

f := NewConsumer(data)

To split the input data from the fuzzer into a random set of equally large chunks:

err := f.Split(3, 6)

...after which the consumer has the following available attributes:

f.CommandPart = commandPart
f.RestOfArray = restOfArray
f.NumberOfCalls = numberOfCalls

To pass the input data from the fuzzer into a struct:

ts := new(target_struct)
err :=f.GenerateStruct(ts)

or:

ts := target_struct{}
err = f.GenerateStruct(&ts)

GenerateStruct will pass data from the input data to the targeted struct. Currently the following field types are supported:

  1. string
  2. bool
  3. int
  4. []string
  5. byte
  6. []byte
  7. custom structures
  8. map