replay

package
v0.0.0-...-9b8dde8 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const ManifestVersion = "1.1"

ManifestVersion captures the schema version for replay artefact manifests.

Variables

This section is empty.

Functions

func CasesEqual

func CasesEqual(a, b []cases.Case) bool

CasesEqual compares two case slices after normalising ordering.

func CasesEqualWithOrder

func CasesEqualWithOrder(a, b []cases.Case, order []string) bool

CasesEqualWithOrder compares two case slices using the provided ordering when supplied.

func ComputeCaseDigest

func ComputeCaseDigest(list []cases.Case, order []string, algorithm string) (string, error)

ComputeCaseDigest renders the provided cases and returns a deterministic digest.

func ComputeFindingsDigest

func ComputeFindingsDigest(list []findings.Finding, order []string, algorithm string) (string, error)

ComputeFindingsDigest renders the findings and returns a deterministic digest.

func CreateArtifact

func CreateArtifact(path string, manifest Manifest, files map[string][]byte) error

CreateArtifact writes the replay manifest and referenced files to a gzipped tarball.

func CreateArtifactWithContext

func CreateArtifactWithContext(ctx context.Context, path string, manifest Manifest, files map[string][]byte) error

CreateArtifactWithContext writes the replay manifest and referenced files to a gzipped tarball using the provided context for tracing.

func LoadCases

func LoadCases(path string) ([]cases.Case, error)

LoadCases reads cases from a JSON file.

func LoadCasesWithContext

func LoadCasesWithContext(ctx context.Context, path string) ([]cases.Case, error)

LoadCasesWithContext reads cases from a JSON file using the provided context for tracing.

func OrderCases

func OrderCases(list []cases.Case, order []string) []cases.Case

OrderCases clones and reorders the provided cases using the supplied ordering.

func OrderFindings

func OrderFindings(list []findings.Finding, order []string) []findings.Finding

OrderFindings clones and reorders the findings according to the provided sequence.

func SanitizeBody

func SanitizeBody(body []byte) []byte

SanitizeBody redacts common credential tokens from HTTP bodies.

func SanitizeCookieValue

func SanitizeCookieValue(value string) string

SanitizeCookieValue hashes cookie values to avoid leaking secrets.

func SanitizeHeaders

func SanitizeHeaders(input map[string][]string) map[string][]string

SanitizeHeaders redacts sensitive header values.

func WriteCases

func WriteCases(path string, list []cases.Case, opts ...WriteCasesOption) error

WriteCases writes the provided cases to disk using deterministic encoding.

func WriteCasesWithContext

func WriteCasesWithContext(ctx context.Context, path string, list []cases.Case, opts ...WriteCasesOption) error

WriteCasesWithContext writes cases using the provided context for tracing.

func WriteFindings

func WriteFindings(path string, list []findings.Finding) error

WriteFindings persists the findings to a JSONL file using deterministic ordering.

func WriteFindingsWithContext

func WriteFindingsWithContext(ctx context.Context, path string, list []findings.Finding) error

WriteFindingsWithContext writes findings using the provided context for tracing.

func WriteFlows

func WriteFlows(path string, flows []FlowRecord) error

WriteFlows persists the provided flow records as JSONL.

func WriteFlowsWithContext

func WriteFlowsWithContext(ctx context.Context, path string, flows []FlowRecord) error

WriteFlowsWithContext persists flow records using the provided context for tracing.

Types

type CookieRecord

type CookieRecord struct {
	Domain string `json:"domain"`
	Name   string `json:"name"`
	Value  string `json:"value"`
}

CookieRecord stores sanitised cookie values observed during the run.

type DNSRecord

type DNSRecord struct {
	Host      string   `json:"host"`
	Addresses []string `json:"addresses"`
}

DNSRecord records resolved addresses for a host.

type FlowRecord

type FlowRecord struct {
	ID                string `json:"id"`
	Sequence          uint64 `json:"sequence"`
	Type              string `json:"type"`
	TimestampUnix     int64  `json:"timestamp_unix"`
	SanitizedBase64   string `json:"sanitized_base64,omitempty"`
	RawBodyBytes      int    `json:"raw_body_bytes,omitempty"`
	RawBodyCaptured   int    `json:"raw_body_captured,omitempty"`
	SanitizedRedacted bool   `json:"sanitized_redacted,omitempty"`
}

FlowRecord captures a sanitized proxy flow suitable for replay. TimestampUnix is recorded in seconds since the Unix epoch to keep the log compact.

func LoadFlows

func LoadFlows(path string) ([]FlowRecord, error)

LoadFlows reads flow records from a JSONL file.

func LoadFlowsWithContext

func LoadFlowsWithContext(ctx context.Context, path string) ([]FlowRecord, error)

LoadFlowsWithContext reads flow records from a JSONL file using the provided context for tracing.

type Manifest

type Manifest struct {
	Version       string            `json:"version"`
	CreatedAt     time.Time         `json:"created_at"`
	Seeds         map[string]int64  `json:"seeds,omitempty"`
	DNS           []DNSRecord       `json:"dns,omitempty"`
	TLS           []TLSRecord       `json:"tls,omitempty"`
	Robots        []RobotsRecord    `json:"robots,omitempty"`
	RateLimits    []RateLimitRecord `json:"rate_limits,omitempty"`
	Cookies       []CookieRecord    `json:"cookies,omitempty"`
	Responses     []ResponseRecord  `json:"responses,omitempty"`
	FlowsFile     string            `json:"flows_file,omitempty"`
	Runner        RunnerInfo        `json:"runner"`
	Plugins       []PluginInfo      `json:"plugins"`
	FindingsFile  string            `json:"findings_file"`
	FindingOrder  []string          `json:"finding_order,omitempty"`
	CasesFile     string            `json:"cases_file"`
	CaseOrder     []string          `json:"case_order,omitempty"`
	CaseTimestamp time.Time         `json:"case_timestamp"`
	Provenance    []Provenance      `json:"provenance,omitempty"`
}

Manifest describes the metadata captured for a replayable pipeline run.

func ExtractArtifact

func ExtractArtifact(path, dest string) (Manifest, error)

ExtractArtifact expands the artefact under the destination directory and returns the manifest.

func ExtractArtifactWithContext

func ExtractArtifactWithContext(ctx context.Context, path, dest string) (Manifest, error)

func (*Manifest) Normalize

func (m *Manifest) Normalize()

Normalize enforces deterministic ordering across manifest collections so that serialised artefacts remain stable for replay comparisons.

func (Manifest) ProvenanceByScope

func (m Manifest) ProvenanceByScope(scope string) (Provenance, bool)

ProvenanceByScope retrieves the provenance record for the provided scope.

func (Manifest) Validate

func (m Manifest) Validate() error

Validate ensures the manifest is structurally sound before packaging.

type PluginInfo

type PluginInfo struct {
	Name         string `json:"name"`
	Version      string `json:"version"`
	ManifestPath string `json:"manifest_path"`
	Signature    string `json:"signature"`
	SHA256       string `json:"sha256"`
}

PluginInfo stores the manifest and signature metadata for a plugin.

type Provenance

type Provenance struct {
	Scope     string `json:"scope"`
	Algorithm string `json:"algorithm"`
	Digest    string `json:"digest"`
}

Provenance captures pre-computed digests for artefact components.

type RateLimitRecord

type RateLimitRecord struct {
	Host   string `json:"host"`
	Policy string `json:"policy"`
}

RateLimitRecord captures observed rate limiting headers.

type ResponseRecord

type ResponseRecord struct {
	RequestURL string              `json:"request_url"`
	Method     string              `json:"method"`
	Status     int                 `json:"status"`
	Headers    map[string][]string `json:"headers,omitempty"`
	BodyFile   string              `json:"body_file,omitempty"`
}

ResponseRecord references a sanitised HTTP response body.

type RobotsRecord

type RobotsRecord struct {
	Host     string `json:"host"`
	BodyFile string `json:"body_file"`
}

RobotsRecord stores the contents of robots.txt for a host.

type RunnerInfo

type RunnerInfo struct {
	CtlVersion    string `json:"0xgenctl_version"`
	DaemonVersion string `json:"0xgend_version"`
	GoVersion     string `json:"go_version,omitempty"`
	OS            string `json:"os,omitempty"`
	Arch          string `json:"arch,omitempty"`
}

RunnerInfo records the versions of the primary executables.

func DefaultRunnerInfo

func DefaultRunnerInfo() RunnerInfo

DefaultRunnerInfo returns a baseline RunnerInfo populated from the runtime.

type TLSRecord

type TLSRecord struct {
	Host           string   `json:"host"`
	JA3            string   `json:"ja3,omitempty"`
	JA3Hash        string   `json:"ja3_hash,omitempty"`
	NegotiatedALPN string   `json:"negotiated_alpn,omitempty"`
	OfferedALPN    []string `json:"offered_alpn,omitempty"`
}

TLSRecord stores observed TLS fingerprinting and ALPN negotiation metadata.

type WriteCasesOption

type WriteCasesOption func(*writeCasesConfig)

WriteCasesOption configures optional behaviour when writing cases.

func WithCaseOrder

func WithCaseOrder(order []string) WriteCasesOption

WithCaseOrder preserves the provided ordering when serialising cases.

Jump to

Keyboard shortcuts

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