Skip to content

Components ​

A detailed map of the software components and what each module is responsible for.

Detailed component architecture ​

Backend modules (cyberrange/src/provisioning/) ​

ModuleResponsibility
provision_api_fastapi.pyApp entry point: mounts routers, startup checks (auth config, capacity config, migrations), starts the TTL reaper and score poller, serves /health and /capacity
config.py, profiles.py, secrets_loader.pyEnvironment settings, deployment profiles (onprem, oci_12gib), secret resolution (environment, then SECRETS_FILE; Vault mode fails closed)
auth.py, introspect_cache.pyKeycloak token introspection, 60-second claims cache, role extraction, guards (require_app_role, require_role, require_owner, require_owner_or_admin)
pods_router.pyLab endpoints, Manual Check, progress, flag submission, rubrics, instructor views, knowledge-gain export, reviews, evidence images, internal browser-score callback
provision.pyBackground lab build and teardown, failure rollback
pod_net.pyPer-lab OVN networks, egress ACLs and peering; the Wazuh manager's return route to each lab; reconciler for orphans and for live labs' ACLs and routes
lab_proxy.pyLXD proxy devices that expose each lab's DVWA on port 18300 + pod_id
guest_nic.py, dvwa_compose.py, dvwa_ready.pyWait for container networking; make DVWA and its database ready
capacity.py, ttl.pyRAM and storage gates, capacity payload; lab expiry calculations
reaper.pyTTL expiry, stuck-lab recovery, storage drift purge, network reconciliation
score_poller.py, scoring.py, ssh_verifier.py, scoring_checks.shAutomatic and manual milestone verification inside containers
score_verifier.py, wazuh_rule_map.pySIEM detection evidence (rule fired for an agent)
scoring_diagnostics.pyInstructor-only, allow-listed failure reason codes per milestone, switched on per scenario, purged after a retention period
hybrid_scoring.py, rubrics.py, flag_planting.pyFlag submission path, rubric catalog, per-student HMAC flags
alerts_endpoint.py, alerts_reader.py, lab_history.pyStudent and instructor SIEM views, archived alerts for ended labs, alert snapshots frozen with reports
evidence_images.pyValidated, re-encoded evidence screenshots stored outside the release tree
users_router.py, keycloak_admin.pyAdmin-only account and role management through Keycloak's admin REST API; marking accounts as excluded from research data
onboarding_router.pyPer-user first-login orientation state
infra_health.pyAdmin health view of API, LXD, Keycloak and Wazuh
audit_router.pyAdmin read-only audit log
knowledge_gain.py, export_knowledge_gain.py, research_exclusions.pyResearch metrics export (completion, time to milestone, detection, rubric scores), leaving out Admin-marked test accounts and staff
wazuh_client.pyWazuh API: tokens, agent lookup and status, agent cleanup, stale-name and connected-agent checks that can stop a lab from becoming ACTIVE
models.pyPydantic request and response models
db.py, migrate.py, schema/v1.sql to v16.sqlSQLite connection settings and migrations (v11 orientation state, v12 Scenario 1 rubric text, v13 an unused booking table kept for history, v14 scoring diagnostics, v15 verification source, v16 research exclusions)
logging_config.pyText or JSON logs to stdout

Portal modules (cyberrange/portal/src/) ​

PathResponsibility
middleware.tsEdge protection: redirect to /login, /no-role, or /dashboard
lib/auth.tsNextAuth options: Keycloak provider, session strategy, token refresh, role decoding
lib/routeRoles.ts, lib/loginRouting.ts, components/auth/AuthGate.tsxRole requirements per path, landing page per role, safe post-login redirects, client-side mirror of the edge checks
lib/apiProxy.ts, app/api/**/route.tsBFF: forward to FastAPI with the user's bearer token
lib/api.tsTyped client used by pages and hooks to call the BFF routes
app/lab/dvwa/[[...path]]/route.ts, lib/dvwaProxy.ts, lib/dvwaScoreSignals.ts, lib/dvwaAutoLogin.tsDVWA reverse proxy with HTML and cookie rewriting, path allow-list, CSP, Scenario 2 attack detection and near-miss reason codes, and automatic DVWA sign-in
next.config.mjsResponse headers (framing, nosniff, referrer policy, no X-Powered-By), Image Optimization disabled, / redirect, dev rewrites
hooks/*Data hooks per feature (lab status polling, provisioning, progress, instructor and admin data)
components/scenario/*Scenario info, provisioning checklist, lab page (terminal, tasks, guide), Big Picture, SIEM viewer
components/terminal/*xterm.js integration and session manager
components/instructor/*, components/admin/*Instructor SIEM panels, lab history, review evidence; admin user modals
hooks/useScenarios.tsStatic scenario catalog: names, descriptions, milestones, points
public/scenarios/*.mdStudent guides

Supporting components ​

ComponentResponsibilitySource
bridge-src/bridge.pyTerminal WebSocket servercyberrange/bridge-src/
Golden imageskali-base, meta-base, dvwa-base LXD imagescyberrange/deploy/oci_build_goldens_arm64.sh, deploy/golden/
Host scriptsKeycloak realm and accounts, iptables fix for OCI, LXD peer wrapper, release pull and sync, Wazuh internal CA, API hardening and provisioner user, verification scriptscyberrange/deploy/host/
CI workflowsRelease build and promotion; portal type check on every pull request.github/workflows/ampere-release.yml, portal-typecheck.yml
Booking backendGoogle Apps Script for test-session bookings and notices; creates no accountscyberrange/booking/Code.gs
systemd unitsService definitions and validatorscyberrange/deploy/systemd/

Sources

cyberrange/src/provisioning/*.py, schema/README.md, cyberrange/portal/src/**, cyberrange/portal/next.config.mjs, cyberrange/bridge-src/bridge.py, cyberrange/deploy/**, cyberrange/booking/Code.gs, .github/workflows/*.yml.

Cyber Range capstone documentation (Capstone 2 · Group 2 · A4102). Documents main at commit 6971373.