protocoltest

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: BSD-3-Clause, GPL-3.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const GenerationVersion = "protocoltest-v2"

Variables

View Source
var ErrBudgetExceeded = errors.New("harness budget exceeded")

ErrBudgetExceeded denotes a harness limit, never a target rejection or crash.

Functions

func GrammarSeed

func GrammarSeed(g Grammar) ([]byte, error)

GrammarSeed constructs one fully specified, non-overlapping fixed-width layout. Nested/TLV expansion and unspecified bytes are deliberately refused.

func MutateFrame

func MutateFrame(frame []byte, framing Framing, mutation Mutation) ([]byte, error)

func ReadDirectionalInput

func ReadDirectionalInput(path string) ([]byte, error)

ReadDirectionalInput enforces adjacent Netcap loss metadata when reading its artifacts.

Types

type AccessCase

type AccessCase struct {
	Metadata     ExperimentMetadata `json:"metadata"`
	ResponseStep int                `json:"responseStep"`
	Role         string             `json:"role"`
	State        string             `json:"state"`
	Resource     string             `json:"resource"`
	Message      string             `json:"message"`
	Allowed      bool               `json:"allowed"`
	Marker       []byte             `json:"marker"`
	Exchange     Exchange           `json:"exchange"`
}

type AccessObservation

type AccessObservation struct {
	Reset          ResetEvidence `json:"reset"`
	Case           AccessCase    `json:"case"`
	Result         Result        `json:"result"`
	MarkerReturned bool          `json:"markerReturned"`
	Status         string        `json:"status"`
}

func RunAccess

func RunAccess(ctx context.Context, cases []AccessCase) ([]AccessObservation, error)

RunAccess opens a fresh session per case. Absence is meaningful only after the case's response assertions matched; failures remain inconclusive.

type BoundaryCase

type BoundaryCase struct {
	Metadata     ExperimentMetadata `json:"metadata"`
	Name         string             `json:"name"`
	Control      Exchange           `json:"control"`
	Probe        Exchange           `json:"probe"`
	ResponseStep int                `json:"responseStep"`
	Accepted     []byte             `json:"accepted"`
	Rejected     []byte             `json:"rejected"`
	Verification *Exchange          `json:"verification,omitempty"`
}

BoundaryCase uses exact application replies as the target oracle. Verification is a readback after the probe without resetting its effects first.

type BoundaryResult

type BoundaryResult struct {
	Version             int           `json:"version"`
	GenerationVersion   string        `json:"generationVersion"`
	Case                BoundaryCase  `json:"case"`
	ConfigurationSHA256 string        `json:"configurationSHA256"`
	Outcome             string        `json:"outcome"`
	Before              Result        `json:"before"`
	BeforeReset         ResetEvidence `json:"beforeReset"`
	Probe               Result        `json:"probe"`
	ProbeReset          ResetEvidence `json:"probeReset"`
	Verification        *Result       `json:"verification,omitempty"`
	After               Result        `json:"after"`
	AfterReset          ResetEvidence `json:"afterReset"`
	Qualified           bool          `json:"qualified"`
}

func RunBoundary

func RunBoundary(ctx context.Context, spec BoundaryCase) (out BoundaryResult, runErr error)

type ByteCorpus

type ByteCorpus struct {
	Version             int          `json:"version"`
	GenerationVersion   string       `json:"generationVersion"`
	TargetVersion       string       `json:"targetVersion"`
	ConfigurationSHA256 string       `json:"configurationSHA256"`
	Cases               []CorpusCase `json:"cases"`
}

func GenerateByteCorpus

func GenerateByteCorpus(seed []byte, maxCases, maxBytes int, target string) (ByteCorpus, error)

type Campaign

type Campaign struct {
	Metadata      ExperimentMetadata `json:"metadata"`
	Generation    *GenerationSpec    `json:"generation,omitempty"`
	Control       Exchange           `json:"control"`
	SendStep      int                `json:"sendStep"`
	ResponseStep  int                `json:"responseStep"`
	FailureMarker []byte             `json:"failureMarker"`
	MaxCases      int                `json:"maxCases"`
	MaxAttempts   int                `json:"maxAttempts"`
}

type CampaignResult

type CampaignResult struct {
	MinimizationMethod   string          `json:"minimizationMethod,omitempty"`
	MinimizationComplete bool            `json:"minimizationComplete"`
	Corpus               GeneratedCorpus `json:"corpus"`
	BeforeReset          ResetEvidence   `json:"beforeReset"`
	AfterReset           ResetEvidence   `json:"afterReset"`
	MinimizedCase        *GeneratedCase  `json:"minimizedCase,omitempty"`
	Reproduction         *CampaignTrial  `json:"reproduction,omitempty"`
	Before               Result          `json:"before"`
	Trials               []CampaignTrial `json:"trials"`
	Minimized            *Minimized      `json:"minimized,omitempty"`
	After                Result          `json:"after"`
	Limitation           string          `json:"limitation"`
}

func RunCampaign

func RunCampaign(ctx context.Context, spec Campaign) (out CampaignResult, runErr error)

RunCampaign uses an application marker as its oracle, never a timeout or crash. Each trial gets a fresh connection and its declared reset; OS resets are import-only.

type CampaignTrial

type CampaignTrial struct {
	Case                  GeneratedCase `json:"case"`
	Reset                 ResetEvidence `json:"reset"`
	Input                 []byte        `json:"input"`
	Result                Result        `json:"result"`
	FailureMarkerReturned bool          `json:"failureMarkerReturned"`
}

type CorpusCase

type CorpusCase struct {
	ID     string `json:"id"`
	Input  []byte `json:"input"`
	SHA256 string `json:"sha256"`
}

func MutationCorpus

func MutationCorpus(seed []byte, maxCases, maxBytes int) ([]CorpusCase, error)

MutationCorpus is deterministic: control, truncations, then single-byte XORs. It deliberately preserves malformed lengths; it does not infer a grammar.

type Exchange

type Exchange struct {
	ServerTLS             *ServerTLS `json:"serverTLS,omitempty"`
	PeerCertificateSHA256 string     `json:"peerCertificateSHA256,omitempty"`
	Version               int        `json:"version"`
	Network               string     `json:"network"`
	Address               string     `json:"address"`
	TLS                   bool       `json:"tls"`
	ServerName            string     `json:"serverName,omitempty"`
	RootCAFile            string     `json:"rootCAFile,omitempty"`
	ClientCertificateFile string     `json:"clientCertificateFile,omitempty"`
	ClientKeyFile         string     `json:"clientKeyFile,omitempty"`
	Framing               Framing    `json:"framing"`
	TimeoutMilliseconds   int        `json:"timeoutMilliseconds"`
	MaxTotalBytes         int        `json:"maxTotalBytes"`
	Steps                 []Step     `json:"steps"`
}

func (Exchange) Validate

func (e Exchange) Validate() error

type ExperimentMetadata

type ExperimentMetadata struct {
	Version       int       `json:"version"`
	TargetVersion string    `json:"targetVersion"`
	Reset         ResetSpec `json:"reset"`
}

func (ExperimentMetadata) Validate

func (m ExperimentMetadata) Validate() error

type FieldDifference

type FieldDifference struct {
	Frame  int    `json:"frame"`
	Field  string `json:"field"`
	Before string `json:"before"`
	After  string `json:"after"`
}

type FieldMutation

type FieldMutation struct {
	Name   string   `json:"name"`
	Values [][]byte `json:"values,omitempty"`
}

type FieldSpec

type FieldSpec struct {
	LengthFrom *LengthField `json:"lengthFrom,omitempty"`
	TLV        *TLVSpec     `json:"tlv,omitempty"`
	Name       string       `json:"name"`
	Offset     int          `json:"offset"`
	Length     int          `json:"length"`
	Kind       string       `json:"kind"`
	ByteOrder  string       `json:"byteOrder,omitempty"`
	Expected   []byte       `json:"expected,omitempty"`
	Hypothesis string       `json:"hypothesis"`
}

type Framing

type Framing struct {
	Kind                 string `json:"kind"`
	LengthBytes          int    `json:"lengthBytes,omitempty"`
	ByteOrder            string `json:"byteOrder,omitempty"`
	LengthIncludesHeader bool   `json:"lengthIncludesHeader,omitempty"`
	Delimiter            []byte `json:"delimiter,omitempty"`
	FixedSize            int    `json:"fixedSize,omitempty"`
	MaxBytes             int    `json:"maxBytes"`
}

func (Framing) ParseAll

func (f Framing) ParseAll(data []byte) ([][]byte, error)

ParseAll rejects trailing partial frames instead of accepting a plausible prefix.

func (Framing) Read

func (f Framing) Read(reader io.Reader) ([]byte, error)

func (Framing) Validate

func (f Framing) Validate() error

type GeneratedCase

type GeneratedCase struct {
	ID                  string   `json:"id"`
	Kind                string   `json:"kind"`
	Exchange            Exchange `json:"exchange"`
	SendStep            int      `json:"sendStep"`
	ResponseStep        int      `json:"responseStep"`
	ConfigurationSHA256 string   `json:"configurationSHA256"`
}

type GeneratedCorpus

type GeneratedCorpus struct {
	Version             int                `json:"version"`
	GenerationVersion   string             `json:"generationVersion"`
	Metadata            ExperimentMetadata `json:"metadata"`
	ConfigurationSHA256 string             `json:"configurationSHA256"`
	Cases               []GeneratedCase    `json:"cases"`
}

func GenerateCampaign

func GenerateCampaign(spec Campaign) (GeneratedCorpus, error)

type GenerationSpec

type GenerationSpec struct {
	Version   int             `json:"version"`
	Bytes     bool            `json:"bytes"`
	Grammar   *Grammar        `json:"grammar,omitempty"`
	BuildSeed bool            `json:"buildSeed"`
	Fields    []FieldMutation `json:"fields,omitempty"`
	States    []StateMutation `json:"states,omitempty"`
}

type Grammar

type Grammar struct {
	Version   int         `json:"version"`
	Framing   Framing     `json:"framing"`
	Fields    []FieldSpec `json:"fields"`
	MaxFrames int         `json:"maxFrames"`
}

func (Grammar) Compare

func (g Grammar) Compare(before, after []byte) (GrammarComparison, error)

func (Grammar) Interpret

func (g Grammar) Interpret(data []byte) (report GrammarReport, runErr error)

type GrammarComparison

type GrammarComparison struct {
	Before      GrammarReport     `json:"before"`
	After       GrammarReport     `json:"after"`
	Differences []FieldDifference `json:"differences"`
	Alignment   string            `json:"alignment"`
}

type GrammarFailure

type GrammarFailure struct {
	Offset int    `json:"offset"`
	Raw    []byte `json:"raw"`
}

type GrammarReport

type GrammarReport struct {
	Error       string             `json:"error,omitempty"`
	Failure     *GrammarFailure    `json:"failure,omitempty"`
	Version     int                `json:"version"`
	InputSHA256 string             `json:"inputSHA256"`
	Frames      []InterpretedFrame `json:"frames"`
	Limitations []string           `json:"limitations"`
}

type Injection

type Injection struct {
	Direction   string `json:"direction"`
	BeforeFrame int    `json:"beforeFrame"`
	Message     []byte `json:"message"`
}

Injection writes a complete message before reading the selected source frame. BeforeFrame=0 can initiate a session without any bytes from that source.

type InterpretedField

type InterpretedField struct {
	Entries    []TLVEntry `json:"entries,omitempty"`
	Name       string     `json:"name"`
	Offset     int        `json:"offset"`
	Length     int        `json:"length"`
	Raw        []byte     `json:"raw"`
	Value      string     `json:"value"`
	Hypothesis string     `json:"hypothesis"`
}

type InterpretedFrame

type InterpretedFrame struct {
	Index  int                `json:"index"`
	Offset int                `json:"offset"`
	Length int                `json:"length"`
	SHA256 string             `json:"sha256"`
	Fields []InterpretedField `json:"fields"`
}

type LengthField

type LengthField struct {
	Offset     int    `json:"offset"`
	Width      int    `json:"width"`
	ByteOrder  string `json:"byteOrder"`
	Adjustment int    `json:"adjustment"`
}

func (LengthField) Resolve

func (s LengthField) Resolve(frame []byte) (int, error)

func (LengthField) Validate

func (s LengthField) Validate() error

type Minimized

type Minimized struct {
	Original []byte `json:"original"`
	Input    []byte `json:"input"`
	Attempts int    `json:"attempts"`
	Complete bool   `json:"complete"`
}

func Minimize

func Minimize(ctx context.Context, input []byte, maxAttempts int, oracle func(context.Context, []byte) (bool, error)) (Minimized, error)

Minimize deletes bytes while an explicit failure oracle still reproduces. Oracle errors (including transport errors) are not classified as failures.

type Mutation

type Mutation struct {
	Direction         string `json:"direction"`
	Frame             int    `json:"frame"`
	Offset            int    `json:"offset"`
	Delete            int    `json:"delete"`
	Insert            []byte `json:"insert"`
	RepairLength      bool   `json:"repairLength"`
	Drop              bool   `json:"drop"`
	Copies            int    `json:"copies"`
	DelayMilliseconds int    `json:"delayMilliseconds"`
}

type Observation

type Observation struct {
	Step        int    `json:"step"`
	Name        string `json:"name"`
	Direction   string `json:"direction"`
	TimestampNs string `json:"timestampNs"`
	Bytes       []byte `json:"bytes"`
	SHA256      string `json:"sha256"`
}

type Proxy

type Proxy struct {
	Injections          []Injection `json:"injections,omitempty"`
	Mode                string      `json:"mode,omitempty"`
	TLS                 *ProxyTLS   `json:"tls,omitempty"`
	Address             string      `json:"address"`
	Framing             Framing     `json:"framing"`
	TimeoutMilliseconds int         `json:"timeoutMilliseconds"`
	MaxFrames           int         `json:"maxFrames"`
	MaxTotalBytes       int         `json:"maxTotalBytes"`
	Mutations           []Mutation  `json:"mutations"`
}

type ProxyObservation

type ProxyObservation struct {
	Planned     []byte `json:"planned,omitempty"`
	Injected    bool   `json:"injected,omitempty"`
	TLSVersion  uint16 `json:"tlsVersion,omitempty"`
	TLSCipher   uint16 `json:"tlsCipher,omitempty"`
	Direction   string `json:"direction"`
	Frame       int    `json:"frame"`
	Original    []byte `json:"original"`
	Transmitted []byte `json:"transmitted"`
	Copies      int    `json:"copies"`
	TimestampNs string `json:"timestampNs"`
	Error       string `json:"error,omitempty"`
}

func ProxyOne

func ProxyOne(ctx context.Context, listener net.Listener, spec Proxy) ([]ProxyObservation, error)

ProxyOne handles one accepted TCP connection. The caller owns listener. It terminates both legs on framing, mutation, budget, timeout or transport failure.

type ProxyTLS

type ProxyTLS struct {
	ClientCertificateFile string `json:"clientCertificateFile,omitempty"`
	ClientKeyFile         string `json:"clientKeyFile,omitempty"`
	PeerCertificateSHA256 string `json:"peerCertificateSHA256,omitempty"`
	Mode                  string `json:"mode,omitempty"`
	CertificateFile       string `json:"certificateFile"`
	KeyFile               string `json:"keyFile"`
	RootCAFile            string `json:"rootCAFile"`
	ServerName            string `json:"serverName"`
}

ProxyTLS requires explicit identity and trust for both independently negotiated legs.

type ReproductionResult

type ReproductionResult struct {
	Version           int              `json:"version"`
	GenerationVersion string           `json:"generationVersion"`
	Spec              ReproductionSpec `json:"spec"`
	Trial             CampaignTrial    `json:"trial"`
}

type ReproductionSpec

type ReproductionSpec struct {
	Metadata      ExperimentMetadata `json:"metadata"`
	Case          GeneratedCase      `json:"case"`
	FailureMarker []byte             `json:"failureMarker"`
}

type ResetEvidence

type ResetEvidence struct {
	Mode        string  `json:"mode"`
	Description string  `json:"description"`
	Observation *Result `json:"observation,omitempty"`
	Isolation   string  `json:"isolation"`
}

type ResetSpec

type ResetSpec struct {
	Mode        string    `json:"mode"`
	Description string    `json:"description"`
	Exchange    *Exchange `json:"exchange,omitempty"`
}

type Result

type Result struct {
	Version             int           `json:"version"`
	ConfigurationSHA256 string        `json:"configurationSHA256"`
	Address             string        `json:"address"`
	LocalAddress        string        `json:"localAddress,omitempty"`
	RemoteAddress       string        `json:"remoteAddress,omitempty"`
	TLSVersion          uint16        `json:"tlsVersion,omitempty"`
	TLSCipher           uint16        `json:"tlsCipher,omitempty"`
	Status              string        `json:"status"`
	Error               string        `json:"error,omitempty"`
	Observations        []Observation `json:"observations"`
	Limitations         []string      `json:"limitations"`
}

func Run

func Run(ctx context.Context, exchange Exchange) (result Result, runErr error)

func ServeOne

func ServeOne(ctx context.Context, listener net.Listener, spec Exchange) (result Result, runErr error)

ServeOne emulates one ordered TCP session. Receive and send steps are separate when a response depends on a request. A new invocation resets all variables.

func ServeUDP

func ServeUDP(ctx context.Context, packet net.PacketConn, spec Exchange) (result Result, runErr error)

ServeUDP pins one peer on the first datagram and refuses cross-peer session mixing. UDP has no half-close, retransmission or reliable ordering semantics.

type ServerTLS

type ServerTLS struct {
	CertificateFile       string `json:"certificateFile"`
	KeyFile               string `json:"keyFile"`
	ClientCAFile          string `json:"clientCAFile,omitempty"`
	PeerCertificateSHA256 string `json:"peerCertificateSHA256,omitempty"`
}

type StateMutation

type StateMutation struct {
	Action string `json:"action"`
	Step   int    `json:"step"`
}

type Step

type Step struct {
	Name            string `json:"name"`
	Send            []byte `json:"send,omitempty"`
	SendPresent     bool   `json:"sendPresent,omitempty"`
	Receive         bool   `json:"receive"`
	Expect          []byte `json:"expect,omitempty"`
	ExpectPresent   bool   `json:"expectPresent,omitempty"`
	Contains        []byte `json:"contains,omitempty"`
	CaptureVariable string `json:"captureVariable,omitempty"`
	CaptureOffset   int    `json:"captureOffset,omitempty"`
	CaptureLength   int    `json:"captureLength,omitempty"`
	SendVariable    string `json:"sendVariable,omitempty"`
}

type TLSCaptureResult

type TLSCaptureResult struct {
	Version      int      `json:"version"`
	InputSHA256  string   `json:"inputSHA256"`
	KeyLogSHA256 string   `json:"keyLogSHA256"`
	ToolVersion  string   `json:"toolVersion"`
	Stream       int      `json:"stream"`
	Client       []byte   `json:"node0Bytes"`
	Server       []byte   `json:"node1Bytes"`
	ClientSHA256 string   `json:"node0SHA256"`
	ServerSHA256 string   `json:"node1SHA256"`
	Nodes        []string `json:"nodes"`
	Limitations  []string `json:"limitations"`
}

func AnalyzeTLSCapture

func AnalyzeTLSCapture(ctx context.Context, input, keyLog string, stream int) (TLSCaptureResult, error)

AnalyzeTLSCapture delegates cryptographic dissection to the installed tshark. Node direction follows tshark's reported endpoints; no client-role inference is made.

type TLVEntry

type TLVEntry struct {
	Type     uint64     `json:"type"`
	Offset   int        `json:"offset"`
	Length   int        `json:"length"`
	Value    []byte     `json:"value"`
	Children []TLVEntry `json:"children,omitempty"`
}

type TLVSpec

type TLVSpec struct {
	TypeBytes            int      `json:"typeBytes"`
	LengthBytes          int      `json:"lengthBytes"`
	ByteOrder            string   `json:"byteOrder"`
	LengthIncludesHeader bool     `json:"lengthIncludesHeader"`
	NestedTypes          []uint64 `json:"nestedTypes,omitempty"`
	LeafKind             string   `json:"leafKind"`
	MaxDepth             int      `json:"maxDepth"`
	MaxEntries           int      `json:"maxEntries"`
	MaxValueBytes        int      `json:"maxValueBytes"`
}

func (TLVSpec) Validate

func (s TLVSpec) Validate() error

type TriageArtifact

type TriageArtifact struct {
	InputGeneration     string `json:"inputGeneration"`
	Version             int    `json:"version"`
	GenerationVersion   string `json:"generationVersion"`
	ConfigurationSHA256 string `json:"configurationSHA256"`
	InputSHA256         string `json:"inputSHA256"`
	Kind                string `json:"kind"`
	TargetVersion       string `json:"targetVersion"`
	Reset               string `json:"reset"`
	Input               []byte `json:"input"`
	Evidence            []byte `json:"evidence"`
	EvidenceSHA256      string `json:"evidenceSHA256"`
	Classification      string `json:"classification"`
}

func ImportGeneratedTriage

func ImportGeneratedTriage(kind, version, reset, inputGeneration string, input []byte, path string) (TriageArtifact, error)

func ImportTriage

func ImportTriage(kind, version, reset string, input []byte, path string) (TriageArtifact, error)

ImportTriage retains external evidence verbatim without executing it or interpreting a stack, sanitizer report or process exit as proof of impact.

Jump to

Keyboard shortcuts

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