fuzzer

package
v0.0.0-...-1dd1f65 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package fuzzer contains a test-plan batch fuzzer. It relies on the existence of a single-file fuzzer such as c4f-fuzz.

Index

Constants

View Source
const DefaultSubjectFuzzes = 10

DefaultSubjectFuzzes is the default number of fuzz cycles to run per subject.

Variables

View Source
var (
	// ErrDriverNil occurs when the fuzzer tries to use the nil pointer as its single-fuzz driver.
	ErrDriverNil = errors.New("driver nil")
)
View Source
var ErrNotSubjectCycleName = errors.New("not a valid subject-cycle name")

ErrNotSubjectCycleName occurs when we try to ParseSubjectCycle on a string that isn't of the right format.

Functions

This section is empty.

Types

type AggregateDriver

type AggregateDriver struct {
	// Single is a single-job fuzzer.
	Single SingleFuzzer
	// Stat is a stat dumper.
	Stat litmus.StatDumper
}

AggregateDriver is a driver that delegates the interface responsibilities to separate implementations.

func (AggregateDriver) DumpStats

func (a AggregateDriver) DumpStats(ctx context.Context, s *litmus.Statset, path string) error

DumpStats delegates to the stat dumper.

func (AggregateDriver) Fuzz

func (a AggregateDriver) Fuzz(ctx context.Context, job fuzzer.Job) error

Fuzz delegates to the fuzzer.

type Driver

type Driver interface {
	SingleFuzzer
	litmus.StatDumper
}

Driver groups the interfaces used to 'drive' parts of the fuzzer.

type Fuzzer

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

Fuzzer holds the state required for the fuzzing stage of the tester.

func New

func New(d Driver, ps SubjectPather, o ...Option) (*Fuzzer, error)

New constructs a fuzzer with the config c and plan p.

func (*Fuzzer) Close

func (*Fuzzer) Close() error

Close does nothing.

func (*Fuzzer) Run

func (f *Fuzzer) Run(ctx context.Context, p *plan.Plan) (*plan.Plan, error)

Run runs the fuzzer with context ctx and plan p.

func (*Fuzzer) Stage

func (*Fuzzer) Stage() stage.Stage

Stage gets the appropriate stage information for the fuzzer.

type Instance

type Instance struct {
	// Normalise contains the subject for which this Instance is responsible.
	Subject subject.Named

	// Driver is the low-level fuzzer driver set.
	Driver Driver

	// SubjectCycles is the number of times each subject should be fuzzed.
	SubjectCycles int

	// Machine is the machine, if any, being targeted by the fuzzer.
	// Knowledge of the machine can be used to shape things like thread counts.
	Machine *machine.Machine

	// Config is the specific configuration, if any, for the fuzzer.
	Config *fuzzer.Config

	// Pathset points to the pathset to use to work out where to store fuzz output.
	Pathset SubjectPather

	// Rng is the random number generator to use for fuzz seeds.
	Rng *rand.Rand

	// ResCh is the channel onto which each fuzzed subject should be sent.
	ResCh chan<- builder.Request
}

Instance contains state for a single fuzzer instance.

func (*Instance) Fuzz

func (j *Instance) Fuzz(ctx context.Context) error

Fuzz performs a single fuzzing instance.

type NopFuzzer

type NopFuzzer struct{}

NopFuzzer is a single-fuzzer that does nothing.

func (NopFuzzer) Fuzz

Fuzz does nothing, but pretends to fuzz a file.

type Option

type Option func(*Fuzzer) error

Option is the type of options passed to the fuzzer constructor.

func ObserveWith

func ObserveWith(obs ...builder.Observer) Option

ObserveWith adds each observer given to the invoker's observer pools.

func Options

func Options(ops ...Option) Option

Options bundles the separate options ops into a single option.

func OverrideQuantities

func OverrideQuantities(qs quantity.FuzzSet) Option

OverrideQuantities overrides the fuzzer's quantities with qs.

func UseConfig

func UseConfig(cfg *fuzzer.Config) Option

UseConfig populates settings for the fuzzer from the configuration cfg.

type Pathset

type Pathset struct {
	// DirLitmus is the directory to which litmus tests will be written.
	DirLitmus string

	// DirTrace is the directory to which traces will be written.
	DirTrace string
}

Pathset contains the pre-computed paths used by a run of the fuzzer.

func NewPathset

func NewPathset(root string) *Pathset

NewPathset constructs a new pathset from the directory root.

func (*Pathset) Prepare

func (p *Pathset) Prepare() error

Prepare prepares this pathset by making its directories.

func (*Pathset) SubjectLitmus

func (p *Pathset) SubjectLitmus(c SubjectCycle) string

SubjectLitmus gets the litmus filepath for the subject/cycle pair c.

func (*Pathset) SubjectTrace

func (p *Pathset) SubjectTrace(c SubjectCycle) string

SubjectTrace gets the litmus filepath for the subject/cycle pair c.

type SingleFuzzer

type SingleFuzzer interface {
	// Fuzz carries out the given fuzzing job.
	Fuzz(context.Context, fuzzer.Job) error
}

SingleFuzzer represents types that can commune with a C litmus test fuzzer.

type SubjectCycle

type SubjectCycle struct {
	// Name is the name of the subject.
	Name string
	// Cycle is the current fuzz cycle (zero based).
	Cycle int
}

SubjectCycle describes the unique name of a particular instance of the batch fuzzer.

func ParseSubjectCycle

func ParseSubjectCycle(s string) (SubjectCycle, error)

ParseSubjectCycle tries to back-form a SubjectCycle from s.

func (SubjectCycle) String

func (f SubjectCycle) String() string

String is a filepath-suitable string representation of a fuzz name.

type SubjectPather

type SubjectPather interface {
	// Prepare sets up the directories ready to serve through SubjectPaths.
	Prepare() error
	// SubjectLitmus gets the litmus filepath for the subject/cycle pair sc.
	SubjectLitmus(sc SubjectCycle) string
	// SubjectTrace gets the trace filepath for the subject/cycle pair sc.
	SubjectTrace(sc SubjectCycle) string
}

SubjectPather is the interface of things that serve file-paths for subject outputs during a fuzz batch.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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