Commit graph

4 commits

Author SHA1 Message Date
trvon
09e6b441ae
Audit flow: add the clang static analyzer as a strict per-change gate
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
- scripts/analyze_changed.sh + `make analyze`: clang-check --analyze over the
  changed TUs via builddir/compile_commands.json (host build may be gcc; clang
  tolerates those flags), nice -n 19, 2 at a time. Strict by default (any
  analyzer diagnostic fails), ANALYZE_STRICT=0 reports only; ANALYZE_FILES/--all
  override selection. Results in build/audit/out/analyze.log.
- AGENTS.md "Per-change checks": new analyzer row, positioned as path-sensitive
  intra-TU analysis that complements fold's bounded symbolic cross-call pass and
  the syntactic invariants (run all three); YAMS index-at-checkpoint reminder.
- CLAUDE.md: analyzer added to the checks pointer + a Performance & C++ bullet
  (perf-kpi + Tracy/PerfStats).
- docs/prompts/PROMPT-strawberry-audit.md: "Clang static analyzer" subsection
  under Symbolic SAST.

No C++ changed; unit suite 50/50 green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-28 09:55:03 -06:00
trvon
bf1e779706
CLI: safe terminal output, completions, no accidental daemons; UX guide
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 / docker (push) Has been cancelled
- Evidence strings are attacker-controlled: every CLI command's stdout
  and stderr now pass through a filter that shows control characters
  (C0, DEL, C1) and invalid UTF-8 as \xNN (src/term_safe.hpp), so a
  crafted process name or path cannot inject terminal escape sequences.
  The daemon's journal output is unchanged.
- `strawberry` alone prints help; an unknown word (`strawberry fix`) is an
  error with a "did you mean" hint. Both used to start a daemon as the
  calling user with the word as its config path. Config paths (contain
  '/' or end in .conf) still run the daemon, for older units.
- Shell completions generated from the command table: `strawberry
  completion bash|zsh|fish`; install.sh installs them under
  /usr/local/share.
- One correlation pass at daemon start (stored findings catch up with the
  current rules, e.g. stable ids), and retire-superseded-findings
  correlates first, so replacements exist before old copies are retired.
  The user's first run reported "no duplicates" for that reason.
- docs/cli-ux.md: CLI UX rules adapted from yams (grammar, flags, human
  and JSON output, status words, security rules for output, help and
  completions, adding a command, known gaps). Exit code 3 and
  confirmation prompts are proposed there, pending a decision. AGENTS.md
  and CLAUDE.md point to it.

tests/test_cli.cpp: bare and unknown words, terminal_safe and the stream
filter, completion scripts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 09:41:19 -06:00
trvon
648457802a
Forbid empty catch blocks
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 / docker (push) Has been cancelled
Every catch now handles the exception or records it with
STRAWBERRY_NOTE_SWALLOWED() (strawberry/swallowed.hpp): an atomic count,
exported in status as resources.swallowed_exceptions, plus a file:line
log line written with write(2), so it is safe out of memory and in
destructors. The 16 empty catches (store error fallbacks, destructors,
YARA compiler callback, thread entry logging) now use it. Status also
reports thread_errors, which was counted but never exported.

Enforced by source invariant R7 (with a self-test fixture) and by
clang-tidy bugprone-empty-catch in a new .clang-tidy (errors; inherits
parent config). AGENTS.md and CLAUDE.md state the rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 18:52:45 -06:00
trvon
6628ea9aea
Harden against crashes and I/O faults
Fix for the 2026-10-25 host freeze (an uncaught iostream exception on a
/proc read aborted the daemon; its core dump deadlocked with the exec
guard): non-throwing /proc reads, crash handlers that release fanotify
permission fds, guarded thread entries, from_chars parsing.

Adds the io fault-injection seam with property tests, source invariant
checks (R1-R6) with self-test fixtures, libFuzzer targets and seeds
(including I/O-fault fuzzing), the fold changed-files scan scripts and
the agent workflow docs (CLAUDE.md, prompts).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 18:17:17 -06:00