"""Custom Gradio tab for OpenRange — cybersecurity range dashboard.
Renders a network topology visualization, live action feed, flag status,
and reward dashboard as a custom tab alongside the default OpenEnv Playground.
Signature matches the gradio_builder contract from OpenEnv.
"""
from __future__ import annotations
from typing import Any, Dict, List, Optional
import gradio as gr
def _range_dashboard_html() -> str:
"""Static HTML for the OpenRange dashboard overview."""
return """
Flags
🚩
FLAG{...} — Web Application
pending
🚩
FLAG{...} — Database
pending
Use the Playground tab to reset and interact. Flags update after submit_flag.
"""
def build_openrange_gradio_app(
web_manager: Any,
action_fields: List[Dict[str, Any]],
metadata: Any,
is_chat_env: bool,
title: str,
quick_start_md: str,
) -> gr.Blocks:
"""Build the Custom tab for OpenRange: network topology + dashboard.
Signature matches the gradio_builder contract (see OpenEnv docs).
"""
with gr.Blocks(title=f"{title} — Range Dashboard") as blocks:
gr.Markdown("# Range Dashboard")
gr.Markdown(
"This tab shows the **network topology**, reward signals, and flag status. "
"Use the **Playground** tab to Reset and Step with commands "
"(e.g. `nmap -sV 10.0.1.0/24`)."
)
gr.HTML(value=_range_dashboard_html())
return blocks