Documentation
¶
Overview ¶
Package corpusgen produces deterministic edge-case seed values from neutral schema/auth constraints. It is a generation-time tool used by cmd/apic and the helpers/* emitters to bake intelligent f.Add(...) seeds into generated fuzz tests. Determinism is mandatory: no rand, no time — generated output must be byte-identical across runs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Intp ¶
Intp / Fp are pointer constructors for ergonomic Constraint building from non-pointer config fields (cmd/apic builds Constraint values directly).
func RenderLiteral ¶
RenderLiteral renders a seed value as a deterministic Go source expression suitable for baking into generated test code. Maps render with sorted keys.
Types ¶
type Constraint ¶
type Constraint struct {
Type string // "string","integer","number","boolean","array","object","file"
MinLen *int
MaxLen *int
Min *float64
Max *float64
ExclusiveMin bool
ExclusiveMax bool
Pattern string
Enum []any
Required bool
Nullable bool
Items *Constraint
Properties map[string]Constraint
PropRequired []string
MinItems *int
MaxItems *int
}
Constraint is a neutral description of one field's validation rules, decoupled from any specific schema model so adapters can map both the config SchemaProp and kin-openapi schemas onto it.
func FromOpenAPISchema ¶
func FromOpenAPISchema(s *openapi3.Schema) Constraint
FromOpenAPISchema maps a kin-openapi schema to a neutral Constraint. Used by the helpers/* emitters which read api/cfgs/openapi.yaml. Returns the zero Constraint for a nil schema.
Note: this function maps SCALAR facets only (type/length/numeric/enum/pattern). It does not populate Items/Properties/PropRequired/MinItems/MaxItems because the current helpers/* consumers fuzz scalar request fields. Extend when object/array helper fuzzing is added.
type Seed ¶
Seed is one edge-case value plus a short tag describing why it matters.
func AuthSeeds ¶
AuthSeeds returns adversarial Authorization-header values for an auth mode or composite expression. The values are full header strings (e.g. "Bearer <token>"). "public"/"none" yield no seeds. The forged JWTs are static, well-known test fixtures (alg:none, etc.); add an allowlist entry in .gitleaks.toml if a scanner flags them.
func ObjectSeeds ¶
func ObjectSeeds(c Constraint) []Seed
ObjectSeeds returns whole-object seeds: a valid in-bounds object, one variant per single-required-missing, and an extra-unknown-property object.
func ValuesFor ¶
func ValuesFor(c Constraint) []Seed
ValuesFor returns deterministic edge-case seeds for a single constraint.