Skip to main content

Module opcode

Module opcode 

Source
Expand description

Opcode and bytecode wire-format contract (version 1).

§File layout (RUSO + version byte)

  1. Metadata (name, description, impact, severity, author, report title)
  2. Probe table (HTTP / DNS / TCP specs)
  3. String pool
  4. Matcher pool (QualifiedMatch)
  5. Extract pool (ExtractSource)
  6. Evidence pool (EvidenceKind)
  7. Payload pool (raw bytes for Send overrides)
  8. Instruction stream (Opcode discriminants)

§Instruction opcodes (wire u8)

ByteVariantPayload
1Setname_id: u32, value_id: u32
2Sendprobe_id: u32, optional payload index
3Matchmatcher_id: u32
4MatchAllstart: u32, len: u16
5MatchAnystart: u32, len: u16
6Assertmatcher_id: u32
7Extractname_id: u32, source_id: u32
8IfMatchmatcher_id: u32, else_pc: u32
9Savefrom_id: u32, to_id: u32
10Evidencekind_id: u32
11Retryprobe_id: u32, count: u32
12RetryDelayduration_id: u32
13Sleepduration_id: u32
14Stop—
15Fail—
16Continue—
17Exit—
18(reserved)was Repeat, removed
19LoopBack—
20Break—
21SetListname_id: u32, start: u32, len: u16
22ForListitem_id: u32, start: u32, len: u16, end_pc: u32
23ForVaritem_id: u32, list_id: u32, end_pc: u32

Compilers must emit crate::BytecodeProgram compatible with crate::VERSION.

Structs§

BytecodeProgram
Compiled script ready for the executor (probes, metadata, and instruction stream).

Enums§

Opcode
A single VM instruction. Operands are u32/u16 indices into the program’s pools (strings, matchers, extracts, evidence) or program counters (Pc) into code — never inline data.

Constants§

MAGIC
The four magic bytes every .rbc file starts with.
OP_ASSERT
Evaluate a matcher and abort the script when it fails: matcher_id: u32.
OP_BREAK
Leave the enclosing loop.
OP_CONTINUE
Skip the rest of the current loop iteration and start the next one.
OP_EVIDENCE
Attach proof to the finding this script emits: kind_id: u32, an evidence-pool index naming the source (body, whole response, or a header).
OP_EXIT
Halt the script immediately without emitting a finding.
OP_EXTRACT
Pull a value out of the last response into a variable: name_id: u32, source_id: u32 (an extract-pool index).
OP_FAIL
Halt the script and mark the run as failed.
OP_FOR_LIST
Loop over a literal list: item_id: u32 (the loop variable), start: u32, len: u16 (the elements), end_pc: u32 (where to resume).
OP_FOR_VAR
Loop over a list held in a variable: item_id: u32 (the loop variable), list_id: u32 (the list variable), end_pc: u32 (where to resume).
OP_IF_MATCH
Branch on a matcher: run the following block when it holds, otherwise jump to else_pc. Payload is matcher_id: u32, else_pc: u32.
OP_LOOP_BACK
Jump back to the top of the enclosing loop.
OP_MATCH
Evaluate one matcher and record the outcome: matcher_id: u32.
OP_MATCH_ALL
Evaluate a contiguous run of matchers; holds only if all of them do. Payload is start: u32, len: u16.
OP_MATCH_ANY
Evaluate a contiguous run of matchers; holds if any of them does. Payload is start: u32, len: u16.
OP_RETRY
Re-send a probe up to count times while it keeps failing: probe_id: u32, count: u32.
OP_RETRY_DELAY
Set the delay inserted between OP_RETRY attempts: duration_id: u32 (a string-pool duration literal).
OP_SAVE
Copy one variable into another: from_id: u32, to_id: u32.
OP_SEND
Fire a probe: probe_id: u32, plus an optional payload-pool index that overrides the probe’s own body.
OP_SET
Bind a variable: name_id: u32, value_id: u32 (both string-pool indices).
OP_SET_LIST
Bind a list variable from a contiguous run of string-pool entries: name_id: u32, start: u32, len: u16.
OP_SLEEP
Pause execution: duration_id: u32.
OP_STOP
Halt the script and report whatever has matched so far.
VERSION
The wire-format version this build reads and writes. The decoder accepts this value only; see the module docs before changing it.

Type Aliases§

Pc
Instruction pointer index into BytecodeProgram::code.