Expand description
Content-safety gate for downloaded files — a small, pure-Rust “antivirus”.
Anything fetched from the open web is untrusted, so before a downloaded file is handed back to a caller it passes three checks, cheapest first:
- size cap — reject anything over the configured ceiling; an unbounded download is itself a resource-exhaustion surface.
- magic-byte sniff (
infer) — detect the file’s real type from its bytes. A file whose bytes are an executable but whose claimed Content-Type is a benign document (PDF, image, …) is a classic disguised-payload and is flagged. - signature scan (
yara_x) — VirusTotal’s pure-Rust YARA engine, run against a tiny embedded ruleset. Ships an EICAR signature so the gate is testable with the industry-standard harmless test file.
clamd signature-database scanning is intentionally not here — it needs
an external daemon and is an opt-in follow-up. This module is the always-on
baseline that runs anywhere, including CI.
Structs§
- Scan
Config - Knobs for
scan_bytes/scan_path. - Scan
Report - Outcome of a scan.
Enums§
- Verdict
- Verdict for a scanned buffer.
Constants§
- DEFAULT_
MAX_ BYTES - Default size ceiling: 100 MiB. Downloads larger than this are rejected before any scan.
Functions§
- scan_
bytes - Scan an in-memory buffer. Infallible — every failure mode is expressed as a
Verdict::Flaggedrather than an error, so the gate never silently lets a file through on a scanner hiccup. - scan_
path - Read
pathand scan its contents. Seescan_bytes.