strawberry/scripts/run_fuzzers.sh
trvon 8f6bd1d4e0
Some checks failed
Build and Test / build (debug, clang) (push) Has been cancelled
Build and Test / build (debug, gcc) (push) Has been cancelled
Build and Test / build (release, clang) (push) Has been cancelled
Build and Test / build (release, gcc) (push) Has been cancelled
Build and Test / macos (push) Has been cancelled
Build and Test / docker (push) Has been cancelled
Privacy: attribute tracker contacts to programs via OpenSnitch events
Second piece of tracker attribution (docs/tracker-attribution.md): which
programs reach domains on a trackers list. Advisory only: never a block,
never a finding (source invariant R11).

- OpenSnitch event listener: OpenSnitch's JSON "remote" logger is the
  hostname source (Strawberry's eBPF connects have none). It streams over
  TCP and cannot leave fields out, so events carry command lines and
  environments. The listener binds 127.0.0.1 at a port below 1024 (only
  root can), accepts only root-owned peers (/proc/net/tcp), bounds
  clients/object size/buffering, and reads only pid, uid, path,
  destination and action; arguments and environment are never copied.
- TrackerContacts: per program x domain, bounded at 20000 keys. A root-only
  tracker_contact telemetry record (type 25) on the first contact, then at
  most hourly with the count since.
- Status `privacy` block; control verb privacy-trackers; CLI
  `strawberry privacy trackers [--json]`.
- `strawberry opensnitch enable-events` adds the logger to OpenSnitch's
  config (with a .bak); the installer runs it when OpenSnitch is present,
  unless privacy_trackers=false. Config: privacy_trackers (default true),
  opensnitch_events (default 127.0.0.1:979).
- EasyPrivacy is a default trackers feed (GPL-3.0+ or CC-BY-SA-3.0,
  downloaded at run time).

Tests: E1-E7 (test_opensnitch_events: event fields, stream splitting,
peer uid, address rules, listener end to end, contacts and record, config
editor), the control verb, CLI translation and help, daemon status. New
fuzz_opensnitch_events (90 s clean).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 06:15:28 -06:00

33 lines
2 KiB
Bash
Executable file

#!/usr/bin/env bash
# Run each libFuzzer target for N seconds (default 60), one at a time, at low
# priority with a memory cap, keeping corpora in build/fuzz-corpus/<target>.
# Crashes land in build/fuzz-artifacts/<target>/ and fail the run.
set -uo pipefail
SECONDS_EACH="${1:-60}"
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
BUILD="${FUZZ_BUILD:-$ROOT/build/fuzz}"
status=0
for target in fuzz_io_faults fuzz_ioc_list fuzz_policy_apply fuzz_governor_parsers fuzz_status_snapshot fuzz_config fuzz_record_decoder fuzz_block_decoder fuzz_segment_reader fuzz_manifest fuzz_evidence_records fuzz_legacy_kv fuzz_telemetry_records fuzz_cmdline_redactor fuzz_tokenizer fuzz_replay fuzz_trace_dsl fuzz_model_file fuzz_rarity_state fuzz_opensnitch_events fuzz_procargs fuzz_mcp_handle; do
bin="$BUILD/fuzz/$target"
[ -x "$bin" ] || { echo "skip $target (not built)"; continue; }
corpus="$ROOT/build/fuzz-corpus/$target"
artifacts="$ROOT/build/fuzz-artifacts/$target/"
mkdir -p "$corpus" "$artifacts"
seeds="$ROOT/fuzz/seeds/$target"
echo "== $target (${SECONDS_EACH}s)"
# LeakSanitizer needs ptrace, which yama ptrace_scope >= 2 forbids for
# non-root; leak checks are off here (ASan/UBSan stay on).
# UBSan recovers by default, which can otherwise make a bad run exit 0.
UBSAN_OPTIONS="${UBSAN_OPTIONS:+$UBSAN_OPTIONS:}halt_on_error=1" \
ASAN_OPTIONS="${ASAN_OPTIONS:-detect_leaks=0}" nice -n 19 "$bin" -max_total_time="$SECONDS_EACH" -rss_limit_mb=1024 -malloc_limit_mb=512 -timeout=10 \
-artifact_prefix="$artifacts" -print_final_stats=1 "$corpus" $( [ -d "$seeds" ] && echo "$seeds" ) \
> "$ROOT/build/fuzz-artifacts/$target.log" 2>&1
rc=$?
grep -E "^stat::number_of_executed_units|^stat::peak_rss_mb|cov: " "$ROOT/build/fuzz-artifacts/$target.log" | tail -3
if [ $rc -ne 0 ]; then
echo "FAIL $target (exit $rc): see build/fuzz-artifacts/$target.log"
grep -E "ERROR|SUMMARY|runtime error" "$ROOT/build/fuzz-artifacts/$target.log" | head -5
status=1
fi
done
exit $status