randparam

package
v0.0.0-...-ae0bca9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package randparam allows a []byte to be used as a source of random parameter values.

The primary use case is to allow infosecual/go-fuzz-fill-utils to automatically generate fuzzing functions for rich signatures such as:

regexp.MatchReader(pattern string, r io.RuneReader)

randparam fills in common top-level interfaces such as io.Reader, io.Writer, io.ReadWriter, and so on. See SupportedInterfaces for current list.

This package predates builtin cmd/go fuzzing support, and originally was targeted at use by infosecual/fzgo, which was a working prototype of an earlier "first class fuzzing in cmd/go" proposal, (There is still some baggage left over from that earlier world).

Index

Constants

This section is empty.

Variables

View Source
var SupportedInterfaces = map[string]bool{
	"io.Writer":       true,
	"io.Reader":       true,
	"io.ReaderAt":     true,
	"io.WriterTo":     true,
	"io.Seeker":       true,
	"io.ByteScanner":  true,
	"io.RuneScanner":  true,
	"io.ReadSeeker":   true,
	"io.ByteReader":   true,
	"io.RuneReader":   true,
	"io.ByteWriter":   true,
	"io.ReadWriter":   true,
	"io.ReaderFrom":   true,
	"io.StringWriter": true,
	"io.Closer":       true,
	"io.ReadCloser":   true,
	"context.Context": true,
}

SupportedInterfaces enumerates interfaces that can be filled by Fill(&obj).

Functions

This section is empty.

Types

type Fuzzer

type Fuzzer struct {
	// contains filtered or unexported fields
}

Fuzzer generates random values for public members. It allows wiring together cmd/go fuzzing or dvyukov/go-fuzz (for randomness, instrumentation, managing corpus, etc.) with the ability to fill in common interfaces, as well as string, []byte, and number values.

func NewFuzzer

func NewFuzzer(data []byte) *Fuzzer

NewFuzzer returns a *Fuzzer, initialized with the []byte as an input stream for drawing values via rand.Rand.

func (*Fuzzer) Data

func (f *Fuzzer) Data() []byte

Data returns a []byte covering the remaining bytes from the original input []byte. Any bytes that are considered consumed should be indicated via Drain.

func (*Fuzzer) Drain

func (f *Fuzzer) Drain(n int)

Drain removes the next n bytes from the input []byte. If n is greater than Remaining, it drains all remaining bytes.

func (*Fuzzer) Fill

func (f *Fuzzer) Fill(obj interface{})

func (*Fuzzer) Fill2

func (f *Fuzzer) Fill2(obj interface{})

func (*Fuzzer) Remaining

func (f *Fuzzer) Remaining() int

Remaining reports how many bytes remain in our original input []byte.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL