Architecture and Code Map¶
High-level flow¶
Diagram source: architecture-overview.mmd
- User triggers scan (CLI or API)
ToolManager(singleton viacore/deps.py) verifies/installs required tools- OS detection via
core/os_detect.py - OS-specific wrapper executes scanner (
LinuxWrapper/WindowsWrapper) - CIS-CAT logic on Linux extracted to
core/wrappers/ciscat_linux.py - Logs are streamed per-tool and persisted (
core/scan_logger.py, DB) - Results are stored in SQLite (
core/database.py) with lazy init, pagination,completed_at, anddelete_scan() - Tool output is parsed by
core/parsers/(oscap, lynis, hardeningkitty, ciscat) - Reports are generated by slim orchestrator
core/reporter.py(formerly split acrossreporter.py+report_gen.py, now merged) - Websocket broadcasts status/log updates to frontend (
core/comms.py, patched viacore/ws_patch.py)
Main modules¶
cli/ (package -- replaces former monolithic cli.py)¶
The CLI has been split into a package with focused submodules:
| Module | Responsibility |
|---|---|
cli/__init__.py | Typer app construction, top-level command wiring |
cli/styles.py | Rich console themes, shared style constants |
cli/menu.py | Interactive menu and UX loops |
cli/server.py | Server start/stop/status/logs wrappers |
cli/scan.py | Scan orchestration (run_quick_scan), --json, --exit-code, --quiet, --verbose, --only-failures |
cli/tools_cmd.py | tools status / tools install subcommands |
cli/history.py | History browsing and report export |
cli/elevation.py | Privilege elevation gating (ensure_root) |
New top-level commands: cis-tool doctor, cis-tool findings <id>.
main.py¶
- FastAPI app setup
- Routers mounted from
api/ - Static asset mounting (
frontend/css,frontend/js) - WebSocket endpoints and middleware
New shared modules in core/¶
| Module | Purpose |
|---|---|
core/deps.py | Singleton ToolManager instance |
core/constants.py | Shared regex patterns and magic values |
core/os_detect.py | Unified OS/distro/version detection (replaces scattered detection logic) |
core/ws_patch.py | WebSocket header-size and handshake patch |
core/tool_manager.py¶
- Package manager abstraction (
apt,dnf/yum,apk,pacman,zypper) - Version-aware package mapping via
core/tools_config.py - Windows Java prerequisite bootstrap for CIS-CAT
- Sanitized subprocess env for packaged runtime compatibility
core/wrappers/linux.py¶
- OpenSCAP content discovery and profile selection
- Runs
openscap,lynis,usg - CIS-CAT logic extracted to
core/wrappers/ciscat_linux.py
core/wrappers/ciscat_linux.py (new)¶
- CIS-CAT benchmark selection and execution on Linux
- Extracted from
linux.pyfor clarity
core/wrappers/windows.py¶
- Runs HardeningKitty (PowerShell)
- Runs SCT (
LGPO.exe) and CIS-CAT batch launcher
core/parsers/ (new package -- replaces parsing logic formerly in reporter.py)¶
| Module | Parses |
|---|---|
core/parsers/oscap.py | OpenSCAP XML ARF output |
core/parsers/lynis.py | Lynis .dat log files |
core/parsers/hardeningkitty.py | HardeningKitty CSV output |
core/parsers/ciscat.py | CIS-CAT results |
core/reporter.py (slim orchestrator)¶
- Aggregates parsed findings from
core/parsers/* - Generates consolidated PDF/HTML reports
report_gen.pyhas been merged into this module and deleted- Handles missing-tool report artifacts gracefully by inserting explicit error findings
core/database.py¶
- SQLite with WAL
- Lazy initialization (no module-level
init_db()call) completed_atcolumn for scan completion trackingdelete_scan(),count_scans(), pagination support
core/scan_logger.py¶
- Per-tool log files (not a single file per scan)
- Lazy directory initialization
core/logger.py¶
- Standard logging setup
- JSON logging mode via
LOG_FORMAT=jsonenvironment variable
api/*¶
scan.py: start/status/report, paginated status,DELETE /scan/{id},GET /scan/{id}/findings,GET /scan/{id}/timeline,GET /scan/{id}/logstools.py: install/statusreport.py: report/file download endpointsGET /api/healthendpoint
Version¶
The package version is read from importlib.metadata at runtime (not hardcoded). It is defined in pyproject.toml.
Frontend¶
Multi-page SPA with hash-based routing:
| Page | Description |
|---|---|
| Dashboard | KPI cards, compliance overview |
| Scans | Scan list with pagination, per-scan inline logs, modal log viewer |
| Tools | Tool status and install controls |
| Logs | Aggregated log browser |
Additional features: - Dark/light theme toggle - Toast notifications - CSV/JSON export - Consumes REST + WebSocket for real-time updates - Static assets under frontend/css and frontend/js
Packaging and release¶
- Project metadata in
pyproject.toml(nosetup.py;distroadded as dependency) - Docker: unified multi-stage Dockerfile using
uvfor fast, reproducible builds .github/workflows/release.ymlbuilds:- Linux DEB (Ubuntu 18.04 container for glibc compatibility)
- Linux AppImage
- Windows standalone EXE + installer
- PyInstaller includes both
templatesandfrontendresources
Deleted files¶
| File | Replacement |
|---|---|
cli.py (monolithic) | cli/ package |
core/report_gen.py | Merged into core/reporter.py |
setup.py | pyproject.toml |
Test/validation layers¶
- Unit/API tests in
tests/ - VM artifact validation pipeline in
scripts/+Vagrantfile - Multi-OS provisioning with per-VM test runners