pump

package
v0.0.0-...-cacfa07 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package pump provides adversarial input generation for regex testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

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

Generator generates adversarial inputs for regex patterns.

func NewGenerator

func NewGenerator(opts *Options) *Generator

NewGenerator creates a new pump pattern generator.

func (*Generator) Generate

func (g *Generator) Generate(re *syntax.Regexp, pattern string) ([]PumpPattern, error)

Generate creates pump patterns for a given regex.

type Options

type Options struct {
	PumpSize       int  // Size of pumped component (default: 10)
	MaxPumpSize    int  // Maximum pump size (default: 100)
	IncludeFailure bool // Include failing suffix (default: true)
}

Options contains configuration for pump pattern generation.

type PumpPattern

type PumpPattern struct {
	BaseString    string // The base pattern to repeat
	PumpComponent string // The component to pump (repeat)
	FailSuffix    string // Suffix that causes failure
	Description   string // Description of why this triggers backtracking
	Sizes         []int  // Suggested pump sizes to test
}

PumpPattern represents an adversarial input pattern.

func (*PumpPattern) GenerateInput

func (p *PumpPattern) GenerateInput(size int) string

GenerateInput generates an actual test input from a pump pattern.

func (*PumpPattern) GenerateSequence

func (p *PumpPattern) GenerateSequence() []string

GenerateSequence generates a sequence of test inputs with increasing sizes.

func (*PumpPattern) String

func (p *PumpPattern) String() string

String returns a string representation of the pump pattern.

Jump to

Keyboard shortcuts

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