strawberry/config/strawberry.conf
trvon db4c49155f
yara: rule partitions — scan each file only with the rules that can match it
Why YARA-X scanned ~1.6x faster than libyara (perf + source audit, 2026-11-14):
not the language — both spend ~5 s in the atom search loop — but verification
(libyara 2.0 s vs 0.3 s). YARA-X derives filesize bounds and header constraints
per rule at compile time and disables those patterns before the search, so their
atom hits are dropped with one bit test. In the yara-forge core pack 1787 rules
require an MZ header and 2498 bound filesize, so for big Linux ELFs most of
libyara's verification is wasted.

Rule partitioning gets the same win with libyara, and drops the rules' atoms from
the automaton entirely:
- src/rule_partition.cpp (pure): lexer-aware splitter (comments, text, regex
  after = or matches, hex), facts from TOP-LEVEL `and` terms only (MZ /
  pe.is_pe, ELF, Mach-O magic; filesize < / <=), exclusion per (MZ / non-MZ) x
  size bucket (<1, 1-4, 4-16, >=16 MiB). Global rules and rules referenced by
  kept rules always stay.
- YaraScanner builds subsets in a background thread after each load, in
  priority order (big non-PE first) under rule_partition_budget_pct (default
  100 ~ one extra full set: 3 subsets, +59 MiB; all 16 class x size subsets
  would cost +428 MiB). Cached under rules_cache_dir/partitions/. File, buffer
  and fd scans pick their subset; process-memory scans use the full set.
- Fails closed to the full rules: include directives, a split count that
  differs from libyara's, or a subset compile / count error.
- Status rules.partitions (state, reason, subsets, kept_rules/scans per
  partition, full_scans); config rule_partitions (default true) and
  rule_partition_budget_pct.

Measured on the 5132-rule pack: big ASan ELFs 1.64x, 1200 system binaries
1.59x, 0 match-set differences, including 348 positive files across
MZ/ELF/raw x small/5 MiB. Tests: splitter traps, facts, exclusion soundness
property, real pack = 5132 rules; differential test (24 file shapes x memory /
ranges / fd scans, every subset built) and fail-closed; bench --partitions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 06:58:39 -07:00

116 lines
5.8 KiB
Text

# Strawberry Security Scanner Configuration
# Evidence store: a directory of compressed segments (leave empty for the XDG
# default; the installed daemon uses /var/lib/strawberry/database.db).
db_path=
# Disk-space floor. Below max(store_min_free_mb, store_min_free_pct % of the
# disk) telemetry recording pauses (or, with evict_oldest_telemetry, the oldest
# telemetry is deleted); evidence keeps being saved until store_hard_min_free_mb.
#store_min_free_mb=2048
#store_min_free_pct=5
#store_hard_min_free_mb=256
#store_floor_action=pause
# Retention applies to telemetry only and is off (0 = unlimited) by default.
#store_retention_days=0
#store_max_mb=0
# Scheduled telemetry reduction (strawberry-reduce.timer). OFF by default.
# When true, strawberry-reduce.service periodically STOPS the daemon, runs
# 'store reduce' (drops dead-benign telemetry subtrees; evidence is untouched),
# and restarts it -- a short monitoring GAP during each run. This DROPS benign
# telemetry (a retention change); run the recall gate first. Enable the timer too:
# systemctl enable --now strawberry-reduce.timer
#store_reduce_enabled=false
# Fleet export egress (Salt pulls bundles from here). Off by default.
#export_dir=/var/lib/strawberry/export
# Local retention of synced bundles (reproducible, so pruning is safe):
#export_retention_hours=48 # delete bundles older than this (0 = off)
#export_max_mb=512 # evict oldest-first when the dir exceeds this (0 = off)
# Record every exec, scan, behavior event and exec-guard verdict (not only
# detections) in the root-only telemetry stream, for the learning stages.
#telemetry=true
# Redact secrets (passwords, tokens, URL credentials) from command lines
# before they are stored. Turn off only for debugging.
#capture_redact_cmdline=true
# When the rules or feeds change, re-scan binaries that ran here before (one
# file per retro_hunt_pace_ms, idle priority, held back while the host is
# busy). New matches show as findings and notify; nothing is blocked.
#retro_hunt=true
#retro_hunt_pace_ms=200
# Inspection model (Stage 4). `strawberry model train` writes
# <model_dir>/shadow.sbm; with model_shadow the daemon scores live windows
# with it and logs the inspections it would request. It acts on nothing.
#model_dir=/var/lib/strawberry/model
#model_shadow=true
# YARA settings
yara_rules_path=/etc/strawberry/rules
# Refuse to start if no rules compile (a scanner without rules detects nothing)
require_rules=true
# Fetch rule/IOC updates from upstreams (GitHub etc). Off on fleet nodes that
# receive pinned snapshots via the installer/Salt; keep on for standalone installs.
#rule_auto_fetch=true
# Daemon settings
daemonize=false
# pid_file/log_file are not implemented yet; under systemd, logs go to the journal
pid_file=/run/strawberry.pid
log_file=
# Process monitoring (despite the name, all backends): Linux prefers eBPF exec
# tracepoints and falls back to procfs polling; macOS prefers Endpoint
# Security and falls back to libproc polling.
enable_bpf_monitoring=true
# Scan processes that are already running at startup (both backends).
scan_existing_processes_on_start=true
# Control socket used by the desktop app, the CLI (--status, --rescan, ...)
# and strawberry-mcp. Members of control_group may connect.
control_socket_path=/run/strawberry/control.sock
control_group=strawberry
# Largest file an on-demand scan (scan-fd / strawberry_scan_paths) will read.
scan_max_bytes=67108864
# Largest executable image read for a process scan (larger ones are counted
# as images_too_large and skipped).
process_scan_max_bytes=268435456
# Rule feeds + allowlist live next to the database by default
# (/var/lib/strawberry/policy.json and /var/lib/strawberry/feeds/), and are
# managed from the desktop app (Rules / Allowlist tabs) or `strawberry --policy-set`.
policy_path=
feeds_dir=
# Node-local cache of the compiled YARA rules (rules.yrc + key). Skips the
# multi-second, memory-heavy compile on start/reload when no rule source and
# no libyara version changed. Root-only (0700 dir, 0600 files). Empty disables.
# rules_cache_dir=/var/lib/strawberry/rules-cache
# Exec guard: scan only the loaded ELF segments of images >= 4 MiB at launch (the pipeline still
# scans the whole file). ~8% faster launch decisions on 4-32 MiB binaries; off by default because
# strings that exist only in unloaded sections are not seen until the background scan.
# guard_loaded_segments_only=false
# Rule partitions: scan each file only with the rules that can match its type and size (same
# results, less work; built in the background after each rules load). On by default.
# rule_partitions=true
# Memory for those subsets: at most this % of the rule count in total (100 ~ one extra full set).
# rule_partition_budget_pct=100
# Optional root-only file with a GitHub token: raises the GitHub API limit the
# rule updater uses from 60 to 5000 requests/hour (only needed on shared IPs).
github_token_file=
# Resource governor: how hard Strawberry may work on this machine.
# efficient - laptops / busy desktops: 1 scan worker, 16 MB/s background
# reads, exec checks fall back to hash/IOC-only when busy
# balanced - default
# aggressive - servers with spare capacity: no read pacing, never degrades
# Background work (startup inventory, rescans, memory scans, correlation,
# rule reloads) waits while the host is under pressure (PSI) and always runs
# at least once per background_max_deferral_s. Program launches are never
# delayed by the governor.
scan_profile=balanced
# Per-scan YARA timeout in seconds (0 = profile: 5 / 10 / 30).
scan_timeout_seconds=0
# How often the governor samples CPU, memory and pressure (ms).
governor_tick_ms=1000
# Background read budget in MiB/s (0 = profile, -1 = unlimited).
max_scan_rate_mb_s=0
background_max_deferral_s=300
# Daemon memory budget in MiB (0 = profile; capped by the systemd MemoryMax).
memory_budget_mb=0