feat(dashboard): add demo targets, fix MCP status, source-only UI
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 6m46s

Three things a prospect would have hit in the Pruefwerk dashboard:

- An empty workspace had no way in. The Targets page and the onboarding
  wizard now offer "Add demo targets", which calls the agent's demo-seed
  endpoint and reports per target whether it was created, already there
  or failed.
- The MCP server card never turned "running" on staging: the health URL
  was derived by appending /health to an endpoint that already ends in
  /mcp, which the ingress routes to a server serving /health at its root.
  The probe now tries both, and MCP_HEALTH_URL overrides it outright for
  the seeded cards.
- Where the agent reports the source_only feature, dynamic testing,
  pentest, the ICS probe and the PLC runtime are hidden with a short note
  instead of offering actions that cannot work, and stages the pipeline
  reports as skipped for that reason read neutral rather than failed.

The findings table also shows the control-mapping column only when
something in view actually carries control references.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
This commit is contained in:
Sharang ParnerkarandClaude Opus 5 authored and Sharang Parnerkar committed 2026-09-14 08:09:05 +00:00
1 parent 728f3ab3bc
commit 35fba487f2
21 files changed
+1135 -41

No files matched your search

+5
View File
@@ -79,6 +79,11 @@ AGENT_API_URL=http://localhost:3001
# MCP Server
MCP_ENDPOINT_URL=http://localhost:8090
# Absolute health URL for the default MCP server card. Set it where an ingress
# routes /mcp/* to a server that serves /health at its own root (staging:
# https://pruefwerk-stage.breakpilot.com/mcp/health). Derived from
# MCP_ENDPOINT_URL when unset.
# MCP_HEALTH_URL=
# Keycloak (required for authentication)
KEYCLOAK_URL=http://localhost:8080
+15
View File
@@ -298,6 +298,13 @@ code {
flex-shrink: 0;
}
/* Runtime-only surfaces (DAST, pentest) when the agent runs source-only. */
.nav-item.disabled {
opacity: 0.4;
cursor: not-allowed;
pointer-events: none;
}
.nav-item:hover {
background: rgba(0, 200, 255, 0.06);
color: var(--text-primary);
@@ -794,6 +801,14 @@ tbody tr:last-child td {
border-color: rgba(0, 230, 118, 0.2);
}
/* Neutral: skipped because a feature is disabled in this environment — not an error. */
.badge-neutral {
background: transparent;
color: var(--text-secondary);
border-color: var(--border-bright);
border-style: dashed;
}
/* ── Buttons ── */
@@ -6,11 +6,22 @@ use crate::components::notification_bell::NotificationBell;
use crate::components::sidebar::Sidebar;
use crate::components::toast::{ToastContainer, Toasts};
use crate::infrastructure::auth_check::check_auth;
use crate::infrastructure::platform::{fetch_platform_info, PlatformInfo};
#[component]
pub fn AppShell() -> Element {
use_context_provider(Toasts::new);
// Agent contract handshake (features such as `source_only`). Provided
// app-wide so pages can hide runtime-only surfaces; defaults to the
// full feature set until the agent answers.
let mut platform = use_context_provider(|| Signal::new(PlatformInfo::default()));
use_future(move || async move {
if let Ok(info) = fetch_platform_info().await {
platform.set(info);
}
});
let auth = use_server_future(check_auth)?;
match auth() {
@@ -0,0 +1,241 @@
//! "Add demo targets" — one-click seeding of the versioned demo-target
//! manifest (`GET/POST /api/v1/targets/demo-seed`).
//!
//! Renders a button that opens a confirm panel listing the manifest
//! targets (pre-selected according to the agent's `source_only` feature),
//! POSTs the selection, and then shows the per-target outcome with links to
//! the targets list and the findings page.
use dioxus::prelude::*;
use crate::app::Route;
use crate::infrastructure::onboarding::{
demo_seed_default_selection, demo_seed_outcome, fetch_demo_seed_targets, seed_demo_targets,
DemoSeedResult, DemoSeedTarget,
};
use crate::infrastructure::platform::{use_source_only, SOURCE_ONLY_NOTE};
/// Human label for a manifest target kind.
fn kind_label(kind: &str) -> &str {
match kind {
"plc_sps" => "PLC / SPS",
"backend_service" => "Backend / API",
"web_app" => "Web application",
"firmware_rtos" => "Firmware (RTOS)",
"firmware_bare_metal" => "Firmware (bare metal)",
"embedded_linux_yocto" => "Embedded Linux",
other => other,
}
}
#[component]
pub fn DemoTargetsButton(
/// Optional callback after a successful seed (e.g. reload the list).
#[props(default)]
on_seeded: Option<EventHandler<()>>,
/// Render as a secondary (outline) button instead of primary.
#[props(default)]
secondary: bool,
) -> Element {
let source_only = use_source_only();
let mut open = use_signal(|| false);
let mut selected = use_signal(Vec::<String>::new);
let mut submitting = use_signal(|| false);
let mut error = use_signal(|| Option::<String>::None);
let mut results = use_signal(|| Option::<Vec<DemoSeedResult>>::None);
let manifest = use_resource(move || async move {
if open() {
Some(fetch_demo_seed_targets().await)
} else {
None
}
});
// Pre-select the usable targets once the manifest arrives.
let mut initialised = use_signal(|| false);
use_effect(move || {
if let Some(Some(Ok(list))) = &*manifest.read() {
if !initialised() {
selected.set(demo_seed_default_selection(&list.targets, source_only));
initialised.set(true);
}
}
});
let btn_class = if secondary {
"btn btn-secondary"
} else {
"btn btn-primary"
};
let close = move |_| {
open.set(false);
results.set(None);
error.set(None);
initialised.set(false);
};
rsx! {
button {
class: "{btn_class}",
title: "Seed the versioned demo targets and queue their first scan",
onclick: move |_| open.set(true),
"Add demo targets"
}
if open() {
div { class: "modal-overlay",
div { class: "modal-dialog demo-targets-dialog", style: "max-width: 640px;",
h3 { "Add demo targets" }
if let Some(res) = results() {
DemoSeedResults { results: res }
div { class: "modal-actions",
Link { to: Route::TargetsPage {}, class: "btn btn-secondary", "Targets list" }
Link { to: Route::FindingsPage {}, class: "btn btn-secondary", "Findings" }
button { class: "btn btn-primary", onclick: close, "Done" }
}
} else {
p { style: "color: var(--text-secondary);",
"Seeds the versioned demo set as targets (named "
code { "Demo · <name>" }
") and queues a first scan of each. Targets that already exist are left untouched."
}
if source_only {
p { style: "color: var(--text-secondary); font-size: 0.9em;",
"This environment runs "
strong { "source-only" }
" — targets that need a live URL or device are not selectable."
}
}
match &*manifest.read() {
Some(Some(Ok(list))) => {
let targets = list.targets.clone();
rsx! {
div { class: "demo-targets-list", style: "display: flex; flex-direction: column; gap: 6px; margin: 12px 0;",
for t in targets {
DemoTargetRow {
target: t.clone(),
checked: selected().contains(&t.name),
disabled: source_only && !t.source_only,
on_toggle: move |name: String| {
let mut v = selected();
if let Some(p) = v.iter().position(|n| n == &name) {
v.remove(p);
} else {
v.push(name);
}
selected.set(v);
},
}
}
}
}
}
Some(Some(Err(e))) => rsx! {
div { style: "color: var(--danger); font-size: 0.9em; margin: 12px 0;",
"Could not load the demo manifest: {e}"
}
},
_ => rsx! { div { class: "loading", "Loading manifest..." } },
}
if let Some(err) = error() {
div { style: "color: var(--danger); font-size: 0.9em; margin-bottom: 8px;", "{err}" }
}
div { class: "modal-actions",
button { class: "btn btn-secondary", disabled: submitting(), onclick: close, "Cancel" }
button {
class: "btn btn-primary",
disabled: submitting() || selected().is_empty(),
onclick: move |_| {
let names = selected();
submitting.set(true);
error.set(None);
spawn(async move {
match seed_demo_targets(names, false).await {
Ok(resp) => {
results.set(Some(resp.seeded));
if let Some(cb) = on_seeded {
cb.call(());
}
}
Err(e) => error.set(Some(e.to_string())),
}
submitting.set(false);
});
},
if submitting() { "Adding..." } else { "Add {selected().len()} target(s)" }
}
}
}
}
}
}
}
}
#[component]
fn DemoTargetRow(
target: DemoSeedTarget,
checked: bool,
disabled: bool,
on_toggle: EventHandler<String>,
) -> Element {
let name = target.name.clone();
let style = if disabled {
"display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); opacity: 0.55;"
} else {
"display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);"
};
rsx! {
label { style: "{style}",
input {
r#type: "checkbox",
checked: checked && !disabled,
disabled: disabled,
onchange: move |_| on_toggle.call(name.clone()),
}
div { style: "flex: 1; min-width: 0;",
div { style: "display: flex; gap: 8px; align-items: center; flex-wrap: wrap;",
strong { "{target.name}" }
span { class: "badge", "{kind_label(&target.kind)}" }
if disabled {
span { class: "badge badge-neutral", title: "{SOURCE_ONLY_NOTE}", "needs runtime — {SOURCE_ONLY_NOTE}" }
}
}
if !target.description.is_empty() {
div { style: "font-size: 0.85em; color: var(--text-secondary); margin-top: 2px;", "{target.description}" }
}
}
}
}
}
#[component]
fn DemoSeedResults(results: Vec<DemoSeedResult>) -> Element {
let queued = results.iter().filter(|r| r.status == "queued").count();
let exists = results.iter().filter(|r| r.status == "exists").count();
let failed = results.iter().filter(|r| r.status == "failed").count();
rsx! {
p { style: "color: var(--text-secondary);",
"{queued} added, {exists} already added, {failed} failed."
if queued > 0 {
" Scans run in the background — findings appear as they complete."
}
}
div { style: "display: flex; flex-direction: column; gap: 6px; margin: 12px 0;",
for r in results {
{
let (cls, label) = demo_seed_outcome(&r);
rsx! {
div { style: "display: flex; gap: 10px; align-items: center; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);",
strong { style: "flex: 1;", "{r.name}" }
span { class: "{cls}", "{label}" }
}
}
}
}
}
}
}
@@ -3,6 +3,7 @@ pub mod attack_chain;
pub mod code_inspector;
pub mod code_snippet;
pub mod copy_button;
pub mod demo_targets;
pub mod file_tree;
pub mod help_chat;
pub mod notification_bell;
+26 -1
View File
@@ -5,58 +5,70 @@ use dioxus_free_icons::Icon;
use crate::app::Route;
use crate::components::theme_toggle::ThemeToggle;
use crate::infrastructure::platform::{use_source_only, SOURCE_ONLY_NOTE};
struct NavItem {
label: &'static str,
route: Route,
icon: Element,
/// Needs a runtime (browser / live target); disabled in source-only mode.
runtime_only: bool,
}
#[component]
pub fn Sidebar() -> Element {
let current_route = use_route::<Route>();
let mut collapsed = use_signal(|| true);
let source_only = use_source_only();
let nav_items = [
NavItem {
label: "Overview",
route: Route::OverviewPage {},
icon: rsx! { Icon { icon: BsSpeedometer2, width: 18, height: 18 } },
runtime_only: false,
},
NavItem {
label: "Targets",
route: Route::TargetsPage {},
icon: rsx! { Icon { icon: BsFolder2Open, width: 18, height: 18 } },
runtime_only: false,
},
NavItem {
label: "Onboard",
route: Route::OnboardingPage {},
icon: rsx! { Icon { icon: BsPlusCircle, width: 18, height: 18 } },
runtime_only: false,
},
NavItem {
label: "Findings",
route: Route::FindingsPage {},
icon: rsx! { Icon { icon: BsShieldExclamation, width: 18, height: 18 } },
runtime_only: false,
},
NavItem {
label: "SBOM",
route: Route::SbomPage {},
icon: rsx! { Icon { icon: BsBoxSeam, width: 18, height: 18 } },
runtime_only: false,
},
NavItem {
label: "Issues",
route: Route::IssuesPage {},
icon: rsx! { Icon { icon: BsListTask, width: 18, height: 18 } },
runtime_only: false,
},
NavItem {
label: "DAST",
route: Route::DastOverviewPage {},
icon: rsx! { Icon { icon: BsBug, width: 18, height: 18 } },
runtime_only: true,
},
NavItem {
label: "Pentest",
route: Route::PentestDashboardPage {},
icon: rsx! { Icon { icon: BsLightningCharge, width: 18, height: 18 } },
runtime_only: true,
},
];
@@ -87,14 +99,27 @@ pub fn Sidebar() -> Element {
(Route::PentestSessionPage { .. }, Route::PentestDashboardPage {}) => true,
(a, b) => a == b,
};
let class = if is_active { "nav-item active" } else { "nav-item" };
let disabled = source_only && item.runtime_only;
let class = if disabled {
"nav-item disabled"
} else if is_active {
"nav-item active"
} else {
"nav-item"
};
let title = if disabled { SOURCE_ONLY_NOTE } else { item.label };
rsx! {
Link {
to: item.route.clone(),
class: class,
title: "{title}",
aria_disabled: disabled,
{item.icon}
if !collapsed() {
span { "{item.label}" }
if disabled {
span { style: "font-size: 0.7em; opacity: 0.8; margin-left: auto;", "n/a" }
}
}
}
}
@@ -22,6 +22,12 @@ pub struct FindingsQuery {
pub sort_order: String,
}
/// The control-mapping column is only shown when at least one finding in the
/// current view carries `control_refs`.
pub fn has_control_refs(findings: &[Finding]) -> bool {
findings.iter().any(|f| !f.control_refs.is_empty())
}
#[server]
pub async fn fetch_findings(query: FindingsQuery) -> Result<FindingsListResponse, ServerFnError> {
let mut path = format!("/api/v1/findings?page={}&limit=20", query.page);
@@ -119,3 +125,34 @@ pub async fn update_finding_feedback(id: String, feedback: String) -> Result<(),
.map_err(|e| ServerFnError::new(e.to_string()))?;
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
use compliance_core::models::{ScanType, Severity};
fn finding(refs: &[&str]) -> Finding {
let mut f = Finding::new(
"repo".into(),
"fp".into(),
"semgrep".into(),
ScanType::Sast,
"t".into(),
"d".into(),
Severity::Low,
);
f.control_refs = refs.iter().map(|s| s.to_string()).collect();
f
}
#[test]
fn control_column_hidden_without_refs() {
assert!(!has_control_refs(&[]));
assert!(!has_control_refs(&[finding(&[]), finding(&[])]));
}
#[test]
fn control_column_shown_when_any_finding_mapped() {
assert!(has_control_refs(&[finding(&[]), finding(&["cra-ai-8"])]));
}
}
+121 -13
View File
@@ -113,6 +113,42 @@ pub async fn add_mcp_server(
Ok(())
}
/// The `endpoint_url` the seeded default MCP server cards carry for a
/// given `MCP_ENDPOINT_URL` (mirrors `server::seed_default_mcp_servers`).
pub fn seeded_mcp_endpoint(mcp_endpoint_url: &str) -> String {
format!("{}/mcp", mcp_endpoint_url.trim_end_matches('/'))
}
/// Health URLs to probe for an MCP server, in order. The first 2xx wins.
///
/// * `override_url` (`MCP_HEALTH_URL`) is used verbatim for the seeded
/// servers (those whose endpoint equals `seeded_endpoint`); it exists for
/// deployments where an ingress strips the `/mcp` prefix (staging:
/// `https://host/mcp/health` → compliance-mcp's `/health`).
/// * Otherwise, for an endpoint ending in `/mcp`, probe `…/mcp/health`
/// first (prefix-routed ingress) and fall back to `…/health` (a directly
/// reachable compliance-mcp process, which serves `/health` at its root).
/// * Any other endpoint probes `<endpoint>/health`.
pub fn mcp_health_url_candidates(
endpoint_url: &str,
seeded_endpoint: Option<&str>,
override_url: Option<&str>,
) -> Vec<String> {
let base = endpoint_url.trim_end_matches('/');
let is_seeded = seeded_endpoint
.map(|s| s.trim_end_matches('/') == base)
.unwrap_or(false);
if let Some(o) = override_url.map(str::trim).filter(|o| !o.is_empty()) {
if is_seeded {
return vec![o.to_string()];
}
}
match base.strip_suffix("/mcp") {
Some(root) if !root.is_empty() => vec![format!("{base}/health"), format!("{root}/health")],
_ => vec![format!("{base}/health")],
}
}
/// Probe each MCP server's health endpoint and update status in MongoDB.
#[server]
pub async fn refresh_mcp_status() -> Result<(), ServerFnError> {
@@ -135,6 +171,14 @@ pub async fn refresh_mcp_status() -> Result<(), ServerFnError> {
.build()
.map_err(|e| ServerFnError::new(e.to_string()))?;
// The endpoint the default (seeded) MCP server cards point at — the
// explicit `MCP_HEALTH_URL` override applies to exactly those.
let seeded_endpoint = state
.config
.mcp_endpoint_url
.as_deref()
.map(seeded_mcp_endpoint);
while cursor
.advance()
.await
@@ -146,20 +190,29 @@ pub async fn refresh_mcp_status() -> Result<(), ServerFnError> {
let Some(oid) = server.id else { continue };
// Derive health URL from the endpoint (replace trailing /mcp with /health)
let health_url = if server.endpoint_url.ends_with("/mcp") {
format!(
"{}health",
&server.endpoint_url[..server.endpoint_url.len() - 3]
)
} else {
format!("{}/health", server.endpoint_url.trim_end_matches('/'))
};
let candidates = mcp_health_url_candidates(
&server.endpoint_url,
seeded_endpoint.as_deref(),
state.mcp_health_url.as_deref(),
);
let new_status = match client.get(&health_url).send().await {
Ok(resp) if resp.status().is_success() => McpServerStatus::Running,
_ => McpServerStatus::Stopped,
};
let mut new_status = McpServerStatus::Stopped;
for health_url in &candidates {
match client.get(health_url).send().await {
Ok(resp) if resp.status().is_success() => {
new_status = McpServerStatus::Running;
break;
}
Ok(resp) => tracing::debug!(
"MCP probe {health_url} for '{}' returned {}",
server.name,
resp.status()
),
Err(e) => {
tracing::debug!("MCP probe {health_url} for '{}' failed: {e}", server.name)
}
}
}
let status_bson = match bson::to_bson(&new_status) {
Ok(b) => b,
@@ -224,3 +277,58 @@ pub async fn regenerate_mcp_token(server_id: String) -> Result<String, ServerFnE
Ok(new_token)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn staging_mcp_endpoint_probes_prefixed_health_first() {
let c = mcp_health_url_candidates("https://pruefwerk-stage.breakpilot.com/mcp", None, None);
assert_eq!(
c,
vec![
"https://pruefwerk-stage.breakpilot.com/mcp/health".to_string(),
"https://pruefwerk-stage.breakpilot.com/health".to_string(),
]
);
}
#[test]
fn local_mcp_endpoint_keeps_root_health_fallback() {
let c = mcp_health_url_candidates("http://localhost:8090/mcp/", None, None);
assert_eq!(
c,
vec![
"http://localhost:8090/mcp/health".to_string(),
"http://localhost:8090/health".to_string(),
]
);
}
#[test]
fn plain_endpoint_appends_health() {
let c = mcp_health_url_candidates("https://mcp.example.com/", None, None);
assert_eq!(c, vec!["https://mcp.example.com/health".to_string()]);
}
#[test]
fn override_applies_to_seeded_servers_only() {
let seeded = seeded_mcp_endpoint("https://pruefwerk-stage.breakpilot.com");
assert_eq!(seeded, "https://pruefwerk-stage.breakpilot.com/mcp");
let o = Some("https://pruefwerk-stage.breakpilot.com/mcp/health");
assert_eq!(
mcp_health_url_candidates(&seeded, Some(&seeded), o),
vec!["https://pruefwerk-stage.breakpilot.com/mcp/health".to_string()]
);
// A user-registered server elsewhere is not affected by the override.
let other = mcp_health_url_candidates("https://mcp.other.example/mcp", Some(&seeded), o);
assert_eq!(other[0], "https://mcp.other.example/mcp/health");
assert_eq!(other.len(), 2);
// Empty override is ignored.
assert_eq!(
mcp_health_url_candidates(&seeded, Some(&seeded), Some(" ")).len(),
2
);
}
}
@@ -12,6 +12,7 @@ pub mod mcp_tokens;
pub mod notifications;
pub mod onboarding;
pub mod pentest;
pub mod platform;
#[allow(clippy::too_many_arguments)]
pub mod repositories;
pub mod sbom;
@@ -39,6 +39,79 @@ pub struct ApplicableScansResponse {
pub data: ApplicableScansData,
}
/// One entry of the demo-target manifest (`GET /api/v1/targets/demo-seed`).
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
pub struct DemoSeedTarget {
pub name: String,
#[serde(default)]
pub kind: String,
#[serde(default)]
pub description: String,
/// The target only needs source artifacts (no live URL / device) and is
/// therefore usable when the agent runs in `source_only` mode.
#[serde(default)]
pub source_only: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct DemoSeedListResponse {
#[serde(default)]
pub targets: Vec<DemoSeedTarget>,
}
/// Per-target outcome of `POST /api/v1/targets/demo-seed`.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
pub struct DemoSeedResult {
pub name: String,
#[serde(default)]
pub target_id: Option<String>,
#[serde(default)]
pub scan_id: Option<String>,
/// `queued` | `exists` | `failed`
#[serde(default)]
pub status: String,
#[serde(default)]
pub error: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct DemoSeedResponse {
#[serde(default)]
pub seeded: Vec<DemoSeedResult>,
}
/// Visual outcome of one seeded demo target: (badge class, label).
pub fn demo_seed_outcome(result: &DemoSeedResult) -> (&'static str, String) {
match result.status.as_str() {
"queued" => {
if result.scan_id.is_some() {
("badge badge-success", "added — scan queued".to_string())
} else {
("badge badge-success", "added".to_string())
}
}
"exists" => ("badge badge-info", "already added".to_string()),
"failed" => (
"badge badge-danger",
match result.error.as_deref().filter(|e| !e.trim().is_empty()) {
Some(e) => format!("failed: {e}"),
None => "failed".to_string(),
},
),
other => ("badge", other.to_string()),
}
}
/// Which manifest targets the seed panel should pre-select: every target,
/// unless the agent runs source-only — then only the source-only ones.
pub fn demo_seed_default_selection(targets: &[DemoSeedTarget], source_only: bool) -> Vec<String> {
targets
.iter()
.filter(|t| !source_only || t.source_only)
.map(|t| t.name.clone())
.collect()
}
/// Validate a target name. The name is used as the clone directory downstream,
/// so it must be a single safe segment (no slashes) and free of stray spaces.
pub fn validate_target_name(name: &str) -> Option<String> {
@@ -113,6 +186,52 @@ pub async fn fetch_targets() -> Result<TargetsResponse, ServerFnError> {
.map_err(|e| ServerFnError::new(e.to_string()))
}
/// List the demo-target manifest the agent can seed.
#[server]
pub async fn fetch_demo_seed_targets() -> Result<DemoSeedListResponse, ServerFnError> {
let resp = super::agent_client::agent_get("/api/v1/targets/demo-seed")
.await?
.send()
.await
.map_err(|e| ServerFnError::new(e.to_string()))?;
if !resp.status().is_success() {
let status = resp.status();
let body = resp.text().await.unwrap_or_default();
return Err(ServerFnError::new(format!(
"agent returned {status} for demo-seed manifest: {body}"
)));
}
resp.json()
.await
.map_err(|e| ServerFnError::new(e.to_string()))
}
/// Seed the named demo targets (empty = all) and queue their first scan.
#[server]
pub async fn seed_demo_targets(
names: Vec<String>,
rescan: bool,
) -> Result<DemoSeedResponse, ServerFnError> {
let body = serde_json::json!({ "names": names, "rescan": rescan });
let resp =
super::agent_client::agent_request(reqwest::Method::POST, "/api/v1/targets/demo-seed")
.await?
.json(&body)
.send()
.await
.map_err(|e| ServerFnError::new(e.to_string()))?;
if !resp.status().is_success() {
let status = resp.status();
let body = resp.text().await.unwrap_or_default();
return Err(ServerFnError::new(format!(
"agent returned {status} for demo-seed: {body}"
)));
}
resp.json()
.await
.map_err(|e| ServerFnError::new(e.to_string()))
}
/// Create a target with the collected artifacts.
#[server]
pub async fn create_target(
@@ -286,3 +405,71 @@ pub async fn trigger_target_scan(id: String) -> Result<serde_json::Value, Server
.await
.map_err(|e| ServerFnError::new(e.to_string()))
}
#[cfg(test)]
mod tests {
use super::*;
fn result(status: &str, scan: Option<&str>, error: Option<&str>) -> DemoSeedResult {
DemoSeedResult {
name: "plc-pump-station".into(),
target_id: Some("abc".into()),
scan_id: scan.map(String::from),
status: status.into(),
error: error.map(String::from),
}
}
#[test]
fn seed_outcome_labels() {
let (cls, label) = demo_seed_outcome(&result("queued", Some("s1"), None));
assert_eq!(cls, "badge badge-success");
assert_eq!(label, "added — scan queued");
let (_, label) = demo_seed_outcome(&result("queued", None, None));
assert_eq!(label, "added");
let (cls, label) = demo_seed_outcome(&result("exists", None, None));
assert_eq!(cls, "badge badge-info");
assert_eq!(label, "already added");
let (cls, label) = demo_seed_outcome(&result("failed", None, Some("clone failed")));
assert_eq!(cls, "badge badge-danger");
assert_eq!(label, "failed: clone failed");
let (_, label) = demo_seed_outcome(&result("failed", None, None));
assert_eq!(label, "failed");
}
#[test]
fn seed_response_parses_contract_shape() {
let body = serde_json::json!({
"seeded": [
{"name": "a", "target_id": "1", "scan_id": null, "status": "exists", "error": null},
{"name": "b", "target_id": "2", "scan_id": "s", "status": "queued", "error": null},
{"name": "c", "target_id": null, "scan_id": null, "status": "failed", "error": "boom"}
]
});
let resp: DemoSeedResponse = serde_json::from_value(body).unwrap();
assert_eq!(resp.seeded.len(), 3);
assert_eq!(resp.seeded[0].status, "exists");
assert_eq!(resp.seeded[1].scan_id.as_deref(), Some("s"));
assert_eq!(resp.seeded[2].error.as_deref(), Some("boom"));
}
#[test]
fn manifest_parses_and_default_selection_respects_source_only() {
let body = serde_json::json!({
"targets": [
{"name": "plc-pump-station", "kind": "plc_sps", "description": "x", "source_only": true},
{"name": "web-juice-shop", "kind": "web_app", "description": "y", "source_only": false}
]
});
let list: DemoSeedListResponse = serde_json::from_value(body).unwrap();
assert_eq!(list.targets.len(), 2);
assert_eq!(
demo_seed_default_selection(&list.targets, false),
vec!["plc-pump-station", "web-juice-shop"]
);
assert_eq!(
demo_seed_default_selection(&list.targets, true),
vec!["plc-pump-station"]
);
}
}
@@ -0,0 +1,319 @@
//! Agent contract handshake (`GET /api/v1/platform/version`).
//!
//! The agent advertises the *environment* it runs in through the public
//! version endpoint — most importantly the `features` list. The dashboard
//! uses it to hide runtime-only surfaces (DAST, pentest, ICS/PLC-runtime,
//! browser-driven actions) when the agent reports `source_only`, e.g. on
//! the CPX32 staging node that has no browserless / soft-plc / plc-sim.
//!
//! The server side caches the handshake for [`CACHE_TTL_SECS`] so every
//! page render does not hit the agent; the client reads it once per app
//! shell mount via [`use_platform_info`] / [`use_source_only`].
use dioxus::prelude::*;
use serde::{Deserialize, Serialize};
/// Feature flag the agent reports when no runtime (browser, PLC sim,
/// live-target) capabilities are available.
pub const FEATURE_SOURCE_ONLY: &str = "source_only";
/// Short user-facing note for surfaces that are disabled in source-only mode.
pub const SOURCE_ONLY_NOTE: &str = "Not available in this environment";
/// How long the server keeps a successful handshake before re-probing.
#[cfg(feature = "server")]
pub const CACHE_TTL_SECS: u64 = 60;
/// The parsed `/api/v1/platform/version` payload.
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, Eq)]
pub struct PlatformInfo {
#[serde(default)]
pub product: String,
#[serde(default)]
pub version: String,
#[serde(default)]
pub contract: String,
/// Feature flags advertised by the agent (e.g. `source_only`).
#[serde(default)]
pub features: Vec<String>,
/// `false` when the handshake could not be fetched — the UI then
/// assumes the full feature set (no surfaces hidden).
#[serde(default)]
pub reachable: bool,
}
impl PlatformInfo {
/// Whether the agent advertised the given feature flag.
pub fn has_feature(&self, feature: &str) -> bool {
self.features.iter().any(|f| f == feature)
}
/// The agent runs without runtime capabilities (no DAST / pentest /
/// PLC-runtime / browser actions).
pub fn source_only(&self) -> bool {
self.has_feature(FEATURE_SOURCE_ONLY)
}
}
/// Parse the raw JSON body of the version endpoint. Unknown / missing fields
/// degrade to defaults so an older agent (no `features` key) still works.
pub fn parse_platform_info(body: &serde_json::Value) -> PlatformInfo {
let mut info: PlatformInfo = serde_json::from_value(body.clone()).unwrap_or_default();
info.reachable = true;
info
}
/// Fetch the agent's version handshake (cached server-side for ~60 s).
#[server]
pub async fn fetch_platform_info() -> Result<PlatformInfo, ServerFnError> {
let state: super::server_state::ServerState =
dioxus_fullstack::FullstackContext::extract().await?;
Ok(cache::get_or_fetch(&state.agent_api_url).await)
}
#[cfg(feature = "server")]
mod cache {
use super::{parse_platform_info, PlatformInfo, CACHE_TTL_SECS};
use std::sync::{Mutex, OnceLock};
use std::time::{Duration, Instant};
static CACHE: OnceLock<Mutex<Option<(Instant, PlatformInfo)>>> = OnceLock::new();
fn slot() -> &'static Mutex<Option<(Instant, PlatformInfo)>> {
CACHE.get_or_init(|| Mutex::new(None))
}
/// Return the cached handshake when fresh, otherwise probe the agent.
/// A failed probe yields `PlatformInfo::default()` (unreachable, no
/// features) and is **not** cached, so the next render retries.
pub async fn get_or_fetch(agent_api_url: &str) -> PlatformInfo {
if let Ok(guard) = slot().lock() {
if let Some((at, info)) = guard.as_ref() {
if at.elapsed() < Duration::from_secs(CACHE_TTL_SECS) {
return info.clone();
}
}
}
let url = format!(
"{}/api/v1/platform/version",
agent_api_url.trim_end_matches('/')
);
let client = match reqwest::Client::builder()
.timeout(Duration::from_secs(5))
.build()
{
Ok(c) => c,
Err(e) => {
tracing::warn!("platform handshake: client build failed: {e}");
return PlatformInfo::default();
}
};
let body = match client.get(&url).send().await {
Ok(resp) if resp.status().is_success() => resp.json::<serde_json::Value>().await.ok(),
Ok(resp) => {
tracing::warn!("platform handshake: {url} returned {}", resp.status());
None
}
Err(e) => {
tracing::warn!("platform handshake: {url} unreachable: {e}");
None
}
};
let Some(body) = body else {
return PlatformInfo::default();
};
let info = parse_platform_info(&body);
if let Ok(mut guard) = slot().lock() {
*guard = Some((Instant::now(), info.clone()));
}
info
}
}
/// Read the platform handshake provided by the app shell. Pages rendered
/// outside the shell (tests, previews) fall back to the default (full
/// feature set).
pub fn use_platform_info() -> PlatformInfo {
match try_consume_context::<Signal<PlatformInfo>>() {
Some(sig) => sig(),
None => PlatformInfo::default(),
}
}
/// `true` when the agent reported the `source_only` feature.
pub fn use_source_only() -> bool {
use_platform_info().source_only()
}
/// A small inline note used next to disabled runtime-only controls.
#[component]
pub fn SourceOnlyNote(#[props(default)] inline: bool) -> Element {
let style = if inline {
"font-size: 0.8em; color: var(--text-secondary); font-style: italic; margin-left: 8px;"
} else {
"padding: 10px 14px; border-left: 3px solid var(--border-bright); color: var(--text-secondary); font-size: 0.9em; margin-bottom: 16px;"
};
rsx! {
span { class: "source-only-note", style: "{style}", title: "{SOURCE_ONLY_NOTE}",
"{SOURCE_ONLY_NOTE} (source-only mode)"
}
}
}
/// Visual tone for a pipeline stage / scan row.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum StageTone {
/// Ran / enabled by default.
Ok,
/// Available but off by default.
Plain,
/// Blocked for a data reason (no artifact, missing URL, …).
Info,
/// Skipped because the feature is disabled in this environment — not
/// an error, render neutrally.
Neutral,
/// Failed.
Failed,
}
impl StageTone {
pub fn badge_class(self) -> &'static str {
match self {
Self::Ok => "badge badge-success",
Self::Plain => "badge",
Self::Info => "badge badge-info",
Self::Neutral => "badge badge-neutral",
Self::Failed => "badge badge-danger",
}
}
}
/// `true` when a stage/scan was skipped because its feature is disabled
/// (the agent reports either `status: "skipped"` with a `feature disabled`
/// reason, or a `blocked_reason` starting with `skipped: feature disabled`).
pub fn is_feature_disabled_skip(status: Option<&str>, reason: Option<&str>) -> bool {
let reason_lc = reason.map(|r| r.to_ascii_lowercase()).unwrap_or_default();
let feature_disabled = reason_lc.contains("feature disabled");
match status.map(|s| s.to_ascii_lowercase()) {
Some(s) if s == "skipped" => feature_disabled,
Some(_) => false,
None => feature_disabled,
}
}
/// Classify one row of the applicable-scans matrix (or a pipeline stage)
/// for rendering.
pub fn stage_tone(
status: Option<&str>,
blocked_reason: Option<&str>,
default_on: bool,
) -> StageTone {
if is_feature_disabled_skip(status, blocked_reason) {
return StageTone::Neutral;
}
match status.map(|s| s.to_ascii_lowercase()).as_deref() {
Some("failed") | Some("error") => StageTone::Failed,
Some("skipped") => StageTone::Neutral,
_ => {
if blocked_reason.is_some() {
StageTone::Info
} else if default_on {
StageTone::Ok
} else {
StageTone::Plain
}
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn parse_reports_source_only_feature() {
let body = serde_json::json!({
"product": "pruefwerk",
"version": "0.9.0",
"contract": "2.0",
"features": ["source_only"]
});
let info = parse_platform_info(&body);
assert!(info.reachable);
assert!(info.source_only());
assert!(info.has_feature("source_only"));
assert!(!info.has_feature("dast"));
assert_eq!(info.version, "0.9.0");
}
#[test]
fn parse_tolerates_missing_features_on_old_agents() {
let body =
serde_json::json!({ "product": "pruefwerk", "version": "0.8.0", "contract": "2.0" });
let info = parse_platform_info(&body);
assert!(info.reachable);
assert!(!info.source_only());
assert!(info.features.is_empty());
}
#[test]
fn parse_tolerates_garbage_body() {
let info = parse_platform_info(&serde_json::json!("nope"));
assert!(info.reachable);
assert!(!info.source_only());
}
#[test]
fn default_is_unreachable_and_full_featured() {
let info = PlatformInfo::default();
assert!(!info.reachable);
assert!(!info.source_only());
}
#[test]
fn feature_disabled_skip_detection() {
assert!(is_feature_disabled_skip(
Some("skipped"),
Some("feature disabled: dast")
));
assert!(is_feature_disabled_skip(
None,
Some("skipped: feature disabled (source_only)")
));
assert!(!is_feature_disabled_skip(
Some("failed"),
Some("feature disabled")
));
assert!(!is_feature_disabled_skip(
Some("skipped"),
Some("no artifact")
));
assert!(!is_feature_disabled_skip(None, None));
}
#[test]
fn stage_tone_neutral_for_feature_disabled_not_red() {
assert_eq!(
stage_tone(None, Some("skipped: feature disabled"), true),
StageTone::Neutral
);
assert_eq!(
stage_tone(Some("skipped"), Some("feature disabled"), false),
StageTone::Neutral
);
assert_ne!(
stage_tone(Some("skipped"), Some("feature disabled"), false).badge_class(),
StageTone::Failed.badge_class()
);
}
#[test]
fn stage_tone_other_cases() {
assert_eq!(stage_tone(Some("failed"), None, true), StageTone::Failed);
assert_eq!(stage_tone(None, Some("no live URL"), true), StageTone::Info);
assert_eq!(stage_tone(None, None, true), StageTone::Ok);
assert_eq!(stage_tone(None, None, false), StageTone::Plain);
assert_eq!(stage_tone(Some("completed"), None, true), StageTone::Ok);
}
}
@@ -35,11 +35,19 @@ pub fn server_start(app: fn() -> Element) -> Result<(), DashboardError> {
tracing::warn!("Keycloak not configured - dashboard is unprotected");
}
// Explicit MCP health URL — needed where an ingress strips the
// `/mcp` prefix (staging: `…/mcp/health` → compliance-mcp `/health`).
let mcp_health_url = std::env::var("MCP_HEALTH_URL")
.ok()
.map(|v| v.trim().to_string())
.filter(|v| !v.is_empty());
let server_state: ServerState = ServerStateInner {
agent_api_url: config.agent_api_url.clone(),
db,
config,
keycloak,
mcp_health_url,
}
.into();
@@ -21,6 +21,10 @@ pub struct ServerStateInner {
pub config: DashboardConfig,
pub agent_api_url: String,
pub keycloak: Option<&'static KeycloakConfig>,
/// Explicit MCP health-probe URL (`MCP_HEALTH_URL`). When unset the
/// probe derives the URL from each server's endpoint (see
/// `infrastructure::mcp::mcp_health_url_candidates`).
pub mcp_health_url: Option<String>,
}
impl From<ServerStateInner> for ServerState {
@@ -5,9 +5,11 @@ use dioxus_free_icons::Icon;
use crate::app::Route;
use crate::components::page_header::PageHeader;
use crate::infrastructure::dast::{fetch_dast_findings, fetch_dast_scan_runs};
use crate::infrastructure::platform::{stage_tone, use_source_only, SourceOnlyNote};
#[component]
pub fn DastOverviewPage() -> Element {
let source_only = use_source_only();
let scan_runs = use_resource(|| async { fetch_dast_scan_runs().await.ok() });
let findings = use_resource(|| async { fetch_dast_findings().await.ok() });
@@ -17,6 +19,16 @@ pub fn DastOverviewPage() -> Element {
description: "Dynamic Application Security Testing — scan running applications for vulnerabilities",
}
if source_only {
div { class: "card", style: "padding: 12px 16px; margin-bottom: 16px;",
strong { "DAST is disabled here." }
SourceOnlyNote { inline: true }
p { style: "margin: 6px 0 0; color: var(--text-secondary); font-size: 0.9em;",
"The agent runs source-only (no browser runtime). Existing scan runs and findings remain readable."
}
}
}
div { class: "stat-cards", style: "margin-bottom: 24px;",
div { class: "stat-card-item",
div { class: "stat-card-value",
@@ -60,9 +72,9 @@ pub fn DastOverviewPage() -> Element {
div { style: "display: flex; gap: 12px; margin-bottom: 24px;",
Link {
to: Route::DastTargetsPage {},
class: "btn btn-primary",
class: if source_only { "btn btn-secondary" } else { "btn btn-primary" },
Icon { icon: BsBullseye, width: 14, height: 14 }
" Manage Targets"
if source_only { " View Targets" } else { " Manage Targets" }
}
Link {
to: Route::DastFindingsPage {},
@@ -97,8 +109,15 @@ pub fn DastOverviewPage() -> Element {
tr {
td { "{run.get(\"target_id\").and_then(|v| v.as_str()).unwrap_or(\"-\")}" }
td {
span { class: "badge",
"{run.get(\"status\").and_then(|v| v.as_str()).unwrap_or(\"unknown\")}"
{
let status = run.get("status").and_then(|v| v.as_str()).unwrap_or("unknown");
let reason = run.get("error_message").and_then(|v| v.as_str());
let cls = match stage_tone(Some(status), reason, true) {
crate::infrastructure::platform::StageTone::Neutral => "badge badge-neutral",
crate::infrastructure::platform::StageTone::Failed => "badge badge-danger",
_ => "badge",
};
rsx! { span { class: "{cls}", title: reason.unwrap_or(""), "{status}" } }
}
}
td { "{run.get(\"current_phase\").and_then(|v| v.as_str()).unwrap_or(\"-\")}" }
@@ -6,6 +6,7 @@ use crate::app::Route;
use crate::components::page_header::PageHeader;
use crate::components::pagination::Pagination;
use crate::components::severity_badge::SeverityBadge;
use crate::infrastructure::findings::has_control_refs;
#[component]
pub fn FindingsPage() -> Element {
@@ -194,6 +195,8 @@ pub fn FindingsPage() -> Element {
Some(Some(resp)) => {
let total_pages = resp.total.unwrap_or(0).div_ceil(20).max(1);
let all_ids: Vec<String> = resp.data.iter().filter_map(|f| f.id.as_ref().map(|id| id.to_hex())).collect();
// Only show the control-mapping column when something in view is mapped.
let show_controls = has_control_refs(&resp.data);
rsx! {
div { class: "card",
div { class: "table-wrapper",
@@ -231,6 +234,9 @@ pub fn FindingsPage() -> Element {
}
th { "Scanner" }
th { "File" }
if show_controls {
th { title: "Compliance controls this finding is evidence for", "Controls" }
}
th {
style: "cursor: pointer; user-select: none;",
onclick: toggle_sort("status"),
@@ -279,6 +285,18 @@ pub fn FindingsPage() -> Element {
Icon { icon: BsFileEarmarkCode, width: 14, height: 14 }
" {finding.file_path.as_deref().unwrap_or(\"-\")}"
}
if show_controls {
td {
div { style: "display: flex; gap: 4px; flex-wrap: wrap;",
for c in finding.control_refs.iter() {
span { class: "badge badge-info", title: "Control {c}", "{c}" }
}
if finding.control_refs.is_empty() {
span { style: "opacity: 0.4;", "—" }
}
}
}
}
td {
span { class: "badge badge-info",
{
@@ -53,12 +53,19 @@ pub fn McpServersPage() -> Element {
description: "Manage Model Context Protocol servers for LLM integrations",
}
div { class: "mb-4",
div { class: "mb-4", style: "display: flex; gap: 8px; flex-wrap: wrap;",
button {
class: "btn btn-primary",
onclick: move |_| show_form.set(!show_form()),
if show_form() { "Cancel" } else { "Register Server" }
}
Link {
to: crate::app::Route::McpTokensPage {},
class: "btn btn-secondary",
title: "Bearer tokens for connecting an IDE / LLM client",
Icon { icon: BsKey, width: 14, height: 14 }
" MCP tokens"
}
}
if show_form() {
+40 -9
View File
@@ -1,10 +1,14 @@
use dioxus::prelude::*;
use crate::components::demo_targets::DemoTargetsButton;
use crate::components::page_header::PageHeader;
use crate::infrastructure::onboarding::{
create_target, detect_target, enable_target_scans, fetch_applicable_scans, trigger_target_scan,
upload_target_artifact, validate_artifact_ref, validate_target_name, ArtifactInputDto,
};
use crate::infrastructure::platform::{
stage_tone, use_source_only, SourceOnlyNote, SOURCE_ONLY_NOTE,
};
/// (value, label, one-line description) for the 9 target families.
const TARGET_TYPES: &[(&str, &str, &str)] = &[
@@ -41,6 +45,12 @@ const ARTIFACT_KINDS: &[(&str, &str)] = &[
const STEP_LABELS: &[&str] = &["Target type", "Artifacts", "Review", "Done"];
/// Artifact kinds that only make sense with a runtime (live target / device)
/// — disabled when the agent reports `source_only`.
fn is_runtime_kind(kind: &str) -> bool {
matches!(kind, "live_url")
}
/// Artifact kinds provided as an uploaded file (rather than a URL/text ref).
fn is_file_kind(kind: &str) -> bool {
matches!(
@@ -79,13 +89,11 @@ fn ScanRow(scan: serde_json::Value) -> Element {
.get("default_on")
.and_then(|v| v.as_bool())
.unwrap_or(false);
let badge_class = if blocked.is_some() {
"badge badge-info"
} else if default_on {
"badge badge-success"
} else {
"badge"
};
let status = scan
.get("status")
.and_then(|v| v.as_str())
.map(String::from);
let badge_class = stage_tone(status.as_deref(), blocked.as_deref(), default_on).badge_class();
rsx! {
div { style: "display: flex; gap: 8px; align-items: center; padding: 6px 0;",
span { class: "{badge_class}", "{name}" }
@@ -141,6 +149,7 @@ pub fn OnboardingPage() -> Element {
// running — stored as serde scan-type names (lowercase, no underscores).
let mut enabled_extra = use_signal(Vec::<String>::new);
let source_only = use_source_only();
let step_now = step();
let name_error = validate_target_name(&name());
let can_advance_type = name_error.is_none() && !target_type().trim().is_empty();
@@ -151,6 +160,7 @@ pub fn OnboardingPage() -> Element {
// lowercase, no underscores, matching ScanType's rename_all = "lowercase").
let optin_scans: Vec<(String, String)> = scans()
.iter()
.filter(|_| !source_only)
.filter_map(|s| {
let unblocked = s.get("blocked_reason").and_then(|v| v.as_str()).is_none();
let default_on = s
@@ -216,6 +226,11 @@ pub fn OnboardingPage() -> Element {
}
}
}
div {
style: "display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 4px 0 8px; font-size: 0.9em; color: var(--text-secondary);",
span { "No target at hand? Start with the versioned demo set:" }
DemoTargetsButton { secondary: true }
}
div {
style: "display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 12px;",
for (value, tlabel, tdesc) in TARGET_TYPES.iter().copied() {
@@ -276,7 +291,13 @@ pub fn OnboardingPage() -> Element {
value: "{new_kind}",
oninput: move |e| new_kind.set(e.value()),
for (value, klabel) in ARTIFACT_KINDS.iter().copied() {
option { value: "{value}", "{klabel}" }
if source_only && is_runtime_kind(value) {
option { value: "{value}", disabled: true, title: "{SOURCE_ONLY_NOTE}",
"{klabel} — {SOURCE_ONLY_NOTE}"
}
} else {
option { value: "{value}", "{klabel}" }
}
}
}
}
@@ -456,7 +477,11 @@ pub fn OnboardingPage() -> Element {
}
}
div { style: "margin-top: 12px; opacity: 0.7; font-size: 0.9em;",
"The applicable scans (SAST / DAST / firmware / PLC) are shown after the target is created."
if source_only {
"The applicable scans (SAST / SBOM / firmware / PLC control logic) are shown after the target is created. DAST, pentest and live-device probes are not available in this environment."
} else {
"The applicable scans (SAST / DAST / firmware / PLC) are shown after the target is created."
}
}
}
}
@@ -480,6 +505,12 @@ pub fn OnboardingPage() -> Element {
ScanRow { scan: s }
}
}
if source_only {
div { style: "margin-top: 12px; font-size: 0.9em;",
"Live-device probes (ICS/PLC runtime), DAST and pentest are skipped here"
SourceOnlyNote { inline: true }
}
}
if !optin_scans.is_empty() {
div { style: "margin-top: 12px; padding: 10px; border: 1px dashed var(--border, #ccc); border-radius: 6px;",
div { style: "font-weight: 600; margin-bottom: 6px;", "Enable opt-in scans" }
+18 -3
View File
@@ -5,7 +5,7 @@ use dioxus_free_icons::Icon;
use crate::app::Route;
use crate::components::page_header::PageHeader;
use crate::components::stat_card::StatCard;
use crate::infrastructure::mcp::fetch_mcp_servers;
use crate::infrastructure::mcp::{fetch_mcp_servers, refresh_mcp_status};
use crate::infrastructure::onboarding::fetch_targets;
#[cfg(feature = "server")]
@@ -27,7 +27,12 @@ pub fn OverviewPage() -> Element {
});
let repos = use_resource(|| async { fetch_targets().await.ok() });
let mcp_servers = use_resource(|| async { fetch_mcp_servers().await.ok() });
// Probe the MCP health endpoints first so the seeded cards reflect the
// live status (running / stopped) instead of the stored default.
let mcp_servers = use_resource(|| async {
let _ = refresh_mcp_status().await;
fetch_mcp_servers().await.ok()
});
rsx! {
PageHeader {
@@ -135,6 +140,10 @@ pub fn OverviewPage() -> Element {
p { style: "padding: 1rem; color: var(--text-secondary);",
"No MCP servers registered."
}
div { style: "padding: 0 1rem 1rem; display: flex; gap: 8px;",
Link { to: Route::McpServersPage {}, class: "btn btn-primary btn-sm", "Manage" }
Link { to: Route::McpTokensPage {}, class: "btn btn-secondary btn-sm", "MCP tokens" }
}
}
} else {
rsx! {
@@ -173,12 +182,18 @@ pub fn OverviewPage() -> Element {
}
}
}
div { style: "padding: 0 1rem 1rem;",
div { style: "padding: 0 1rem 1rem; display: flex; gap: 8px; flex-wrap: wrap;",
Link {
to: Route::McpServersPage {},
class: "btn btn-primary btn-sm",
"Manage"
}
Link {
to: Route::McpTokensPage {},
class: "btn btn-secondary btn-sm",
title: "Bearer tokens for connecting an IDE / LLM client",
"MCP tokens"
}
}
}
}
+22 -10
View File
@@ -9,12 +9,14 @@ use dioxus::prelude::*;
use dioxus_free_icons::icons::bs_icons::*;
use dioxus_free_icons::Icon;
use crate::components::demo_targets::DemoTargetsButton;
use crate::components::page_header::PageHeader;
use crate::components::toast::{ToastType, Toasts};
use crate::infrastructure::onboarding::{
delete_target, fetch_applicable_scans, fetch_targets, trigger_target_scan, update_target,
validate_artifact_ref, validate_target_name, ArtifactInputDto,
};
use crate::infrastructure::platform::{stage_tone, use_source_only, SourceOnlyNote};
/// The nine target families (value, label) for the edit form's type selector.
const TARGET_TYPES: &[(&str, &str)] = &[
@@ -78,6 +80,7 @@ fn TargetScans(id: String) -> Element {
async move { fetch_applicable_scans(id).await.ok() }
});
let source_only = use_source_only();
let snapshot = scans.read().clone();
match &snapshot {
Some(Some(resp)) => {
@@ -94,13 +97,8 @@ fn TargetScans(id: String) -> Element {
let rationale = str_at(&s, "rationale").to_string();
let blocked = s.get("blocked_reason").and_then(|b| b.as_str()).map(String::from);
let default_on = s.get("default_on").and_then(|b| b.as_bool()).unwrap_or(false);
let badge = if blocked.is_some() {
"badge badge-info"
} else if default_on {
"badge badge-success"
} else {
"badge"
};
let status = s.get("status").and_then(|b| b.as_str()).map(String::from);
let badge = stage_tone(status.as_deref(), blocked.as_deref(), default_on).badge_class();
rsx! {
div { style: "display: flex; gap: 8px; align-items: center; padding: 4px 0;",
span { class: "{badge}", "{name}" }
@@ -112,7 +110,12 @@ fn TargetScans(id: String) -> Element {
}
}
}
if pentest {
if pentest && source_only {
div { style: "margin-top: 6px; opacity: 0.75; font-size: 0.85em;",
"Active pentest is supported for this target type"
SourceOnlyNote { inline: true }
}
} else if pentest {
div { style: "margin-top: 6px; opacity: 0.75; font-size: 0.85em;",
"Active pentest is supported for this target type."
}
@@ -348,8 +351,17 @@ pub fn TargetsPage() -> Element {
rsx! {
div { class: "card", style: "padding: 24px; text-align: center;",
p { style: "opacity: 0.7;", "No targets yet." }
Link { to: crate::app::Route::OnboardingPage {}, class: "btn btn-primary",
"Onboard your first target"
div { style: "display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;",
Link { to: crate::app::Route::OnboardingPage {}, class: "btn btn-primary",
"Onboard your first target"
}
DemoTargetsButton {
secondary: true,
on_seeded: move |_| targets.restart(),
}
}
p { style: "opacity: 0.6; font-size: 0.85em; margin-top: 10px;",
"The demo set covers two PLC projects, a CRA-vulnerable git service and a Zephyr firmware sample."
}
}
}
+11
View File
@@ -32,6 +32,17 @@ From this page you can:
Each registered server is assigned a random access token on creation. You use this token in your MCP client configuration for authenticated access.
### Server status
The card shows **running** once the dashboard has reached the server's health
endpoint. It probes `<endpoint>/health` and, for an endpoint that ends in
`/mcp`, also the path with the prefix stripped — which is what a
prefix-routing ingress needs. Where neither applies, set `MCP_HEALTH_URL` to
the absolute URL to probe for the default server (staging:
`https://pruefwerk-stage.breakpilot.com/mcp/health`). A server whose health
endpoint cannot be reached is shown as stopped; the tools still work if the
endpoint itself is reachable from your client.
## Available Tools
The MCP server exposes seven tools that LLM clients can discover and call:
+19
View File
@@ -25,6 +25,14 @@ The overview shows key metrics at a glance: total repositories, findings broken
Here is the fastest path from zero to your first scan results:
### 0. Or start with the demo targets
An empty workspace offers **Add demo targets** on the Targets page and in the
onboarding wizard. It creates a small curated set — two PLC projects, a
deliberately vulnerable web service and a Zephyr firmware sample — attaches
their files, detects each type and starts the first scans, so there are real
findings to look at within minutes. See [Demo targets](/guide/demo-targets).
### 1. Add a repository
Navigate to **Repositories** in the sidebar and click **Add Repository**. Enter a name, the Git clone URL, and the default branch to scan.
@@ -47,3 +55,14 @@ Once the scan completes, navigate to **Findings** to see everything that was dis
- [Understand how scans work](/guide/scanning) -- phases, triggers, and deduplication
- [Work with findings](/guide/findings) -- triage, false positives, and developer feedback
- [Explore your SBOM](/guide/sbom) -- dependencies, licenses, and exports
- [Connect your IDE](/features/mcp-server) -- query findings from an LLM client over MCP
## Static-analysis-only environments
Some deployments run with `PW_FEATURES=source_only` — the shared staging
environment does. Dynamic testing needs infrastructure (a browser, a soft-PLC,
network access to a running target) that is not deployed there, so dynamic
application testing, pentest sessions, the ICS probe and the ephemeral PLC
runtime are hidden in the interface, and a scan records those stages as
*skipped* rather than failed. Everything static — SAST, SBOM, CVE, the graph,
AI triage, control mapping — works as documented.