Skip to main content

Module scanner

Module scanner 

Source
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:

  1. size cap — reject anything over the configured ceiling; an unbounded download is itself a resource-exhaustion surface.
  2. 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.
  3. 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§

ScanConfig
Knobs for scan_bytes / scan_path.
ScanReport
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::Flagged rather than an error, so the gate never silently lets a file through on a scanner hiccup.
scan_path
Read path and scan its contents. See scan_bytes.