strawberry/fuzz/meson.build
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

54 lines
2.4 KiB
Meson

# libFuzzer targets for every boundary that parses untrusted or
# attacker-influenced input. Build with clang:
# CC=clang CXX=clang++ meson setup build/fuzz -Denable_fuzzing=true -Denable_app=disabled
# nice -n 19 ninja -C build/fuzz -j2
# scripts/run_fuzzers.sh 60 # each target for 60 s, capped
fuzz_args = ['-fsanitize=fuzzer']
fuzz_targets = {
'fuzz_ioc_list': ['fuzz_ioc_list.cpp', '../src/rule_updater.cpp', '../src/ioc_list.cpp', '../src/yara_scanner.cpp', '../src/rule_partition.cpp'],
'fuzz_policy_apply': ['fuzz_policy_apply.cpp'],
'fuzz_governor_parsers': ['fuzz_governor_parsers.cpp'],
'fuzz_status_snapshot': ['fuzz_status_snapshot.cpp'],
'fuzz_config': ['fuzz_config.cpp'],
'fuzz_record_decoder': ['fuzz_record_decoder.cpp'],
'fuzz_block_decoder': ['fuzz_block_decoder.cpp'],
'fuzz_segment_reader': ['fuzz_segment_reader.cpp'],
'fuzz_manifest': ['fuzz_manifest.cpp'],
'fuzz_evidence_records': ['fuzz_evidence_records.cpp'],
'fuzz_legacy_kv': ['fuzz_legacy_kv.cpp'],
'fuzz_telemetry_records': ['fuzz_telemetry_records.cpp'],
'fuzz_cmdline_redactor': ['fuzz_cmdline_redactor.cpp'],
'fuzz_tokenizer': ['fuzz_tokenizer.cpp'],
'fuzz_replay': ['fuzz_replay.cpp'],
'fuzz_trace_dsl': ['fuzz_trace_dsl.cpp'],
'fuzz_model_file': ['fuzz_model_file.cpp'],
'fuzz_rarity_state': ['fuzz_rarity_state.cpp'],
'fuzz_opensnitch_events': ['fuzz_opensnitch_events.cpp'],
'fuzz_procargs': ['fuzz_procargs.cpp'],
'fuzz_rule_partition': ['fuzz_rule_partition.cpp', '../src/rule_partition.cpp'],
}
foreach name, sources : fuzz_targets
extra = name == 'fuzz_ioc_list' ? [updater_feature_dep, yara_dep, yara_feature_dep] : []
executable(name, sources,
include_directories: inc_dirs,
dependencies: [strawberry_core_dep] + extra,
link_args: fuzz_args,
)
endforeach
# I/O-failure fuzzing: its sources are compiled with the fault injector on, so
# it does not link strawberry_core (whose objects have no injector).
executable('fuzz_io_faults',
'fuzz_io_faults.cpp', '../src/hash_utils.cpp', '../src/resource_governor.cpp',
include_directories: inc_dirs,
cpp_args: ['-DSTRAWBERRY_FAULT_INJECTION=1'],
dependencies: [openssl_dep, threads_dep],
link_args: fuzz_args,
)
if get_option('enable_mcp').allowed()
executable('fuzz_mcp_handle', 'fuzz_mcp_handle.cpp',
include_directories: inc_dirs,
link_with: strawberry_mcp_lib,
dependencies: [nlohmann_json_dep, strawberry_core_dep],
link_args: fuzz_args,
)
endif