fuzzer

package module
v0.0.0-...-fd1090a Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: MIT Imports: 9 Imported by: 0

README

IPFS Datastore Fuzzer

The fuzzer provides a go fuzzer interface to Datastore implementations. This can be used for fuzz testing of these implementations.

Usage

First, configure the datastores to fuzz (from this directory):

// either run via `go run`
go run ./cmd/generate github.com/ipfs/go-ds-badger
// or `go generate`
DS_PROVIDERS="github.com/ipfs/go-ds-badger" go generate

Then, build the fuzzing artifact and fuzz:

go-fuzz-build
go-fuzz

If you don't have go-fuzz installed, it can be acquired as:

go get -u github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Threads int

Threads is a measure of concurrency. Note: if Threads > 1, determinism is not guaranteed.

Functions

func AddOpener

func AddOpener(name string, opener func(loc string) ds.Datastore)

AddOpener allows registration of a new driver for fuzzing.

func Fuzz

func Fuzz(data []byte) int

Fuzz is a go-fuzzer compatible input point for replaying data (interpreted as a script of commands) to known ipfs datastore implementations

func FuzzDB

func FuzzDB(driver string, location string, cleanup bool, data []byte) int

FuzzDB fuzzes a given database entry, providing sufficient hooks to be used by CLI commands.

func FuzzStream

func FuzzStream(driver string, location string, cleanup bool, data io.Reader) error

FuzzStream does the same as fuzz but with streaming input

Types

type RunState

type RunState struct {
	Cancel context.CancelFunc
	// contains filtered or unexported fields
}

RunState encapulates the state of a given fuzzing run

func Open

func Open(driver string, location string, cleanup bool) (*RunState, error)

Open instantiates an instance of the database implementation for testing.

func (*RunState) DB

func (r *RunState) DB() ds.Datastore

DB returns the datastore being driven by this instance

func (*RunState) Fuzz

func (r *RunState) Fuzz(data []byte)

Fuzz sends a set of bytes to drive the current open datastore instance.

func (*RunState) FuzzStream

func (r *RunState) FuzzStream(data io.Reader)

FuzzStream sends a set of bytes to drive the current instance from a reader.

func (*RunState) TxnDB

func (r *RunState) TxnDB() ds.TxnDatastore

TxnDB returns the transaciton database if the store under test supports transactions

Directories

Path Synopsis
cmd
generate
This file is invoked by `go generate`
This file is invoked by `go generate`
run

Jump to

Keyboard shortcuts

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