sequence

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package sequence builds and executes dependency-aware request sequences for stateful fuzzing. It uses the dependency graph to determine valid execution orders (producers before consumers), performs weighted random walks, and applies mutations such as stale-value reuse and step repetition.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder constructs dependency-aware sequences.

func NewBuilder

func NewBuilder(ops []*openapi.Operation, g *graph.Graph, rng *rand.Rand) *Builder

NewBuilder creates a sequence builder.

func (*Builder) Build

func (b *Builder) Build(maxSteps int) Sequence

Build generates a single sequence using a dependency-guided weighted random walk. The sequence respects topological order: producers are executed before their consumers. The length is bounded by maxSteps.

func (*Builder) BuildN

func (b *Builder) BuildN(n, maxSteps int) []Sequence

BuildN generates n independent sequences.

func (*Builder) SetStaleRate

func (b *Builder) SetStaleRate(rate float64)

SetStaleRate sets the probability (0-1) of a consumer step using stale values.

type Executor

type Executor struct {
	BaseURL  string
	Client   *execute.Executor
	Gen      *generate.Generator
	Graph    *graph.Graph
	Ops      map[string]*openapi.Operation
	StateRNG *rand.Rand // separate RNG for state store value selection
}

Executor executes sequences against a target, maintaining state across steps.

func NewExecutor

func NewExecutor(baseURL string, client *execute.Executor, gen *generate.Generator, g *graph.Graph, ops []*openapi.Operation) *Executor

NewExecutor creates a sequence executor.

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, seq Sequence, store *state.Store) *Result

Execute runs a single sequence, maintaining a state store across steps.

func (*Executor) ExecuteAll

func (e *Executor) ExecuteAll(ctx context.Context, seqs []Sequence) []*Result

ExecuteAll runs multiple sequences, each with a fresh state store.

type Failure

type Failure struct {
	StepIndex    int              `json:"step_index"`
	OperationKey string           `json:"operation"`
	Method       string           `json:"method"`
	Path         string           `json:"path"`
	StatusCode   int              `json:"status_code,omitempty"`
	Err          string           `json:"error,omitempty"`
	Findings     []oracle.Finding `json:"findings,omitempty"`
	Params       map[string]any   `json:"params,omitempty"`
	// Sequence is the full sequence that led to this failure (for repro).
	Sequence []Step `json:"sequence"`
}

Failure is a sequence-level failure: an operation within a sequence that exposed a problem, with full sequence context for reproduction.

type Result

type Result struct {
	Sequence Sequence           `json:"sequence"`
	Outcomes []*execute.Outcome `json:"outcomes"`
	Failures []Failure          `json:"failures"`
	Duration time.Duration      `json:"duration"`
}

Result holds the outcome of executing one sequence.

type Sequence

type Sequence struct {
	Steps []Step `json:"steps"`
}

Sequence is an ordered list of operations to execute.

type Step

type Step struct {
	OperationKey string `json:"operation"`
	Method       string `json:"method"`
	Path         string `json:"path"`
	// UseStale indicates that this step should deliberately use deleted/stale
	// values from the state store (for "use after delete" testing).
	UseStale bool `json:"use_stale,omitempty"`
}

Step is a single operation in a request sequence.

Jump to

Keyboard shortcuts

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