man zabibucanary internals
How it works
One engine powers the CLI, the hook, and the website. It is pure and dependency-free: parse, detect, score, map, sign.
1. Parse
The engine decides what you gave it. If it looks like a unified diff (git output), it parses per-file hunks — additions, deletions, added lines. Anything else (a code block from an AI chat, notes) is treated as free text and scanned line by line. Normies never need to know the difference.
2. Detect
Each detector maps matched lines to a finding with a severity and a plain-English explanation:
| Detector | Severity | Catches |
|---|---|---|
| Secrets | critical | Credential-shaped strings, .env files in diffs |
| Injection | high | SQL built by gluing strings together |
| Dangerous code | high | eval(), shelling out with user text |
| Authorization | high | Auth, session, permission, middleware changes |
| Schema | high | Prisma schemas, migrations, .sql |
| Supply chain | medium | New dependencies, unpinned versions, lockfile churn |
| Infrastructure | medium | Dockerfiles, CI workflows, deploy configs |
| Accessibility | medium | Removed focus outlines, blocked zoom, div-onClick |
| Scope | medium | Diffs over 25 files or 500 net lines |
| Tests | info | Test changes alongside the diff — slightly lowers the score |
3. Score
Weighted sum: critical 34 · high 17 · medium 8 · low 3, minus up to 9 for accompanying tests, clamped to 0–100. Grades: A < 15, B < 30, C < 50, D < 70, E above. The verdict comes from the worst finding: any critical → Stop — fix these first; any high → Check carefully before using.
4. Map
Every finding projects onto five damage sectors — see the five sectors. Each sector gets a level 0–3 from the strongest finding that touches it, rendered as a radar, bars, and a findings-by-sector heat grid in both UIs.
5. Sign
An approval is an Ed25519 signature over analysisId | signer | signedAt, chained to the previous signature — starting from a fixed genesis. Change any record and every later signature fails.
sig[0] = Ed25519(priv, genesis | payload[0]) sig[1] = Ed25519(priv, sig[0] | payload[1]) ...
The private key stays where the approval happened; verification needs only the public key. That asymmetry is the entire point — a third party can check the record without being able to produce a fake one. When signer and verifier share a secret, anyone who can verify can also forge, and the whole chain can be regenerated from scratch. (An earlier version of Canary did exactly that with HMAC. It is kept in this paragraph only as a warning.)
A signature stops edits, not deletion: whoever holds the ledger file can always drop records and re-sign the remainder with the same key. So the head of the chain is fingerprinted, and the fingerprint is meant to be anchored somewhere you don't control — a signed commit, OpenTimestamps, a public log. Anchoring is the step that makes a wholesale rewrite detectable, and no amount of self-checking can replace it.
In the CLI the chain lives at ~/.zabibucanary/ledger.jsonl and the key at ~/.zabibucanary/approver.key. Export a portable proof with zabibucanary ledger export, and check one anywhere with zabibucanary ledger verify <file>.
What it deliberately does not do
- No model calls in the deterministic core — the engine is rules, reproducible and offline
- No telemetry, no accounts, no phone-home
- No code execution of the analyzed content