From b1ac9dcc07f30577ae8463e53cfa3b86c5cf6f42 Mon Sep 17 00:00:00 2001 From: karthickmk2001 Date: Tue, 27 Oct 2026 03:41:24 +0000 Subject: [PATCH] SECFOO-69: Dashboard UI improvements inspired by AGNT.gg Runs and findings - Live run page: step checklist polled from /runs//status.json, replacing the 5-second meta refresh; run receipt with prompt download - Blocked runs explain the cause and fix, with a Try again action - Reviewer sign-off on SAST findings (confirm / false positive / accept risk with a reason); new sast_findings review columns with a migration for existing stores; awaiting-sign-off count on SAST page - Review pipeline on the assessment page showing each activity's state Navigation and onboarding - Agents page and dashboard card with per-agent readiness - Starter templates and skill cards on Run Assessment; optional fields folded away on New Assessment - Getting-started checklist driven by real state - Command palette (Ctrl+K or /) and a path-style top bar with a live runs-in-progress indicator Visual refresh - Dark petrol sidebar with inline SVG icons, posture banner, icon stat cards, lighter tables, badges with status dots, blueprint canvas, shared page header, severity edges on finding rows - Light / System / Dark theme switch with dark-mode component fixes - AI spend labels metered vs subscription agents - Static assets served with Cache-Control: no-cache so upgrades are picked up without a hard refresh Fixes - Table cells using .findings-cell no longer break column alignment - Stat cards without icons no longer indent their value Co-Authored-By: Claude Opus 5.5 --- src/secfoo/storage/models.py | 4 + src/secfoo/storage/repository.py | 54 +++ src/secfoo/storage/schema.sql | 4 + src/secfoo/web/app.py | 13 + src/secfoo/web/routes/activities.py | 29 +- src/secfoo/web/routes/agents.py | 16 + src/secfoo/web/routes/assessments.py | 35 +- src/secfoo/web/routes/overview.py | 15 + src/secfoo/web/routes/runs.py | 36 +- src/secfoo/web/run_status.py | 231 +++++++++++ src/secfoo/web/sast_dashboard.py | 4 + src/secfoo/web/static/design-system/base.css | 4 +- .../design-system/components/badges.css | 22 +- .../design-system/components/buttons.css | 1 + .../static/design-system/components/cards.css | 2 +- .../static/design-system/components/dark.css | 56 +++ .../design-system/components/dashboard.css | 369 ++++++++++++++++++ .../design-system/components/run-ui.css | 279 +++++++++++++ .../design-system/components/sidebar.css | 98 ++++- .../design-system/components/stat-card.css | 61 ++- .../design-system/components/tables.css | 26 +- .../design-system/components/workflow.css | 305 +++++++++++++++ .../static/design-system/design-system.css | 4 + .../web/static/design-system/tokens.css | 23 +- src/secfoo/web/static/js/live-run.js | 84 ++++ src/secfoo/web/static/js/palette.js | 131 +++++++ src/secfoo/web/static/js/run-form.js | 23 ++ src/secfoo/web/static/js/theme.js | 36 ++ src/secfoo/web/templates/_icons.html | 29 ++ src/secfoo/web/templates/_page.html | 20 + .../activities/architecture_dashboard.html | 4 +- .../web/templates/activities/detail.html | 5 +- .../templates/activities/sast_dashboard.html | 6 +- .../activities/sast_finding_detail.html | 34 ++ .../activities/sast_findings_list.html | 10 +- .../templates/activities/sca_dashboard.html | 2 +- .../activities/secret_scanning_dashboard.html | 2 +- src/secfoo/web/templates/agents.html | 36 ++ .../web/templates/assessments/detail.html | 38 +- .../web/templates/assessments/list.html | 11 +- src/secfoo/web/templates/assessments/new.html | 15 +- src/secfoo/web/templates/assessments/run.html | 34 +- src/secfoo/web/templates/base.html | 68 +++- src/secfoo/web/templates/overview.html | 150 +++++-- src/secfoo/web/templates/responsible_ai.html | 8 +- src/secfoo/web/templates/run_detail.html | 109 ++++-- src/secfoo/web/templates/third_party.html | 7 +- src/secfoo/web/templating.py | 61 +++ tests/test_web/test_activity_routes.py | 5 +- tests/test_web/test_assessment_routes.py | 9 +- tests/test_web/test_run_ui.py | 173 ++++++++ tests/test_web/test_sast_dashboard.py | 17 +- 52 files changed, 2641 insertions(+), 177 deletions(-) create mode 100644 src/secfoo/web/routes/agents.py create mode 100644 src/secfoo/web/run_status.py create mode 100644 src/secfoo/web/static/design-system/components/dark.css create mode 100644 src/secfoo/web/static/design-system/components/dashboard.css create mode 100644 src/secfoo/web/static/design-system/components/run-ui.css create mode 100644 src/secfoo/web/static/design-system/components/workflow.css create mode 100644 src/secfoo/web/static/js/live-run.js create mode 100644 src/secfoo/web/static/js/palette.js create mode 100644 src/secfoo/web/static/js/run-form.js create mode 100644 src/secfoo/web/static/js/theme.js create mode 100644 src/secfoo/web/templates/_icons.html create mode 100644 src/secfoo/web/templates/_page.html create mode 100644 src/secfoo/web/templates/agents.html create mode 100644 tests/test_web/test_run_ui.py diff --git a/src/secfoo/storage/models.py b/src/secfoo/storage/models.py index 77273d9..e4c4ca5 100644 --- a/src/secfoo/storage/models.py +++ b/src/secfoo/storage/models.py @@ -162,6 +162,10 @@ class SastFindingRecord: language: str | None = None framework: str | None = None construct: str | None = None + review_status: str | None = None + review_note: str | None = None + reviewed_by: str | None = None + reviewed_at: str | None = None project_display_name: str | None = None diff --git a/src/secfoo/storage/repository.py b/src/secfoo/storage/repository.py index e2fa673..117b3e4 100644 --- a/src/secfoo/storage/repository.py +++ b/src/secfoo/storage/repository.py @@ -88,8 +88,17 @@ def use_db_path(path: Path): "language": "ALTER TABLE sast_findings ADD COLUMN language TEXT", "framework": "ALTER TABLE sast_findings ADD COLUMN framework TEXT", "construct": "ALTER TABLE sast_findings ADD COLUMN construct TEXT", + # Reviewer sign-off (dashboard Confirm / False positive / Accept risk). + # Stored on the finding row so a sign-off survives the finding being + # re-seen by later runs -- the upsert never touches these columns. + "review_status": "ALTER TABLE sast_findings ADD COLUMN review_status TEXT", + "review_note": "ALTER TABLE sast_findings ADD COLUMN review_note TEXT", + "reviewed_by": "ALTER TABLE sast_findings ADD COLUMN reviewed_by TEXT", + "reviewed_at": "ALTER TABLE sast_findings ADD COLUMN reviewed_at TEXT", } +SAST_REVIEW_STATUSES = ("confirmed", "false_positive", "accepted_risk") + # Skill id -> its per-finding lifecycle table. Every one of these tables # shares the open/closed + first/last-seen columns, which is what lets # close_stale_findings and list_structured_findings serve all three. @@ -415,6 +424,22 @@ def list_runs( rows = self._conn.execute(query, params).fetchall() return [self._row_to_run(row) for row in rows] + def agent_run_stats(self) -> dict[str, dict]: + """Per-agent run count, last run, last success and last status -- + backs the dashboard's agent health cards.""" + rows = self._conn.execute( + "SELECT agent_id, COUNT(*) runs, MAX(started_at) last_run_at, " + "MAX(CASE WHEN status = 'success' THEN started_at END) last_success_at " + "FROM runs GROUP BY agent_id" + ).fetchall() + stats = {row["agent_id"]: dict(row) for row in rows} + for row in self._conn.execute( + "SELECT agent_id, status FROM runs r WHERE started_at = " + "(SELECT MAX(started_at) FROM runs WHERE agent_id = r.agent_id)" + ).fetchall(): + stats[row["agent_id"]]["last_status"] = row["status"] + return stats + def get_run(self, run_uuid: str) -> RunRecord | None: row = self._conn.execute( "SELECT runs.*, projects.display_name FROM runs " @@ -1453,6 +1478,35 @@ def list_structured_findings( result.append((skill_id, dict(row))) return result + def review_sast_finding( + self, + finding_id: int, + *, + review_status: str | None, + note: str | None = None, + reviewed_by: str | None = None, + ) -> None: + """Records (or, with review_status=None, clears) a reviewer's + sign-off on one finding. Accepting a risk needs a reason -- a bare + "accepted" with nothing behind it is exactly what an auditor flags. + """ + if review_status is not None and review_status not in SAST_REVIEW_STATUSES: + raise ValueError(f"unknown review status {review_status!r}") + if review_status == "accepted_risk" and not (note or "").strip(): + raise ValueError("accepting a risk needs a reason") + self._conn.execute( + "UPDATE sast_findings SET review_status = ?, review_note = ?, reviewed_by = ?, reviewed_at = ? " + "WHERE id = ?", + ( + review_status, + (note or "").strip() or None if review_status else None, + (reviewed_by or "").strip() or None if review_status else None, + _now() if review_status else None, + finding_id, + ), + ) + self._conn.commit() + def list_sast_findings( self, *, diff --git a/src/secfoo/storage/schema.sql b/src/secfoo/storage/schema.sql index 8357599..164a70c 100644 --- a/src/secfoo/storage/schema.sql +++ b/src/secfoo/storage/schema.sql @@ -221,6 +221,10 @@ CREATE TABLE IF NOT EXISTS sast_findings ( last_seen_at TEXT NOT NULL, closed_in_run_id INTEGER REFERENCES runs(id), closed_at TEXT, + review_status TEXT, -- reviewer sign-off: confirmed / false_positive / accepted_risk, NULL = awaiting + review_note TEXT, + reviewed_by TEXT, + reviewed_at TEXT, UNIQUE (project_id, fingerprint) ); diff --git a/src/secfoo/web/app.py b/src/secfoo/web/app.py index d23dd82..b727e0e 100644 --- a/src/secfoo/web/app.py +++ b/src/secfoo/web/app.py @@ -8,6 +8,7 @@ from secfoo.config import STORE_DIR from secfoo.web.routes import ( activities, + agents, assessments, overview, projects, @@ -34,6 +35,17 @@ def mermaid_bundle_available() -> bool: def create_app() -> FastAPI: app = FastAPI(title="secfoo dashboard") + + @app.middleware("http") + async def revalidate_static(request, call_next): + # Make the browser re-check stylesheets/scripts on each load (a cheap + # 304 via ETag when unchanged). Without this, heuristic caching can + # keep serving an old design-system.css -- and its @import-ed + # component files -- after an upgrade, so a new UI looks broken. + response = await call_next(request) + if request.url.path.startswith("/static/"): + response.headers["Cache-Control"] = "no-cache" + return response # Mounted BEFORE /static: Starlette matches mounts in registration # order, so the broader /static would otherwise swallow /static/vendor. VENDOR_DIR.mkdir(parents=True, exist_ok=True) @@ -41,6 +53,7 @@ def create_app() -> FastAPI: app.mount("/static", StaticFiles(directory=str(STATIC_DIR)), name="static") app.include_router(overview.router) app.include_router(activities.router) + app.include_router(agents.router) app.include_router(assessments.router) app.include_router(third_party.router) app.include_router(responsible_ai.router) diff --git a/src/secfoo/web/routes/activities.py b/src/secfoo/web/routes/activities.py index d5e81f3..a8978bb 100644 --- a/src/secfoo/web/routes/activities.py +++ b/src/secfoo/web/routes/activities.py @@ -18,7 +18,8 @@ from pathlib import Path -from fastapi import APIRouter, HTTPException, Request +from fastapi import APIRouter, Form, HTTPException, Request +from fastapi.responses import RedirectResponse from secfoo.report.architecture import count_trust_boundaries, extract_design_verdict, extract_mermaid_diagram from secfoo.skills.loader import SkillLoadError, load_skill @@ -218,6 +219,32 @@ def sast_finding_detail(request: Request, fingerprint: str): ) +@router.post("/activities/sast/findings/{fingerprint}/review") +def sast_finding_review( + fingerprint: str, + finding_id: int = Form(...), + review_status: str = Form(...), + note: str = Form(""), + reviewer: str = Form(""), +): + """Reviewer sign-off: Confirm, False positive, Accept risk (needs a + reason), or "clear" to put the finding back to awaiting review.""" + with RunRepository() as repo: + finding = next((f for f in repo.list_sast_findings() if f.id == finding_id), None) + if finding is None or finding.fingerprint != fingerprint: + raise HTTPException(status_code=404, detail="Finding not found") + try: + repo.review_sast_finding( + finding_id, + review_status=None if review_status == "clear" else review_status, + note=note, + reviewed_by=reviewer, + ) + except ValueError as exc: + raise HTTPException(status_code=400, detail=str(exc)) from exc + return RedirectResponse(url=f"/activities/sast/findings/{fingerprint}", status_code=303) + + @router.get("/activities/{skill_id}/vulnerabilities") def sca_vulnerabilities_list(request: Request, skill_id: str, project_id: int | None = None): """The full SCA vulnerability register, filterable by project -- what diff --git a/src/secfoo/web/routes/agents.py b/src/secfoo/web/routes/agents.py new file mode 100644 index 0000000..e5af2b6 --- /dev/null +++ b/src/secfoo/web/routes/agents.py @@ -0,0 +1,16 @@ +from __future__ import annotations + +from fastapi import APIRouter, Request + +from secfoo.storage.repository import RunRepository +from secfoo.web.run_status import agent_health +from secfoo.web.templating import templates + +router = APIRouter() + + +@router.get("/agents") +def agents_page(request: Request): + with RunRepository() as repo: + stats = repo.agent_run_stats() + return templates.TemplateResponse(request, "agents.html", {"agents": agent_health(stats)}) diff --git a/src/secfoo/web/routes/assessments.py b/src/secfoo/web/routes/assessments.py index 30b5703..e85f3e5 100644 --- a/src/secfoo/web/routes/assessments.py +++ b/src/secfoo/web/routes/assessments.py @@ -20,7 +20,8 @@ from secfoo.skills.renderer import merge_excludes from secfoo.storage.repository import RunRepository from secfoo.targets.resolver import TargetResolutionError, resolve_target -from secfoo.web.templating import severity_rows, templates +from secfoo.web.run_status import assessment_pipeline +from secfoo.web.templating import SIDEBAR_ACTIVITY_IDS, ordered_skills, severity_rows, templates from secfoo.web.third_party_dashboard import SKILL_ID as THIRD_PARTY_RISK_SKILL_ID router = APIRouter() @@ -91,9 +92,38 @@ def _run_third_party_risk_assessment(assessment_id: int, project_id: int) -> Non shutil.rmtree(tmp_dir, ignore_errors=True) +# One-click presets on the Run Assessment form (static/js/run-form.js ticks +# the matching skill boxes and sets depth). Skills missing from this +# install are dropped rather than breaking the card. +RUN_STARTERS = [ + {"title": "Quick code triage", "skills": ["sast", "secret-scanning"], "depth": "quick", + "meta": "SAST + secrets · quick"}, + {"title": "Full design review", "skills": ["security-architecture-review", "threat-modeling"], + "depth": "standard", "meta": "architecture + threat model · standard"}, + {"title": "Dependency check", "skills": ["sca-reachability"], "depth": "quick", + "meta": "SCA reachability · quick"}, + {"title": "AI system review", "skills": ["prompt-review", "responsible-ai-compliance"], "depth": "standard", + "meta": "prompts + responsible AI · standard"}, +] + + +def _pipeline_skills(runs) -> list: + """The five core review activities always, plus any other skill that + actually ran on this assessment (e.g. responsible-ai-compliance).""" + ran = {r.skill_id for r in runs} + return [s for s in ordered_skills() if s.id in SIDEBAR_ACTIVITY_IDS or s.id in ran] + + def _run_form_context() -> dict: + skills = load_all_skills() + starters = [] + for starter in RUN_STARTERS: + present = [skill_id for skill_id in starter["skills"] if skill_id in skills] + if present: + starters.append({**starter, "skills": present}) return { - "skills": sorted(load_all_skills().values(), key=lambda s: s.name), + "starters": starters, + "skills": [skill for skill in ordered_skills() if skill.id in skills], "agent_options": [ {"id": agent_id, "available": get_adapter(agent_id).is_available()} for agent_id in ADAPTERS ], @@ -195,6 +225,7 @@ def assessment_detail(request: Request, assessment_id: int): "models_count": models_count, "tools_count": tools_count, "has_running_run": has_running_run, + "pipeline": assessment_pipeline(runs, _pipeline_skills(runs)), "severity_rows": severity_rows( assessment.critical_count, assessment.high_count, diff --git a/src/secfoo/web/routes/overview.py b/src/secfoo/web/routes/overview.py index db943fa..7f72b88 100644 --- a/src/secfoo/web/routes/overview.py +++ b/src/secfoo/web/routes/overview.py @@ -3,6 +3,7 @@ from fastapi import APIRouter, Request from secfoo.storage.repository import RunRepository +from secfoo.web.run_status import COST_REPORTING_AGENTS, agent_health, setup_steps from secfoo.web.templating import ordered_skills, severity_rows, templates from secfoo.web.top_findings import build_top_findings @@ -21,6 +22,10 @@ def overview(request: Request): models_count, tools_count = repo.ai_bom_counts_total() top_findings = build_top_findings(repo) cost_by_agent = repo.cost_summary(group_by="agent") + agent_stats = repo.agent_run_stats() + recent_runs = repo.list_runs(limit=6) + assessment_count = repo.count_assessments() + reviewed_count = sum(1 for f in repo.list_sast_findings() if f.review_status) # Coverage is "projects that have had this activity run", so the # denominator is the project count -- see RunRepository.skill_coverage. @@ -50,6 +55,16 @@ def overview(request: Request): "tools_count": tools_count, "top_findings": top_findings, "cost_by_agent": cost_by_agent, + "cost_reporting_agents": COST_REPORTING_AGENTS, + "agents": agent_health(agent_stats), + "recent_runs": recent_runs, + "setup": setup_steps( + agents=agent_health(agent_stats), + assessment_count=assessment_count, + run_count=sum(stats["runs"] for stats in agent_stats.values()), + reviewed_count=reviewed_count, + ), + "run_count": sum(stats["runs"] for stats in agent_stats.values()), # None (rendered "-") until at least one run has a known cost, # so runs that predate tracking don't read as free. "total_cost": ( diff --git a/src/secfoo/web/routes/runs.py b/src/secfoo/web/routes/runs.py index 96b7eaf..fa9ae2f 100644 --- a/src/secfoo/web/routes/runs.py +++ b/src/secfoo/web/routes/runs.py @@ -3,10 +3,11 @@ from pathlib import Path from fastapi import APIRouter, HTTPException, Request -from fastapi.responses import FileResponse +from fastapi.responses import FileResponse, JSONResponse from secfoo.report.markdown import render_report_html from secfoo.storage.repository import RunRepository +from secfoo.web.run_status import ACTIVE_STATUSES, blocked_hint, elapsed_seconds, run_steps from secfoo.web.templating import templates router = APIRouter() @@ -32,6 +33,10 @@ def run_detail(request: Request, run_uuid: str): "run_detail.html", { "run": record, + "steps": run_steps(record), + "blocked": blocked_hint(record), + "elapsed": elapsed_seconds(record), + "is_active": record.status in ACTIVE_STATUSES, "report_html": report_html, "mermaid_available": mermaid_bundle_available(), }, @@ -45,3 +50,32 @@ def run_report_download(run_uuid: str): if record is None or not record.report_path or not Path(record.report_path).exists(): raise HTTPException(status_code=404, detail="Report not found") return FileResponse(record.report_path, media_type="text/markdown", filename=f"{run_uuid}.md") + + +@router.get("/runs/{run_uuid}/status.json") +def run_status_json(run_uuid: str): + """Polled by static/js/live-run.js while a run is in flight, so the run + page can tick its step list without reloading the whole report view.""" + with RunRepository() as repo: + record = repo.get_run(run_uuid) + if record is None: + raise HTTPException(status_code=404, detail="Run not found") + return JSONResponse( + { + "status": record.status, + "active": record.status in ACTIVE_STATUSES, + "elapsed_seconds": elapsed_seconds(record), + "steps": [{"label": s.label, "state": s.state, "detail": s.detail} for s in run_steps(record)], + } + ) + + +@router.get("/runs/{run_uuid}/prompt.md") +def run_prompt_download(run_uuid: str): + """The exact prompt the agent was given -- part of the run receipt, so a + reviewer can see what was asked, not just what came back.""" + with RunRepository() as repo: + record = repo.get_run(run_uuid) + if record is None or not record.prompt_path or not Path(record.prompt_path).exists(): + raise HTTPException(status_code=404, detail="Prompt not found") + return FileResponse(record.prompt_path, media_type="text/markdown", filename=f"{run_uuid}-prompt.md") diff --git a/src/secfoo/web/run_status.py b/src/secfoo/web/run_status.py new file mode 100644 index 0000000..3d4f461 --- /dev/null +++ b/src/secfoo/web/run_status.py @@ -0,0 +1,231 @@ +"""Presentation helpers for a single run: the step checklist on the run +page, the "Blocked" explanation for a run that didn't produce a report, +and per-agent facts the dashboard needs (install hint, whether the CLI +reports its own cost). + +The runner doesn't emit progress events, so the steps are derived from +what a run has left behind so far -- prompt.md is written just before the +agent is invoked, stdout.log right after it returns, and report_path once +the report has been parsed. That's coarse (the agent's own work is one +step), but it is accurate: nothing here is guessed. +""" + +from __future__ import annotations + +from dataclasses import dataclass +from datetime import datetime, timezone + +from secfoo.agents.api import KEY_VARS +from secfoo.agents.registry import ADAPTERS, get_adapter +from secfoo.config import run_dir +from secfoo.storage.models import RunRecord + +ACTIVE_STATUSES = {"pending", "running"} + +# Agents whose CLI reports token usage / cost back to secfoo. The others run +# on the user's own subscription and say nothing about spend, so the +# dashboard labels them instead of showing a bare "-". +COST_REPORTING_AGENTS = {"claude", "gemini", "api", "droid"} + +AGENT_LABELS = { + "claude": "Claude Code", + "agent": "Cursor", + "agy": "Antigravity", + "gemini": "Gemini CLI", + "codex": "Codex CLI", + "copilot": "GitHub Copilot CLI", + "droid": "Factory Droid", + "devin": "Devin", + "api": "API agent (LiteLLM)", +} + +INSTALL_HINTS = { + "claude": "npm install -g @anthropic-ai/claude-code", + "agent": "curl https://cursor.com/install -fsS | bash", + "gemini": "npm install -g @google/gemini-cli", + "codex": "npm install -g @openai/codex", + "copilot": "npm install -g @github/copilot", + "api": f"Set one of {', '.join(KEY_VARS)} in your environment", +} + + +@dataclass(frozen=True) +class RunStep: + label: str + state: str # "done" | "live" | "failed" | "todo" + detail: str = "" + + +@dataclass(frozen=True) +class BlockedHint: + title: str + explanation: str + fix: str | None = None + + +def _parse_time(value: str | None) -> datetime | None: + if not value: + return None + try: + parsed = datetime.fromisoformat(value) + except ValueError: + return None + return parsed if parsed.tzinfo else parsed.replace(tzinfo=timezone.utc) + + +def elapsed_seconds(run: RunRecord) -> float | None: + """Wall-clock seconds so far for a live run, or the recorded duration.""" + if run.duration_seconds is not None: + return run.duration_seconds + started = _parse_time(run.started_at) + if started is None: + return None + return max(0.0, (datetime.now(timezone.utc) - started).total_seconds()) + + +def run_steps(run: RunRecord) -> list[RunStep]: + folder = run_dir(run.run_uuid) + prompt_written = (folder / "prompt.md").exists() or bool(run.prompt_path) + agent_returned = (folder / "stdout.log").exists() or run.status not in ACTIVE_STATUSES + report_saved = bool(run.report_path) and run.status not in ACTIVE_STATUSES + failed = run.status not in ACTIVE_STATUSES and run.status != "success" + agent_label = AGENT_LABELS.get(run.agent_id, run.agent_id) + + steps = [RunStep("Run created", "done", run.started_at[:19].replace("T", " "))] + # The runner writes prompt.md before invoking the agent, so any finished + # run got past this step even if its prompt file has since been removed. + prompt_done = prompt_written or run.status not in ACTIVE_STATUSES + steps.append(RunStep("Prompt prepared from skill", "done" if prompt_done else "live")) + + if failed: + agent_state = "failed" + elif not prompt_written: + agent_state = "todo" + elif agent_returned: + agent_state = "done" + else: + agent_state = "live" + confluence = f" with {len(run.confluence_urls)} Confluence page(s)" if run.confluence_urls else "" + steps.append(RunStep(f"{agent_label} reviewing the target{confluence}", agent_state)) + + if failed: + steps.append(RunStep("Report saved and findings counted", "todo", "skipped: the agent didn't finish")) + else: + steps.append(RunStep("Report saved and findings counted", "done" if report_saved else "todo")) + return steps + + +def blocked_hint(run: RunRecord) -> BlockedHint | None: + """Plain-language cause and fix for a run that ended without success.""" + agent_label = AGENT_LABELS.get(run.agent_id, run.agent_id) + if run.status == "binary_not_found": + if run.agent_id == "api": + return BlockedHint( + "No API key found for the api agent", + "The api agent calls a model provider directly and needs a key in the environment " + "of the process running secfoo.", + INSTALL_HINTS["api"], + ) + binary = ADAPTERS[run.agent_id].binary if run.agent_id in ADAPTERS else run.agent_id + return BlockedHint( + f"{agent_label} isn't installed", + f"secfoo couldn't find the {binary!r} command on PATH, so the agent never started.", + INSTALL_HINTS.get(run.agent_id), + ) + if run.status == "timeout": + return BlockedHint( + "The agent ran out of time", + "The run hit its timeout before the agent returned a report. Large repositories or " + "standard depth can need longer.", + "Re-run with --timeout set higher, or exclude vendored paths", + ) + if run.status == "failed": + exit_note = f" (exit code {run.exit_code})" if run.exit_code is not None else "" + return BlockedHint( + f"{agent_label} stopped with an error{exit_note}", + "The agent exited before producing a usable report. The error output below usually " + "says why: an expired sign-in, a rate limit, or a sandbox refusing to read the target.", + None, + ) + return None + + +def agent_health(runs_by_agent: dict[str, dict]) -> list[dict]: + """One row per registered agent for the Agents page and dashboard card. + + `runs_by_agent` maps agent id -> {"runs": int, "last_run_at": str|None, + "last_success_at": str|None}. "Ready" only means the CLI (or API key) is + present -- secfoo can't tell whether a CLI is still signed in without + launching it, so the page says so rather than implying more. + """ + rows = [] + for agent_id in ADAPTERS: + adapter = get_adapter(agent_id) + available = adapter.is_available() + stats = runs_by_agent.get(agent_id, {}) + rows.append( + { + "id": agent_id, + "label": AGENT_LABELS.get(agent_id, agent_id), + "binary": adapter.binary, + "available": available, + "reports_cost": agent_id in COST_REPORTING_AGENTS, + "install_hint": None if available else INSTALL_HINTS.get(agent_id), + "runs": stats.get("runs", 0), + "last_run_at": stats.get("last_run_at"), + "last_success_at": stats.get("last_success_at"), + "last_status": stats.get("last_status"), + } + ) + return rows + + +BLOCKED_STATUSES = {"binary_not_found", "failed", "timeout"} + + +def assessment_pipeline(runs: list[RunRecord], skill_order: list) -> list[dict]: + """One node per security activity, in review order, for the assessment + page's pipeline view. Each node reflects the LATEST run of that skill + on this assessment: done / blocked / running / not run, plus that run's + finding counts. Skills with no run still appear, so coverage gaps are + visible rather than silently missing.""" + latest: dict[str, RunRecord] = {} + for run in sorted(runs, key=lambda r: r.started_at): + latest[run.skill_id] = run + nodes = [] + for skill in skill_order: + run = latest.get(skill.id) + if run is None: + state = "todo" + elif run.status in ACTIVE_STATUSES: + state = "running" + elif run.status in BLOCKED_STATUSES: + state = "blocked" + else: + state = "done" + nodes.append( + { + "id": skill.id, + "label": skill.nav_label, + "state": state, + "run": run, + "findings": (run.critical_count + run.high_count + run.medium_count + run.low_count) if run else 0, + "severe": (run.critical_count + run.high_count) if run else 0, + } + ) + return nodes + + +def setup_steps(*, agents: list[dict], assessment_count: int, run_count: int, reviewed_count: int) -> list[dict]: + """The dashboard's getting-started checklist, each step checked off from + real state rather than a "dismiss" flag.""" + return [ + {"label": "Set up an agent", "detail": "Install a coding-agent CLI or set an API key.", + "done": any(a["available"] for a in agents), "href": "/agents"}, + {"label": "Create an assessment", "detail": "Name the project and point at its code.", + "done": assessment_count > 0, "href": "/assessments/new"}, + {"label": "Run your first activity", "detail": "Pick a starter template and start a run.", + "done": run_count > 0, "href": "/assessments"}, + {"label": "Sign off a finding", "detail": "Confirm, dismiss or accept the risk on a SAST finding.", + "done": reviewed_count > 0, "href": "/activities/sast/findings"}, + ] diff --git a/src/secfoo/web/sast_dashboard.py b/src/secfoo/web/sast_dashboard.py index 5b6dd39..f0edea0 100644 --- a/src/secfoo/web/sast_dashboard.py +++ b/src/secfoo/web/sast_dashboard.py @@ -56,6 +56,7 @@ def build(repo: RunRepository) -> SastDashboard: verified_count = 0 severe_count = 0 exploitable_count = 0 + awaiting_signoff = 0 for finding in dash.open_findings: band = _cvss_band(finding.cvss_score) @@ -66,6 +67,8 @@ def build(repo: RunRepository) -> SastDashboard: verified_count += 1 if band in ("high", "critical"): severe_count += 1 + if finding.review_status is None: + awaiting_signoff += 1 if (finding.verdict or "").strip().lower() != "latent": exploitable_count += 1 @@ -76,6 +79,7 @@ def build(repo: RunRepository) -> SastDashboard: "exploitable": exploitable_count, "verified": verified_count, "severe": severe_count, + "awaiting_signoff": awaiting_signoff, } return dash diff --git a/src/secfoo/web/static/design-system/base.css b/src/secfoo/web/static/design-system/base.css index 0f6a60f..90487e8 100644 --- a/src/secfoo/web/static/design-system/base.css +++ b/src/secfoo/web/static/design-system/base.css @@ -30,8 +30,8 @@ h1, h2, h3, h4, h5, h6, p, figure { margin: 0 0 var(--space-4) 0; } -h1 { font: var(--text-h1); } -h2 { font: var(--text-h2); } +h1 { font: var(--text-h1); letter-spacing: -0.02em; text-wrap: balance; } +h2 { font: var(--text-h2); letter-spacing: -0.01em; text-wrap: balance; } h3 { font: var(--text-h3); } h4 { font: var(--text-h4); } diff --git a/src/secfoo/web/static/design-system/components/badges.css b/src/secfoo/web/static/design-system/components/badges.css index f2d7139..6b9d94c 100644 --- a/src/secfoo/web/static/design-system/components/badges.css +++ b/src/secfoo/web/static/design-system/components/badges.css @@ -6,14 +6,28 @@ .badge { display: inline-flex; align-items: center; - gap: var(--space-1); - padding-block: var(--space-1); - padding-inline: var(--space-3); + gap: 0.375rem; + padding-block: 0.1875rem; + padding-inline: 0.625rem; border-radius: var(--radius-pill); font: var(--text-caption); + font-size: 0.6875rem; font-weight: var(--font-weight-bold); text-transform: uppercase; - letter-spacing: 0.03em; + letter-spacing: 0.04em; + white-space: nowrap; +} + +/* Status dot on semantic badges so state reads at a glance, not just by hue. */ +.badge--success::before, +.badge--warning::before, +.badge--error::before, +.badge--primary::before { + content: ""; + width: 0.375rem; + height: 0.375rem; + border-radius: 50%; + background-color: currentColor; } .badge--neutral { background-color: var(--color-gray-100); color: var(--color-gray-700); } diff --git a/src/secfoo/web/static/design-system/components/buttons.css b/src/secfoo/web/static/design-system/components/buttons.css index 6fe8019..797549b 100644 --- a/src/secfoo/web/static/design-system/components/buttons.css +++ b/src/secfoo/web/static/design-system/components/buttons.css @@ -20,6 +20,7 @@ padding-inline: var(--space-6); font: var(--text-button-sm); white-space: nowrap; + text-decoration: none; cursor: pointer; user-select: none; transition: background-color var(--duration-fast) var(--ease-standard), diff --git a/src/secfoo/web/static/design-system/components/cards.css b/src/secfoo/web/static/design-system/components/cards.css index 62f763f..3838a94 100644 --- a/src/secfoo/web/static/design-system/components/cards.css +++ b/src/secfoo/web/static/design-system/components/cards.css @@ -49,7 +49,7 @@ .card__title { font: var(--text-h4); - margin-bottom: var(--space-2); + margin-bottom: var(--space-3); } .card__body { diff --git a/src/secfoo/web/static/design-system/components/dark.css b/src/secfoo/web/static/design-system/components/dark.css new file mode 100644 index 0000000..46f3fb3 --- /dev/null +++ b/src/secfoo/web/static/design-system/components/dark.css @@ -0,0 +1,56 @@ +/* + Dark theme: component touch-ups + ------------------------------- + The role tokens in tokens.css carry most of [data-theme="dark"], but a + handful of components paint with raw ramp steps (gray-100 tracks, + primary-50 tints, primary-700 text) that only read on a light ground. + This file re-points just those, so the dashboard's theme switch works + without rewriting every component. +*/ + +[data-theme="dark"] .badge--neutral, +[data-theme="dark"] .badge:not([class*="badge--"]) { background-color: var(--color-gray-700); color: var(--color-gray-100); } +[data-theme="dark"] .badge--primary { background-color: #0f3a4c; color: var(--color-primary-200); } +[data-theme="dark"] .badge--teal { background-color: #0d3d3a; color: var(--color-teal-300); } +[data-theme="dark"] .badge--amber { background-color: #3a2a14; color: var(--color-amber-300); } + +[data-theme="dark"] .segmented, +[data-theme="dark"] .severity-bar__track, +[data-theme="dark"] .conformance-bar__track, +[data-theme="dark"] .stacked-bar, +[data-theme="dark"] code, +[data-theme="dark"] .input:disabled { background-color: var(--color-gray-900); } + +[data-theme="dark"] .segmented__option[aria-selected="true"] { background-color: var(--color-primary-500); } + +[data-theme="dark"] .sidebar { --sidebar-bg: #04161e; border-right: 1px solid var(--color-border); } + +[data-theme="dark"] .stat-card { --stat-accent-bg: rgba(255, 255, 255, 0.06); } +[data-theme="dark"] .stat-card--teal { --stat-accent: var(--color-teal-300); } +[data-theme="dark"] .stat-card:not([class*="stat-card--"]) { --stat-accent: var(--color-primary-300); } +[data-theme="dark"] .tabs__tab[aria-selected="true"], +[data-theme="dark"] .nav__link[aria-current="page"] { color: var(--color-primary-200); } + +[data-theme="dark"] .table tbody tr:hover, +[data-theme="dark"] tr.run-row:hover { background-color: #0f3a4c; } + +[data-theme="dark"] .btn--primary { background-color: var(--color-primary-500); } +[data-theme="dark"] .btn--primary:hover { background-color: var(--color-primary-400); } +[data-theme="dark"] .btn--outline, +[data-theme="dark"] .btn--ghost { border-color: var(--color-primary-300); color: var(--color-primary-200); } +[data-theme="dark"] .btn--outline:hover, +[data-theme="dark"] .btn--ghost:hover { background-color: #0f3a4c; } + +[data-theme="dark"] .run-steps__item[data-state="live"] .run-steps__dot { background-color: #0d3d3a; } + +[data-theme="dark"] .table th { background-color: rgba(255, 255, 255, 0.03); } + +[data-theme="dark"] .sidebar .segmented { background-color: rgba(0, 0, 0, 0.3); } +[data-theme="dark"] .sidebar .segmented__option[aria-selected="true"] { background-color: var(--color-teal-500); color: var(--color-primary-900); } +[data-theme="dark"] .posture { background-color: #062230; border: 1px solid var(--color-border); } +[data-theme="dark"] .feed__dot--running, [data-theme="dark"] .feed__dot--pending { box-shadow: 0 0 0 4px #0d3d3a; } +[data-theme="dark"] .alert--info { color: var(--color-primary-100); border-color: var(--color-primary-600); } +[data-theme="dark"] .alert--success { border-color: #2a5c3d; } +[data-theme="dark"] .alert--warning { border-color: #6b4f22; } +[data-theme="dark"] .alert--error { border-color: #6e2f2a; } +[data-theme="dark"] .ds-overline { color: var(--color-teal-300); } diff --git a/src/secfoo/web/static/design-system/components/dashboard.css b/src/secfoo/web/static/design-system/components/dashboard.css new file mode 100644 index 0000000..ed3e3eb --- /dev/null +++ b/src/secfoo/web/static/design-system/components/dashboard.css @@ -0,0 +1,369 @@ +/* + Dashboard + --------- + The posture banner that opens the dashboard, the recent-runs feed, and + two button variants for use on the dark petrol surfaces (banner, + terminal callouts). +*/ + +/* ---------- Posture banner ---------- */ +.posture { + position: relative; + display: grid; + grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); + gap: var(--space-8); + align-items: center; + padding: var(--space-8); + border-radius: var(--radius-xl); + color: var(--color-white); + background-color: var(--color-primary-900); + background-image: + radial-gradient(38rem 18rem at 100% 0%, rgba(20, 168, 156, 0.28), transparent 70%), + radial-gradient(30rem 16rem at 0% 120%, rgba(44, 118, 144, 0.45), transparent 70%); + box-shadow: var(--shadow-md); + overflow: hidden; +} + +.posture__main { position: relative; z-index: 1; min-width: 0; } + +.posture__eyebrow { + display: inline-flex; + align-items: center; + gap: var(--space-2); + font: var(--text-overline); + letter-spacing: var(--overline-letter-spacing); + text-transform: uppercase; + color: var(--color-teal-300); +} + +.posture__eyebrow-icon { width: 1rem; height: 1rem; } + +.posture__title { + font: 700 1.875rem/1.2 var(--font-family-base); + letter-spacing: -0.02em; + margin: var(--space-3) 0 var(--space-2); + color: var(--color-white); + max-width: 28ch; +} + +.posture__meta { + font: var(--text-body-sm); + color: rgba(255, 255, 255, 0.68); + margin-bottom: var(--space-6); +} + +.posture__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); } + +.posture__meter { + position: relative; + z-index: 1; + background-color: rgba(255, 255, 255, 0.06); + border: 1px solid rgba(255, 255, 255, 0.1); + border-radius: var(--radius-lg); + padding: var(--space-5); + min-width: 0; +} + +.posture__bar { + display: flex; + gap: 3px; + height: 0.625rem; + border-radius: var(--radius-pill); + overflow: hidden; + margin-bottom: var(--space-5); +} + +.posture__seg { display: block; min-width: 0.5rem; flex-basis: 0; } +.posture__seg--critical { background-color: #ff6b5e; } +.posture__seg--high { background-color: #f59a4a; } +.posture__seg--medium { background-color: #f0cf6a; } +.posture__seg--low { background-color: var(--color-teal-300); } +.posture__seg--none { background-color: rgba(255, 255, 255, 0.15); } + +.posture__legend { + display: grid; + grid-template-columns: repeat(4, minmax(0, 1fr)); + gap: var(--space-3); + margin: 0; +} + +.posture__legend dt { + display: flex; + align-items: center; + gap: var(--space-2); + font: var(--text-caption); + color: rgba(255, 255, 255, 0.68); +} + +.posture__legend dd { + margin: var(--space-1) 0 0; + font: 700 1.5rem/1.1 var(--font-family-base); + font-variant-numeric: tabular-nums; + color: var(--color-white); +} + +.posture__dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; display: inline-block; } + +@media (max-width: 60rem) { + .posture { grid-template-columns: minmax(0, 1fr); padding: var(--space-6); } + .posture__title { font-size: 1.5rem; } +} + +@media (max-width: 30rem) { + .posture__legend { grid-template-columns: repeat(2, minmax(0, 1fr)); } +} + +/* ---------- Buttons on dark surfaces ---------- */ +.btn__icon { width: 1.125rem; height: 1.125rem; flex-shrink: 0; } + +.btn--signal { + background-color: var(--color-teal-300); + color: var(--color-primary-900); + border: 1px solid var(--color-teal-300); +} + +.btn--signal:hover:not(:disabled) { + background-color: var(--color-teal-100); + border-color: var(--color-teal-100); +} + +.btn--on-dark { + background-color: transparent; + color: var(--color-white); + border: 1px solid rgba(255, 255, 255, 0.35); +} + +.btn--on-dark:hover:not(:disabled) { + background-color: rgba(255, 255, 255, 0.08); + border-color: rgba(255, 255, 255, 0.6); +} + +/* ---------- Recent runs feed ---------- */ +.feed { list-style: none; margin: 0; padding: 0; display: grid; } + +.feed__item { + display: grid; + grid-template-columns: auto minmax(0, 1fr) auto; + gap: var(--space-3); + align-items: center; + padding: var(--space-3) var(--space-2); + margin-inline: calc(-1 * var(--space-2)); + border-radius: var(--radius-sm); + color: inherit; + text-decoration: none; + border-bottom: 1px solid var(--color-border); + transition: background-color var(--duration-fast) var(--ease-standard); +} + +.feed li:last-child .feed__item { border-bottom: none; } +.feed__item:hover { background-color: var(--color-bg-subtle); } +.feed__item:focus-visible { outline: none; box-shadow: var(--shadow-focus); } + +.feed__dot { width: 0.625rem; height: 0.625rem; border-radius: 50%; background-color: var(--color-gray-300); } +.feed__dot--success { background-color: var(--color-success); } +.feed__dot--blocked { background-color: var(--color-error); } +.feed__dot--running, .feed__dot--pending { + background-color: var(--color-teal-500); + box-shadow: 0 0 0 4px var(--color-teal-100); +} + +.feed__body { display: grid; min-width: 0; } +.feed__title { font: var(--text-body-sm); font-weight: var(--font-weight-bold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.feed__meta { font: var(--text-caption); color: var(--color-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } + +/* ---------- Page header (overline + h1 + actions) spacing ---------- */ +.app-shell__main h1 { margin-top: var(--space-1); } + +/* Inside the app shell the main column already provides the side gutter; + the container only caps the width. */ +.app-shell__main > .ds-container { padding-inline: 0; } + +/* ---------- Blueprint canvas ---------- + A faint dot grid behind the main column -- the drafting-table backdrop + an architecture review is drawn on. Cards stay solid on top of it. */ +:root { --canvas-dot: rgba(18, 74, 96, 0.09); } +[data-theme="dark"] { --canvas-dot: rgba(255, 255, 255, 0.05); } + +.app-shell__main { + background-image: radial-gradient(var(--canvas-dot) 1px, transparent 1.2px); + background-size: 22px 22px; + background-position: -11px -11px; +} + +/* ---------- Top bar: where you are, as a path ---------- */ +.topbar { + position: sticky; + top: 0; + z-index: 20; + display: flex; + align-items: center; + justify-content: space-between; + gap: var(--space-4); + margin: calc(-1 * var(--space-8)) calc(-1 * var(--space-10)) var(--space-4); + padding: var(--space-3) var(--space-10); + background-color: color-mix(in srgb, var(--color-bg-subtle) 82%, transparent); + backdrop-filter: blur(8px); + -webkit-backdrop-filter: blur(8px); + border-bottom: 1px solid var(--color-border); +} + +.topbar__path { + font-family: var(--font-family-mono); + font-size: 0.8125rem; + color: var(--color-text-muted); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + min-width: 0; +} + +.topbar__path a { color: var(--color-text-muted); text-decoration: none; } +.topbar__path a:hover { color: var(--color-link); text-decoration: underline; } +.topbar__root { color: var(--color-teal-700) !important; font-weight: var(--font-weight-bold); } +.topbar__sep { margin-inline: 0.2em; opacity: 0.5; } +.topbar__path [aria-current="page"] { color: var(--color-text); font-weight: var(--font-weight-bold); } + +.topbar__caret { + display: inline-block; + width: 0.5em; + height: 1.05em; + margin-left: 0.25em; + vertical-align: text-bottom; + background-color: var(--color-teal-500); + animation: topbar-caret 1.1s steps(1) infinite; +} + +@keyframes topbar-caret { 50% { opacity: 0; } } + +.topbar__status { + display: flex; + align-items: center; + gap: var(--space-3); + flex-shrink: 0; + font: var(--text-caption); + color: var(--color-text-muted); +} + +.topbar__live, +.topbar__idle { + display: inline-flex; + align-items: center; + gap: var(--space-2); + color: inherit; + text-decoration: none; +} + +.topbar__live { color: var(--color-teal-700); font-weight: var(--font-weight-bold); } + +.topbar__pulse, +.topbar__dot { + width: 0.5rem; + height: 0.5rem; + border-radius: 50%; + background-color: var(--color-gray-400); +} + +.topbar__pulse { + background-color: var(--color-teal-500); + box-shadow: 0 0 0 0 rgba(20, 168, 156, 0.5); + animation: topbar-pulse 1.6s ease-out infinite; +} + +@keyframes topbar-pulse { to { box-shadow: 0 0 0 0.5rem rgba(20, 168, 156, 0); } } + +.topbar__mode { + font-family: var(--font-family-mono); + font-size: 0.6875rem; + text-transform: uppercase; + letter-spacing: 0.08em; + padding: 0.125rem 0.5rem; + border: 1px solid var(--color-border); + border-radius: var(--radius-sm); +} + +@media (prefers-reduced-motion: reduce) { + .topbar__caret, .topbar__pulse { animation: none; } +} + +@media (max-width: 64rem) { + .topbar { margin: calc(-1 * var(--space-6)) calc(-1 * var(--space-4)) var(--space-5); padding-inline: var(--space-4); } + .topbar__mode { display: none; } +} + +[data-theme="dark"] .topbar__root { color: var(--color-teal-300) !important; } +[data-theme="dark"] .topbar__live { color: var(--color-teal-300); } + +/* ---------- Severity edge on finding rows ---------- + Rows that carry data-sev get a coloured left edge, so the worst items + are findable by scanning the margin. */ +.table tr[data-sev] td:first-child { box-shadow: inset 3px 0 0 var(--sev-edge, transparent); } +.table tr[data-sev="critical"] { --sev-edge: var(--color-error); } +.table tr[data-sev="high"] { --sev-edge: #e0742c; } +.table tr[data-sev="medium"] { --sev-edge: var(--color-amber-500); } +.table tr[data-sev="low"] { --sev-edge: var(--color-teal-500); } + + +/* ---------- Page header ---------- */ +.page-head { + display: grid; + grid-template-columns: auto minmax(0, 1fr) auto; + gap: var(--space-5); + align-items: start; + padding-bottom: var(--space-6); + margin-bottom: var(--space-6); + border-bottom: 1px solid var(--color-border); +} + +.page-head__tile { + width: 3rem; + height: 3rem; + border-radius: var(--radius-md); + display: inline-flex; + align-items: center; + justify-content: center; + color: var(--color-teal-300); + background-color: var(--color-primary-800); + background-image: linear-gradient(135deg, var(--color-primary-700), var(--color-primary-900)); + box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), var(--shadow-sm); +} + +.page-head__icon { width: 1.375rem; height: 1.375rem; } +.page-head__text { min-width: 0; } +.page-head__title { margin: var(--space-1) 0 0; } +.page-head__desc { + margin: var(--space-2) 0 0; + max-width: 62ch; + font: var(--text-body-sm); + color: var(--color-text-muted); +} +.page-head__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); align-self: center; } + +@media (max-width: 40rem) { + .page-head { grid-template-columns: auto minmax(0, 1fr); } + .page-head__actions { grid-column: 1 / -1; } +} + +/* ---------- Dashboard card grid ---------- */ +.card-grid > .card--full { grid-column: 1 / -1; } +.card-grid > .card--full .agent-list { + grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); + column-gap: var(--space-6); +} + +.coverage-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); + gap: var(--space-4) var(--space-6); +} + +.coverage-item { + display: grid; + gap: var(--space-1); + color: inherit; + text-decoration: none; + border-radius: var(--radius-sm); +} + +.coverage-item > div:first-child { display: flex; justify-content: space-between; } +.coverage-item:hover .ds-caption:first-child { color: var(--color-link); } +.coverage-item:focus-visible { outline: none; box-shadow: var(--shadow-focus); } diff --git a/src/secfoo/web/static/design-system/components/run-ui.css b/src/secfoo/web/static/design-system/components/run-ui.css new file mode 100644 index 0000000..66a51e3 --- /dev/null +++ b/src/secfoo/web/static/design-system/components/run-ui.css @@ -0,0 +1,279 @@ +/* + Run UI + ------ + Components for following and auditing a run: the live step checklist, + the run receipt, the "Blocked" card, agent health cards, starter + templates and the selectable skill catalog on Run Assessment, and the + sidebar theme switch. +*/ + +/* ---------- Run page layout ---------- */ +.run-top { + display: grid; + grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); + gap: var(--space-6); + margin-bottom: var(--space-6); +} + +@media (max-width: 56rem) { + .run-top { grid-template-columns: minmax(0, 1fr); } +} + +/* ---------- Step checklist ---------- */ +.run-steps { + list-style: none; + margin: 0; + padding: 0; +} + +.run-steps__item { + display: grid; + grid-template-columns: 1.25rem minmax(0, 1fr) auto; + gap: var(--space-3); + align-items: center; + padding-block: var(--space-3); + border-bottom: 1px dashed var(--color-border); + font: var(--text-body-sm); +} + +.run-steps__item:last-child { border-bottom: none; } + +.run-steps__dot { + width: 0.75rem; + height: 0.75rem; + border-radius: 50%; + border: 2px solid var(--color-border); + justify-self: center; +} + +.run-steps__item[data-state="done"] .run-steps__dot { background-color: var(--color-success); border-color: var(--color-success); } +.run-steps__item[data-state="failed"] .run-steps__dot { background-color: var(--color-error); border-color: var(--color-error); } +.run-steps__item[data-state="live"] .run-steps__dot { + border-color: var(--color-teal-500); + background-color: var(--color-teal-100); + animation: run-steps-pulse 1.4s ease-in-out infinite; +} +.run-steps__item[data-state="todo"] .run-steps__label { color: var(--color-text-muted); } +.run-steps__item[data-state="failed"] .run-steps__label { color: var(--color-error); font-weight: var(--font-weight-medium); } + +.run-steps__detail { + font: var(--text-caption); + color: var(--color-text-muted); + font-variant-numeric: tabular-nums; +} + +@keyframes run-steps-pulse { + 50% { box-shadow: 0 0 0 4px var(--color-teal-100); } +} + +@media (prefers-reduced-motion: reduce) { + .run-steps__item[data-state="live"] .run-steps__dot { animation: none; } +} + +.run-elapsed { + font-family: var(--font-family-mono); + font-variant-numeric: tabular-nums; +} + +/* ---------- Receipt ---------- */ +.receipt { + font-family: var(--font-family-mono); + font-size: 0.8125rem; + line-height: 1.8; + font-variant-numeric: tabular-nums; +} + +.receipt__line { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + gap: var(--space-4); + border-bottom: 1px dotted var(--color-border); +} + +.receipt__line > span:first-child { color: var(--color-text-muted); } +.receipt__line > span:last-child { margin-left: auto; text-align: right; overflow-wrap: anywhere; } + +.receipt__line--total { + border-bottom: none; + padding-top: var(--space-2); + font-weight: var(--font-weight-bold); +} + +.receipt__actions { + display: flex; + flex-wrap: wrap; + gap: var(--space-2); + margin-top: var(--space-4); +} + +/* ---------- Blocked card ---------- */ +.blocked-card { + border-left: 4px solid var(--color-error); + display: grid; + gap: var(--space-3); +} + +.blocked-card__title { font: var(--text-h4); margin: 0; } +.blocked-card__fix { + font-family: var(--font-family-mono); + font-size: 0.8125rem; + background-color: var(--color-bg-subtle); + border: 1px solid var(--color-border); + border-radius: var(--radius-md); + padding: var(--space-2) var(--space-3); + overflow-x: auto; + white-space: pre; +} + +/* ---------- Agent health ---------- */ +.agent-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); + gap: var(--space-4); +} + +.agent-card { + min-width: 0; + display: grid; + /* minmax(0, ...) so a long setup command scrolls inside its own box + instead of widening the whole card past its column. */ + grid-template-columns: minmax(0, 1fr); + gap: var(--space-2); + align-content: start; +} + +.agent-card__top { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + align-items: center; + gap: var(--space-2); +} + +.agent-card__name { font-weight: var(--font-weight-bold); } +.agent-card__id { font-family: var(--font-family-mono); font-size: 0.75rem; color: var(--color-text-muted); } + +.agent-list { + list-style: none; + margin: 0; + padding: 0; + display: grid; + gap: var(--space-2); +} + +.agent-list__item { + display: flex; + justify-content: space-between; + align-items: center; + gap: var(--space-3); + font: var(--text-body-sm); +} + +/* ---------- Starter templates + skill catalog ---------- */ +.starter-grid, +.skill-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); + gap: var(--space-3); +} + +.starter { + text-align: left; + font: inherit; + cursor: pointer; + background-color: var(--color-surface); + border: 1px solid var(--color-border); + border-radius: var(--radius-md); + padding: var(--space-3) var(--space-4); + display: grid; + gap: var(--space-1); + color: var(--color-text); + transition: border-color var(--duration-fast) var(--ease-standard); +} + +.starter:hover { border-color: var(--color-primary-400); } +.starter:focus-visible { outline: none; box-shadow: var(--shadow-focus); } +.starter[aria-pressed="true"] { border-color: var(--color-teal-500); box-shadow: inset 0 0 0 1px var(--color-teal-500); } +.starter__title { font-weight: var(--font-weight-bold); font-size: 0.9375rem; } +.starter__meta { font-family: var(--font-family-mono); font-size: 0.75rem; color: var(--color-text-muted); } + +.skill-card { + position: relative; + display: grid; + gap: var(--space-1); + align-content: start; + background-color: var(--color-surface); + border: 1px solid var(--color-border); + border-radius: var(--radius-md); + padding: var(--space-3) var(--space-4) var(--space-3) 2.75rem; + cursor: pointer; + transition: border-color var(--duration-fast) var(--ease-standard); +} + +.skill-card:hover { border-color: var(--color-primary-400); } +.skill-card input { + position: absolute; + left: var(--space-4); + top: calc(var(--space-3) + 0.2rem); + accent-color: var(--color-teal-500); +} +.skill-card:has(input:checked) { border-color: var(--color-teal-500); box-shadow: inset 0 0 0 1px var(--color-teal-500); } +.skill-card:has(input:focus-visible) { box-shadow: var(--shadow-focus); } +.skill-card__name { font-weight: var(--font-weight-bold); font-size: 0.9375rem; } +.skill-card__desc { + font: var(--text-caption); + color: var(--color-text-muted); + display: -webkit-box; + -webkit-line-clamp: 3; + -webkit-box-orient: vertical; + overflow: hidden; +} + +/* ---------- Collapsible form section ---------- */ +.form-more { + border-top: 1px solid var(--color-border); + padding-top: var(--space-4); + margin-top: var(--space-2); +} + +.form-more > summary { + cursor: pointer; + font: var(--text-body-sm); + font-weight: var(--font-weight-medium); + color: var(--color-link); + margin-bottom: var(--space-4); +} + +/* ---------- Review (sign-off) ---------- */ +.review-actions { + display: flex; + flex-wrap: wrap; + gap: var(--space-2); +} + +.review-actions form { margin: 0; } + +/* ---------- Theme switch ---------- */ +.theme-switch { + margin-top: auto; + padding-top: var(--space-6); + display: grid; + gap: var(--space-2); +} + +.theme-switch .segmented { width: 100%; justify-content: space-between; } +.theme-switch .segmented__option { padding-inline: var(--space-3); } + +@media (max-width: 64rem) { + .theme-switch { margin-top: 0; padding-top: 0; margin-left: auto; } + .theme-switch .sidebar__section-label { display: none; } +} + +/* Dashboard cards that hold a table scroll it inside the card rather than + pushing the whole page sideways. */ +.card-grid > .card { min-width: 0; overflow-x: auto; } + +@media (min-width: 72rem) { + .card-grid > .card--wide { grid-column: span 2; } +} diff --git a/src/secfoo/web/static/design-system/components/sidebar.css b/src/secfoo/web/static/design-system/components/sidebar.css index 53d2ae6..8e321ad 100644 --- a/src/secfoo/web/static/design-system/components/sidebar.css +++ b/src/secfoo/web/static/design-system/components/sidebar.css @@ -13,13 +13,28 @@ } .sidebar { - width: 16rem; + /* Always the brand-dark petrol surface, in light and dark theme alike: + the shell frames the content rather than competing with it. */ + --sidebar-bg: var(--color-primary-900); + --sidebar-text: rgba(255, 255, 255, 0.66); + --sidebar-text-strong: var(--color-white); + --sidebar-hover: rgba(255, 255, 255, 0.06); + --sidebar-active: rgba(111, 217, 204, 0.12); + --sidebar-rule: rgba(255, 255, 255, 0.08); + width: 15.5rem; flex-shrink: 0; display: flex; flex-direction: column; - background-color: var(--color-surface); - border-right: 1px solid var(--color-border); - padding: var(--space-6) var(--space-4); + background-color: var(--sidebar-bg); + background-image: linear-gradient(180deg, rgba(20, 168, 156, 0.08), transparent 18rem); + color: var(--sidebar-text); + padding: var(--space-6) var(--space-3); + position: sticky; + top: 0; + height: 100vh; + overflow-y: auto; + --brand-ink: var(--color-white); + --brand-signal: var(--color-teal-300); } .sidebar__brand { @@ -27,7 +42,7 @@ align-items: center; gap: var(--space-2); font: var(--text-h4); - color: var(--color-text); + color: var(--sidebar-text-strong); text-decoration: none; padding-inline: var(--space-2); margin-bottom: var(--space-8); @@ -39,27 +54,38 @@ padding: 0; display: flex; flex-direction: column; - gap: var(--space-1); + gap: 2px; } .sidebar__link { display: flex; align-items: center; - gap: var(--space-3); - padding-block: var(--space-3); + gap: 0.625rem; + padding-block: 0.5rem; padding-inline: var(--space-3); - border-radius: var(--radius-md); + border-radius: var(--radius-sm); font: var(--text-body-sm); font-weight: var(--font-weight-medium); - color: var(--color-text-muted); + color: var(--sidebar-text); text-decoration: none; + position: relative; transition: background-color var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard); } +.sidebar__icon { + width: 1rem; + height: 1rem; + flex-shrink: 0; + opacity: 0.6; + transition: opacity var(--duration-fast) var(--ease-standard); +} + +.sidebar__link:hover .sidebar__icon { opacity: 0.85; } + .sidebar__link:hover { - background-color: var(--color-bg-subtle); - color: var(--color-text); + background-color: var(--sidebar-hover); + color: var(--sidebar-text-strong); } .sidebar__link:focus-visible { @@ -68,44 +94,74 @@ } .sidebar__link[aria-current="page"] { - background-color: var(--color-primary-50); - color: var(--color-primary-700); + background-color: var(--sidebar-active); + color: var(--sidebar-text-strong); font-weight: var(--font-weight-bold); - box-shadow: inset 3px 0 0 var(--color-primary-700); +} + +.sidebar__link[aria-current="page"] .sidebar__icon { + opacity: 1; + color: var(--color-teal-300); +} + +.sidebar__link { font-size: 0.84375rem; letter-spacing: 0.005em; } + +.sidebar__link[aria-current="page"]::before { + content: ""; + position: absolute; + left: calc(-1 * var(--space-3)); + top: 0.5rem; + bottom: 0.5rem; + width: 3px; + border-radius: 0 3px 3px 0; + background-color: var(--color-teal-300); } .sidebar__divider { border: none; - border-top: 1px solid var(--color-border); - margin-block: var(--space-6); + border-top: 1px solid var(--sidebar-rule); + margin-block: var(--space-5); } .sidebar__section-label { font: var(--text-overline); + font-size: 0.6875rem; letter-spacing: var(--overline-letter-spacing); text-transform: uppercase; - color: var(--color-text-muted); + color: rgba(255, 255, 255, 0.4); padding-inline: var(--space-3); margin-bottom: var(--space-2); display: block; } +.sidebar .segmented { background-color: rgba(0, 0, 0, 0.25); } +.sidebar .segmented__option { color: var(--sidebar-text); } +.sidebar .segmented__option:hover { color: var(--sidebar-text-strong); } +.sidebar .segmented__option[aria-selected="true"] { + background-color: var(--color-teal-500); + color: var(--color-primary-900); +} + .app-shell__main { flex: 1; min-width: 0; - padding: var(--space-8); + padding: var(--space-8) var(--space-10); } @media (max-width: 64rem) { .app-shell { flex-direction: column; } .sidebar { width: 100%; + height: auto; + position: static; flex-direction: row; align-items: center; overflow-x: auto; - border-right: none; - border-bottom: 1px solid var(--color-border); + padding: var(--space-3) var(--space-4); } + .sidebar nav { display: flex; } + .app-shell__main { padding: var(--space-6) var(--space-4); } + .sidebar__link[aria-current="page"]::before { display: none; } .sidebar__brand { margin-bottom: 0; margin-right: var(--space-4); } .sidebar__nav { flex-direction: row; } .sidebar__divider, .sidebar__section-label { display: none; } diff --git a/src/secfoo/web/static/design-system/components/stat-card.css b/src/secfoo/web/static/design-system/components/stat-card.css index 63a57bc..b7b1274 100644 --- a/src/secfoo/web/static/design-system/components/stat-card.css +++ b/src/secfoo/web/static/design-system/components/stat-card.css @@ -5,40 +5,69 @@ */ .stat-card { + --stat-accent: var(--color-primary-600); + --stat-accent-bg: var(--color-primary-50); + position: relative; background-color: var(--color-surface); border: 1px solid var(--color-border); - border-top: 3px solid var(--color-primary-700); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); - padding: var(--space-6); - display: flex; - flex-direction: column; - gap: var(--space-3); - transition: box-shadow var(--duration-base) var(--ease-standard); + padding: var(--space-5); + display: grid; + grid-template-columns: auto minmax(0, 1fr); + grid-template-areas: "icon value" "icon label"; + column-gap: var(--space-4); + row-gap: var(--space-1); + align-items: center; + overflow: hidden; + transition: box-shadow var(--duration-base) var(--ease-standard), + transform var(--duration-base) var(--ease-standard); +} + +.stat-card::after { + content: ""; + position: absolute; + inset: auto 0 0 0; + height: 3px; + background: var(--stat-accent); + opacity: 0.85; } +a.stat-card:hover, .stat-card:hover { box-shadow: var(--shadow-md); + transform: translateY(-1px); } +.stat-card--teal { --stat-accent: var(--color-teal-500); --stat-accent-bg: var(--color-teal-100); } +.stat-card--amber { --stat-accent: var(--color-amber-500); --stat-accent-bg: var(--color-amber-100); } +.stat-card--error { --stat-accent: var(--color-error); --stat-accent-bg: var(--color-error-bg); } + .stat-card__icon { - width: 2.5rem; - height: 2.5rem; + grid-area: icon; + width: 2.75rem; + height: 2.75rem; border-radius: var(--radius-md); - background-color: var(--color-primary-50); - color: var(--color-primary-700); + background-color: var(--stat-accent-bg); + color: var(--stat-accent); display: inline-flex; align-items: center; justify-content: center; font-size: 1.25rem; } +.stat-card__icon svg { width: 1.375rem; height: 1.375rem; } + .stat-card__value { - font: var(--text-h2); + grid-area: value; + font: 700 1.75rem/1.1 var(--font-family-base); + letter-spacing: -0.02em; + font-variant-numeric: tabular-nums; color: var(--color-text); } .stat-card__label { + grid-area: label; font: var(--text-body-sm); font-weight: var(--font-weight-medium); color: var(--color-text-muted); @@ -46,6 +75,12 @@ .stat-card-grid { display: grid; - grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); - gap: var(--space-5); + grid-template-columns: repeat(auto-fit, minmax(12.5rem, 1fr)); + gap: var(--space-4); +} + +/* Cards without an icon (activity dashboards) drop the icon column. */ +.stat-card:not(:has(.stat-card__icon)) { + grid-template-columns: minmax(0, 1fr); + grid-template-areas: "value" "label"; } diff --git a/src/secfoo/web/static/design-system/components/tables.css b/src/secfoo/web/static/design-system/components/tables.css index 9db1f77..a129986 100644 --- a/src/secfoo/web/static/design-system/components/tables.css +++ b/src/secfoo/web/static/design-system/components/tables.css @@ -6,8 +6,10 @@ .table-wrap { width: 100%; overflow-x: auto; - border-radius: var(--radius-md); + border-radius: var(--radius-lg); border: 1px solid var(--color-border); + background-color: var(--color-surface); + box-shadow: var(--shadow-sm); } .table { @@ -18,21 +20,29 @@ .table th { text-align: left; - background-color: var(--color-primary-800); - color: var(--color-white); - font-weight: var(--font-weight-bold); + background-color: var(--color-bg-subtle); + color: var(--color-text-muted); + font: var(--text-overline); + font-size: 0.6875rem; + letter-spacing: var(--overline-letter-spacing); + text-transform: uppercase; padding: var(--space-3) var(--space-4); + border-bottom: 1px solid var(--color-border); + white-space: nowrap; } .table td { - padding: var(--space-3) var(--space-4); + padding: var(--space-4); border-top: 1px solid var(--color-border); + vertical-align: middle; } -.table tbody tr:nth-child(even) { - background-color: var(--color-primary-50); +.table tbody tr:first-child td { border-top: none; } + +.table tbody tr { + transition: background-color var(--duration-fast) var(--ease-standard); } .table tbody tr:hover { - background-color: var(--color-teal-100); + background-color: var(--color-primary-50); } diff --git a/src/secfoo/web/static/design-system/components/workflow.css b/src/secfoo/web/static/design-system/components/workflow.css new file mode 100644 index 0000000..72895b4 --- /dev/null +++ b/src/secfoo/web/static/design-system/components/workflow.css @@ -0,0 +1,305 @@ +/* + Workflow + -------- + The assessment review pipeline, the dashboard's getting-started + checklist, and the top bar search / command palette. +*/ + +/* ---------- Review pipeline (assessment page) ---------- + The activities in review order as a chain of nodes joined by a rail; + the rail after each node takes that node's state colour. */ +.pipeline { margin-block: var(--space-6) var(--space-8); } + +.pipeline__head { + display: flex; + justify-content: space-between; + align-items: baseline; + gap: var(--space-4); + flex-wrap: wrap; + margin-bottom: var(--space-4); +} + +.pipeline__summary { font: var(--text-body-sm); color: var(--color-text-muted); font-variant-numeric: tabular-nums; } +.pipeline__summary--blocked { color: var(--color-error); font-weight: var(--font-weight-bold); } + +.pipeline__track { + list-style: none; + margin: 0; + padding: 0 0 var(--space-2); + display: grid; + grid-auto-flow: column; + grid-auto-columns: minmax(10.5rem, 1fr); + gap: var(--space-4); + overflow-x: auto; +} + +.pipeline__node { + --node: var(--color-gray-300); + position: relative; + min-width: 0; +} + +.pipeline__node[data-state="done"] { --node: var(--color-success); } +.pipeline__node[data-state="blocked"] { --node: var(--color-error); } +.pipeline__node[data-state="running"] { --node: var(--color-teal-500); } + +.pipeline__node:not(:last-child)::after { + content: ""; + position: absolute; + top: 1.45rem; + right: calc(-1 * var(--space-4)); + width: var(--space-4); + height: 2px; + background-color: var(--node); + opacity: 0.6; +} + +.pipeline__card { + display: grid; + gap: var(--space-2); + height: 100%; + padding: var(--space-4); + border-radius: var(--radius-lg); + border: 1px solid var(--color-border); + border-top: 3px solid var(--node); + background-color: var(--color-surface); + box-shadow: var(--shadow-sm); + color: inherit; + text-decoration: none; + transition: box-shadow var(--duration-base) var(--ease-standard), transform var(--duration-base) var(--ease-standard); +} + +.pipeline__card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); } +.pipeline__card:focus-visible { outline: none; box-shadow: var(--shadow-focus); } + +.pipeline__node[data-state="todo"] .pipeline__card { + border-style: dashed; + border-top-style: solid; + background-color: transparent; + box-shadow: none; +} + +.pipeline__top { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); } +.pipeline__step { font: 700 0.75rem/1 var(--font-family-mono); color: var(--color-text-muted); } + +.pipeline__state { + display: inline-flex; + align-items: center; + font: var(--text-overline); + font-size: 0.625rem; + letter-spacing: var(--overline-letter-spacing); + text-transform: uppercase; + color: var(--node); +} + +.pipeline__node[data-state="todo"] .pipeline__state { color: var(--color-text-muted); } + +.pipeline__node[data-state="running"] .pipeline__state::before { + content: ""; + width: 0.4rem; + height: 0.4rem; + margin-right: 0.35rem; + border-radius: 50%; + background-color: currentColor; + animation: topbar-pulse 1.6s ease-out infinite; +} + +.pipeline__label { display: flex; align-items: center; gap: var(--space-2); font-weight: var(--font-weight-bold); font-size: 0.9375rem; } +.pipeline__icon { color: var(--color-text-muted); flex-shrink: 0; } +.pipeline__meta { font: var(--text-caption); color: var(--color-text-muted); } +.pipeline__meta strong { color: var(--color-error); } + +/* ---------- Getting-started checklist ---------- */ +.setup { + margin-top: var(--space-6); + padding: var(--space-6); + border-radius: var(--radius-xl); + border: 1px solid var(--color-border); + background-color: var(--color-surface); + box-shadow: var(--shadow-sm); +} + +.setup__head { + display: flex; + justify-content: space-between; + align-items: flex-end; + gap: var(--space-6); + flex-wrap: wrap; + margin-bottom: var(--space-5); +} + +.setup__progress { display: grid; gap: var(--space-2); min-width: 10rem; text-align: right; } +.setup__count { font: 700 1.25rem/1 var(--font-family-mono); font-variant-numeric: tabular-nums; } +.setup__bar { display: block; height: 6px; border-radius: var(--radius-pill); background-color: var(--color-gray-100); overflow: hidden; } +.setup__bar > span { display: block; height: 100%; background-color: var(--color-teal-500); border-radius: inherit; } + +.setup__steps { + list-style: none; + margin: 0; + padding: 0; + display: grid; + grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); + gap: var(--space-3); +} + +.setup__step a { + display: grid; + grid-template-columns: auto minmax(0, 1fr); + gap: var(--space-3); + align-items: start; + height: 100%; + padding: var(--space-4); + border-radius: var(--radius-md); + border: 1px solid var(--color-border); + color: inherit; + text-decoration: none; + transition: border-color var(--duration-fast) var(--ease-standard), background-color var(--duration-fast) var(--ease-standard); +} + +.setup__step a:hover { border-color: var(--color-primary-400); background-color: var(--color-bg-subtle); } + +.setup__num { + width: 1.75rem; + height: 1.75rem; + border-radius: 50%; + display: inline-flex; + align-items: center; + justify-content: center; + font: 700 0.8125rem/1 var(--font-family-mono); + border: 1.5px solid var(--color-primary-400); + color: var(--color-primary-600); +} + +.setup__step[data-done="true"] .setup__num { background-color: var(--color-success); border-color: var(--color-success); color: var(--color-white); } +.setup__step[data-done="true"] strong { text-decoration: line-through; text-decoration-color: var(--color-text-muted); color: var(--color-text-muted); } +.setup__text { display: grid; gap: 2px; font: var(--text-body-sm); } +.setup__text span { font: var(--text-caption); color: var(--color-text-muted); } + +/* ---------- Top bar search + command palette ---------- */ +.topbar__search { + margin-left: auto; + margin-right: var(--space-4); + display: inline-flex; + align-items: center; + gap: var(--space-2); + min-width: 15rem; + padding: 0.375rem 0.5rem 0.375rem 0.625rem; + border-radius: var(--radius-sm); + border: 1px solid var(--color-border); + background-color: var(--color-surface); + color: var(--color-text-muted); + font: var(--text-caption); + cursor: pointer; +} + +.topbar__search span { flex: 1; text-align: left; } +.topbar__search:hover { border-color: var(--color-primary-400); color: var(--color-text); } +.topbar__search:focus-visible { outline: none; box-shadow: var(--shadow-focus); } + +kbd { + font: 600 0.6875rem/1 var(--font-family-mono); + padding: 0.1875rem 0.375rem; + border-radius: 4px; + border: 1px solid var(--color-border); + border-bottom-width: 2px; + background-color: var(--color-bg-subtle); + color: var(--color-text-muted); +} + +.palette { + padding: 0; + border: none; + background: transparent; + width: min(36rem, calc(100vw - 2rem)); + margin-top: 12vh; + color: var(--color-text); +} + +.palette::backdrop { background-color: rgba(4, 22, 30, 0.45); backdrop-filter: blur(3px); } + +.palette__box { + border-radius: var(--radius-lg); + border: 1px solid var(--color-border); + background-color: var(--color-surface); + box-shadow: var(--shadow-lg), 0 0 0 1px rgba(20, 168, 156, 0.08); + overflow: hidden; +} + +.palette__field { + display: flex; + align-items: center; + gap: var(--space-3); + padding: var(--space-4); + border-bottom: 1px solid var(--color-border); + color: var(--color-text-muted); +} + +.palette__input { + flex: 1; + border: none; + outline: none; + background: transparent; + font: var(--text-body); + color: var(--color-text); +} + +.palette__list { list-style: none; margin: 0; padding: var(--space-2); max-height: 22rem; overflow-y: auto; } + +.palette__group { + padding: var(--space-3) var(--space-3) var(--space-1); + font: var(--text-overline); + font-size: 0.625rem; + letter-spacing: var(--overline-letter-spacing); + text-transform: uppercase; + color: var(--color-text-muted); +} + +.palette__item { + display: flex; + justify-content: space-between; + align-items: center; + gap: var(--space-4); + padding: 0.5625rem var(--space-3); + border-radius: var(--radius-sm); + font: var(--text-body-sm); + cursor: pointer; +} + +.palette__item[aria-selected="true"] { + background-color: var(--color-primary-50); + color: var(--color-primary-800); + box-shadow: inset 2px 0 0 var(--color-teal-500); +} + +.palette__hint { font: 0.6875rem/1 var(--font-family-mono); color: var(--color-text-muted); } +.palette__empty { margin: 0; padding: var(--space-6); text-align: center; font: var(--text-body-sm); color: var(--color-text-muted); } + +.palette__foot { + display: flex; + gap: var(--space-5); + padding: var(--space-3) var(--space-4); + border-top: 1px solid var(--color-border); + font: var(--text-caption); + color: var(--color-text-muted); + background-color: var(--color-bg-subtle); +} + +.palette__foot kbd { margin-right: 2px; } + +@media (max-width: 64rem) { + .topbar__search { min-width: 0; margin-right: var(--space-2); } + .topbar__search span, + .topbar__search kbd { display: none; } +} + +/* ---------- Dark theme ---------- */ +[data-theme="dark"] .setup__bar { background-color: rgba(255, 255, 255, 0.08); } +[data-theme="dark"] .setup__num { border-color: var(--color-primary-300); color: var(--color-primary-200); } +[data-theme="dark"] .palette__item[aria-selected="true"] { background-color: #0f3a4c; color: var(--color-white); } + +/* Soft teal glow on hover for raised cards in dark theme. */ +[data-theme="dark"] .pipeline__card:hover, +[data-theme="dark"] .stat-card:hover, +[data-theme="dark"] .setup__step a:hover { + box-shadow: 0 0 0 1px rgba(111, 217, 204, 0.18), 0 8px 28px rgba(20, 168, 156, 0.12); +} diff --git a/src/secfoo/web/static/design-system/design-system.css b/src/secfoo/web/static/design-system/design-system.css index 1f19a9c..c452a36 100644 --- a/src/secfoo/web/static/design-system/design-system.css +++ b/src/secfoo/web/static/design-system/design-system.css @@ -26,3 +26,7 @@ @import url("./components/conformance-bar.css"); @import url("./components/stacked-bar.css"); @import url("./components/donut.css"); +@import url("./components/run-ui.css"); +@import url("./components/dashboard.css"); +@import url("./components/workflow.css"); +@import url("./components/dark.css"); diff --git a/src/secfoo/web/static/design-system/tokens.css b/src/secfoo/web/static/design-system/tokens.css index 9548405..f75d4e0 100644 --- a/src/secfoo/web/static/design-system/tokens.css +++ b/src/secfoo/web/static/design-system/tokens.css @@ -57,7 +57,7 @@ /* ---------- Color: Semantic role mapping ---------- */ --color-bg: var(--color-white); - --color-bg-subtle: var(--color-gray-50); + --color-bg-subtle: #f3f6f7; --color-surface: var(--color-white); --color-border: var(--color-gray-200); --color-text: var(--color-gray-900); @@ -77,10 +77,10 @@ --font-weight-bold: 700; --text-display: 400 3.25rem/1.1 var(--font-family-base); - --text-h1: 400 2.5rem/1.15 var(--font-family-base); - --text-h2: 400 2rem/1.2 var(--font-family-base); - --text-h3: 600 1.5rem/1.25 var(--font-family-base); - --text-h4: 600 1.25rem/1.3 var(--font-family-base); + --text-h1: 700 2rem/1.2 var(--font-family-base); + --text-h2: 650 1.375rem/1.3 var(--font-family-base); + --text-h3: 600 1.125rem/1.35 var(--font-family-base); + --text-h4: 600 1rem/1.4 var(--font-family-base); --text-body-lg: 400 1.125rem/1.6 var(--font-family-base); --text-body: 400 1rem/1.6 var(--font-family-base); --text-body-sm: 400 0.875rem/1.5 var(--font-family-base); @@ -114,8 +114,8 @@ --radius-circle: 50%; /* ---------- Shadow (soft, brand-tinted) ---------- */ - --shadow-sm: 0 1px 3px rgba(7, 39, 54, 0.08); - --shadow-md: 0.25rem 0.25rem 1.25rem rgba(7, 39, 54, 0.08); + --shadow-sm: 0 1px 2px rgba(7, 39, 54, 0.04), 0 2px 8px rgba(7, 39, 54, 0.05); + --shadow-md: 0 4px 12px rgba(7, 39, 54, 0.07), 0 12px 32px rgba(7, 39, 54, 0.06); --shadow-lg: 0.625rem 0.625rem 2.5rem rgba(7, 39, 54, 0.10); --shadow-focus: 0 0 0 3px rgba(20, 168, 156, 0.35); @@ -143,6 +143,15 @@ --color-text-muted: var(--color-gray-300); --color-link: var(--color-teal-300); --color-link-hover: var(--color-teal-100); + --color-success: #6fcf97; + --color-success-bg: #12321f; + --color-warning: #f0bd7c; + --color-warning-bg: #3a2a14; + --color-error: #f08a82; + --color-error-bg: #3d1a18; + --color-info: var(--color-primary-200); + --color-info-bg: #0f3a4c; + color-scheme: dark; } /* ---------- Secfoo brand layer ---------- */ diff --git a/src/secfoo/web/static/js/live-run.js b/src/secfoo/web/static/js/live-run.js new file mode 100644 index 0000000..dc33e84 --- /dev/null +++ b/src/secfoo/web/static/js/live-run.js @@ -0,0 +1,84 @@ +// Live progress for in-flight runs, replacing the old 5-second full-page +// . +// +// Markup contract: +//
    with
  1. +// children -- the step list is re-rendered from the JSON each poll. +// -- ticks up once a second. +//
    -- on a page listing several runs +// (assessment detail), polls each and reloads the page once any of +// them finishes, so the new findings and report show up. +(function () { + var POLL_MS = 3000; + + function fmt(seconds) { + seconds = Math.max(0, Math.floor(seconds)); + var m = Math.floor(seconds / 60); + var s = seconds % 60; + return m + "m " + (s < 10 ? "0" : "") + s + "s"; + } + + function tickElapsed() { + var nodes = document.querySelectorAll("[data-elapsed]"); + nodes.forEach(function (node) { + if (node.getAttribute("data-elapsed-frozen") === "true") return; + var value = parseFloat(node.getAttribute("data-elapsed")) + 1; + node.setAttribute("data-elapsed", String(value)); + node.textContent = fmt(value); + }); + } + + function renderSteps(list, steps) { + var items = list.querySelectorAll("[data-step]"); + steps.forEach(function (step, i) { + var item = items[i]; + if (!item) return; + item.setAttribute("data-state", step.state); + var label = item.querySelector(".run-steps__label"); + var detail = item.querySelector(".run-steps__detail"); + if (label) label.textContent = step.label; + if (detail && step.state !== "live") detail.textContent = step.detail || ""; + }); + } + + function pollRun(list) { + var url = list.getAttribute("data-live-run"); + fetch(url, { headers: { Accept: "application/json" } }) + .then(function (r) { return r.ok ? r.json() : null; }) + .then(function (data) { + if (!data) return; + renderSteps(list, data.steps); + if (!data.active) { + window.location.reload(); + return; + } + setTimeout(function () { pollRun(list); }, POLL_MS); + }) + .catch(function () { setTimeout(function () { pollRun(list); }, POLL_MS * 2); }); + } + + function pollMany(node) { + var ids = node.getAttribute("data-live-runs").split(",").filter(Boolean); + Promise.all(ids.map(function (id) { + return fetch("/runs/" + id + "/status.json").then(function (r) { return r.ok ? r.json() : { active: false }; }); + })) + .then(function (results) { + if (results.some(function (r) { return !r.active; })) { + window.location.reload(); + return; + } + setTimeout(function () { pollMany(node); }, POLL_MS); + }) + .catch(function () { setTimeout(function () { pollMany(node); }, POLL_MS * 2); }); + } + + document.addEventListener("DOMContentLoaded", function () { + if (document.querySelector("[data-elapsed]")) setInterval(tickElapsed, 1000); + document.querySelectorAll("[data-live-run]").forEach(function (list) { + setTimeout(function () { pollRun(list); }, POLL_MS); + }); + document.querySelectorAll("[data-live-runs]").forEach(function (node) { + setTimeout(function () { pollMany(node); }, POLL_MS); + }); + }); +})(); diff --git a/src/secfoo/web/static/js/palette.js b/src/secfoo/web/static/js/palette.js new file mode 100644 index 0000000..feb0442 --- /dev/null +++ b/src/secfoo/web/static/js/palette.js @@ -0,0 +1,131 @@ +// Command palette: Ctrl/Cmd+K (or "/") opens a filterable list of every +// sidebar page plus a few actions; arrow keys move, Enter opens, Esc +// closes. Items come from the page itself (sidebar links + the dialog's +//