strategy

package
Version: v0.0.0-...-9f34108 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2018 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List() []string

List returns a list of all registered fuzzing strategy names.

func NewAllPermutations

func NewAllPermutations(root token.Token, r rand.Rand) (chan struct{}, error)

NewAllPermutations implements a fuzzing strategy that generates all possible permutations of a token graph. Every iteration of the strategy generates a new permutation. The generation is deterministic. Since this strategy really produces every possible permutation of a token graph, it is advised to only use the strategy on graphs with few states since the state explosion problem manifests itself quite fast.

func NewAlmostAllPermutations

func NewAlmostAllPermutations(root token.Token, r rand.Rand) (chan struct{}, error)

NewAlmostAllPermutations implements a fuzzing strategy that generates "almost" all possible permutations of a token graph. Every iteration of the strategy generates a new permutation. The generation is deterministic. This strategy does not cover all repititional permutations which can be helpful when less permutations are needed but a almost complete permutation coverage is still needed. For example the definition +2(?(1)?(2)) does not result in 16 permutations but instead it results in only 7.

func NewPermuteOptionals

func NewPermuteOptionals(root token.Token, r rand.Rand) (chan struct{}, error)

NewPermuteOptionals implements a fuzzing strategy that generates permutations of only optional tokens of a token graph. Every iteration of the strategy generates a new permutation. The generation is deterministic. This strategy searches the graph for tokens who implement the OptionalToken interface and permutates over them by deactivating or activating them. The permutations always start from the deactivated states so that minimum data is generated first.

func NewRandom

func NewRandom(root token.Token, r rand.Rand) (chan struct{}, error)

NewRandom implements a fuzzing strategy that generates a random permutation of a token graph. The strategy does exactly one iteration which permutates at random all reachable tokens in the graph. The determinism is dependent on the random generator and is therefore for example deterministic if a seed for the random generator produces always the same outputs.

func Register

func Register(name string, strat Strategy)

Register registers a fuzzing strategy instance function with the given name.

Types

type Error

type Error struct {
	Message string
	Type    ErrorType
}

Error holds a fuzzing strategy error

func (*Error) Error

func (err *Error) Error() string

type ErrorType

type ErrorType int

ErrorType the fuzzing strategy error type

const (
	// ErrEndlessLoopDetected the token graph has a cycle which is not allowed.
	ErrEndlessLoopDetected ErrorType = iota
	// ErrNilRandomGenerator the random generator is nil
	ErrNilRandomGenerator
)

type Strategy

type Strategy func(root token.Token, r rand.Rand) (chan struct{}, error)

Strategy defines a fuzzing strategy. The function starts the first iteration of the fuzzing strategy returning a channel which controls the iteration flow. The channel returns a value if the iteration is complete and waits with calculating the next iteration until a value is put in. The channel is automatically closed when there are no more iterations. The error return argument is not nil if an error occurs during the setup of the fuzzing strategy.

func New

func New(name string) (Strategy, error)

New returns a new fuzzing strategy instance given the registered name of the strategy. The error return argument is not nil, if the name does not exist in the registered fuzzing strategy list.

Jump to

Keyboard shortcuts

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