strawberry/fuzz/seeds/fuzz_rule_partition/rules
trvon 169a05cd2a
fuzz: target the YARA rule partitioner
rule_partition.cpp parses rule sources (splitting rules, extracting top-level
condition identifiers and facts), but had no fuzz target, contradicting the
repository rule that every parser of attacker-influenced input gets one.
fuzz_rule_partition asserts the splitter is a total, exact partition of its
input, that rule/condition slicing stays within the rule, and that partition
selection agrees with magic bytes and the size bucket boundaries.

It is registered in fuzz/meson.build (with rule_partition.cpp), swept by
scripts/run_fuzzers.sh, and documented next to the other targets. Seeds cover
comments, strings, regexes, hex blocks, an include and a truncated source.
2026-11-17 13:45:12 -07:00

32 lines
659 B
Text

import "pe"
import "math"
private rule helper_match {
strings:
$a = "MZ"
$hex = { 4D 5A ?? ?? [0-4] 00 }
$re = /foo(bar|baz)+/i nocase
condition:
$a at 0 or any of them
}
global rule gated {
condition:
filesize < 20MB
}
rule win_executable : windows malware
{
meta:
author = "seed"
description = "a rule with a // comment inside and a /* block */ comment"
strings:
$mz = { 4D 5A }
condition:
uint16(0) == 0x5A4D and ( pe.number_of_sections > 2 or filesize < 1MB ) and $mz
}
rule elf_only {
condition:
uint32(0) == 0x464c457f and filesize <= 4MB
}