How choi-sslkd/endpoint_anti_virus_mvp_rust works
Project type and purpose
• This is a Rust-based, modular CLI application (“Endpoint Anti Virus MVP”) that performs file scanning using both signature-based and heuristic-based detection, plus update, quarantine, and scheduling capabilities.
• It is a monolithic, modular design (not distributed-service), organized into independent modules for scanner, engine, quarantine, and updater.
File structure
• Top-level files:
• Cargo.toml – Cargo dependencies and metadata
• README.md – project description and instructions
• data/signatures.json – raw signature data
• src/main.rs – application entrypoint and CLI interface
• src/scanner/ – core detection logic: signature.rs, heuristics.rs, mod.rs (FileScanner, ScanResult)
• src/engine/ – orchestrates scanning, logging, scheduling: scheduler.rs, logging.rs, mod.rs (Engine)
• src/quarantine/ – file-isolation logic
• src/updater/ – signature loader logic
Key insights from README
• FileScanner sums signature match and heuristic scores and returns a risk score.
• Engine’s scheduler dispatches scan tasks, applies a risk threshold, and triggers quarantine.
• Updater loads and parses data/signatures.json at startup.
• Modules are independent for easy extension (e.g., eBPF, network telemetry, UI).
Main components & interactions
a. Components
1. CLI Frontend (main.rs)
2. Engine Module
– Scheduler
– Logger
3. Scanner Module
– Signature Matcher
– Heuristics Analyzer
4. Updater Module (loads signatures.json)
5. Quarantine Module
6. Data Store (signatures.json)
b. Relationships & Data Flow
1. CLI invokes Engine.init() and passes file/directory paths.
2. Engine’s Scheduler enqueues scan tasks for each path.
3. Each task calls Scanner.scan(file):
– Scanner requests signature patterns (injected by Updater).
– Signature Matcher & Heuristics Analyzer compute risk score.
– Scanner returns ScanResult to Engine.
4. Engine compares score against threshold:
– If below: log “clean”
– If above: call Quarantine.isolate(file)
5. Updater loads signatures.json at startup (or on demand) and populates in-memory patterns for Scanner.
c. Architectural patterns & design principles
• Modular separation of concerns (Updater, Scanner, Engine, Quarantine)
• Single responsibility per module
• Dependency injection: Updater → Scanner
• Task scheduling queue in Engine
d. Technologies & libraries
• Rust (Cargo)
• JSON parsing (serde_json)
• CLI argument parsing (clap or std::env)
• Simple file I/O and logging