module Docs::A_GETTING_STARTED::RULES_AND_SELECTORS

Overview

Structure Rules & Advanced Selectors

Crowbar 2.0 features 10 structure-preserving format rules and an arsenal of composable selectors to isolate specific data structures or target valid grammars with precision.

Executive Summary & Key Topics

Topic Method / Anchor Description
Structure-Preserving Rules (10 Formats) .topic_01_rules_catalog Deep inspection of all available format rules in Crowbar.
Composable Selectors & Combinators .topic_02_selectors_and_combinators Target columns, character classes, strides, entropy, or combine with &, |, ~.

Related Guides & Source References

Defined in:

docs/a_getting_started/rules_and_selectors.cr

Class Method Summary

Class Method Detail

def self.topic_01_rules_catalog : Nil #

Structure-Preserving Rules (10 Formats): Deep inspection of all available format rules in Crowbar.

Format Rule Code Description
JSON `json` Valid JSON AST with mutated leaf values and bounds
YAML `yaml` Valid YAML document hierarchy with mutated scalars
HTTP `http` RFC HTTP/1.x framing with mutated headers, paths, or body
DNS `dns` RFC 1035 wire-format DNS packets with mutated records
CSV/TSV `csv` RFC 4180 tabular data with column and cell transforms
XML/HTML `xml` Valid XML/HTML document tree with mutated nodes and attributes
URL `url` RFC 3986 URI/URL and query string parameters
TLV `tlv` Type-Length-Value binary packet framing and boundary lengths
Base64 `base64` Transparent Base64 envelope decode-mutate-encode
Varint `varint` LEB128/Protobuf 7-bit continuation bit integer streams

Working Examples

fuzzer = Crowbar.define do
  preserve :csv  # or :xml, :url, :json, :yaml, :http, :dns, :tlv, :base64, :varint
end

def self.topic_02_selectors_and_combinators : Nil #

Composable Selectors & Combinators: Target columns, character classes, strides, entropy, or combine with &, |, ~.

Selector DSL Helper Description
`DelimitedField` `field: 1, delimiter: ','` Isolates N-th column or token
`CharacterClass` `chars: :digits` Targets contiguous digits, hex, or printable spans
`Stride` `stride: 4, offset: 0` Targets periodic byte slices at regular intervals
`Entropy` `entropy: :high` Targets Shannon entropy slices (:high or :low)
`Combinators` `sel_a & sel_b` Composable intersection (&), union ( ), and inversion (~)

Working Examples

fuzzer = Crowbar.define do
  # Intersect delimited field with character class
  selector = Crowbar::Selectors::DelimitedField.new(1, ',') &
             Crowbar::Selectors::CharacterClass.new(:digits)

  scope :numeric_field, selector: selector do
    mutate :num, :scale
  end
end