feat(dashboard): open findings by type and folder as clickable charts (#957) #964

Merged
sharang merged 1 commits from feat/957-findings-view into main 2026-11-10 15:40:06 +00:00
Owner

What changed

The "Befunde" view of #957: the findings page of one target (/findings?target=<id>) now opens with two charts of the target's open findings. Each chart element is a link, and its filter goes into the URL.

  1. Open findings by type: one horizontal bar per finding type (the scan_type the list already filters by), as long as its share of the largest type. Each bar is stacked by severity with a 2px gap, on one red scale: kritisch #7E2318, hoch #B3452F, mittel #D9765F, niedrig #E8A08C, and info #EDEFF7 with a hairline. There is a legend and a total at the end of each bar. Every segment is a real <button> with aria-label "Datenschutz, mittel: 9".
  2. Where the findings are: a flex-wrap tree map of the folders. Each tile is a <button> whose flex-grow is its open count, coloured by its most severe finding, with white text on the two darkest colours. Open findings in no file (CVEs in dependencies, DAST) are not in the map, and a note gives their number.
  3. Behind a click: the list is filtered to target + type + severity, or to target + folder. The page then shows a breadcrumb "Befunde › Datenschutz · mittel" (or "Befunde › src/api/") and "← Zurück zum Diagramm" in place of the charts.
  4. Table toggle: an aria-pressed toggle called "Tabelle" shows the same numbers as two tables. Every non-zero count in them opens its list too.

New files: compliance-core/src/finding_breakdown.rs (shared DTO and the pure counting function), compliance-agent/src/api/handlers/finding_breakdown.rs, compliance-dashboard/src/components/finding_breakdown.rs, compliance-dashboard/src/infrastructure/finding_breakdown.rs. The texts are in a new finding_breakdown module at the end of texts.rs, and the styles are .fb-* classes at the end of main.css.

API

GET /api/v1/targets/{id}/finding-breakdown is tenant-scoped through tenant_db like GET /api/v1/findings. As a GET it is read-gated by the role middleware (a row was added to role_gate/router_tests.rs). It is not added to the API-key KEY_SCOPES.

{ "data": {
    "by_type": [ { "scan_type": "gdpr",
                   "counts": { "critical": 0, "high": 2, "medium": 9, "low": 1, "info": 0 } } ],
    "folders": [ { "path": "src/api/", "count": 7, "worst": "high" },
                 { "path": "src/*",    "count": 2, "worst": "medium" },
                 { "path": "/",        "count": 1, "worst": "low" } ],
    "without_file": 3,
    "total": 15 },
  "total": 15 }
  • by_type is sorted by most findings first, then by type name. folders is sorted by most findings, then by path. The order therefore does not depend on Mongo's cursor order.
  • The handler projects scan_type, severity and file_path of the open findings, and compliance_core::finding_breakdown::breakdown counts them. That one pure function is unit-tested.
  • Folders: a folder is the top-level directory (docs/). When one top-level directory holds more than half of the open findings that have a file, and it has subfolders with findings, it is shown two levels deep (src/api/), and the files directly in it become src/*. Files in the root are /.

"Open"

Open means undecided: Open, Triaged and NeedsReview. These are the statuses of ISSUE_STATUSES in pipeline/issue_creation.rs, i.e. findings that still get a tracker issue. The list is OPEN_STATUSES in core, with a test pinning it. Resolved, false-positive (rule or mapping), accepted-risk and ignored findings are decided and not counted.

So that the list behind a chart shows the findings the chart counted, the findings list API takes status=undecided ($in the three statuses). The status select gains an "Offen (unentschieden)" entry, and a URL with a chart filter starts the list on it.

URL filters

The route is now #[route("/findings?:scan_type&:severity&:path&:target")]. The three new fields are Option<String>, so a link without a chart filter keeps its old form /findings?target=<id>, and old links still parse. target comes last because the router writes & after each argument that is set, and the macro wants the fields in the order of the arguments. Examples:

  • /findings?scan_type=gdpr&severity=medium&target=<id>
  • /findings?path=src/api/&target=<id>, path=src/* (only the files directly in src), path=/ (the root)

The findings list API takes an optional path filter. q cannot express "under folder X": it is unanchored, case-insensitive, and OR'd with title, description and rule. dto::path_regex builds an anchored literal regex with literal_regex:

key regex
/ ^/?[^/]+$
src/* ^/?src/[^/]+$
src/ or src ^/?src/

There is no i option. Stored paths are relative already (source_text::relative_path); the /? only tolerates a leading slash, which the chart ignores too.

FindingsPage keeps its hooks when only the query changes. A use_reactive effect therefore moves the URL's filters into the page's filter signals, writing only on a real change. The severity, type and status selects now mark the selected option, so they show what the URL set.

Note for other branches: Route::FindingsPage now has four fields, so a Route::FindingsPage { target } literal no longer compiles. The new Route::findings(target) builds the plain list link. The 7 existing call sites use it now (one-line changes in sidebar, demo_targets, scan_runs, overview, target, targets and onboarding). A branch that adds such a link (e.g. #952 on overview, targets or target) needs the same one-line change after rebasing.

The edits to pages/findings.rs are kept small (the props, seeding the signals and the effect, mounting the component, path in the query, and selected on options), because #958 and #961 (#951) also edit that file.

How tested

  • cargo fmt --all --check: clean
  • cargo clippy -D warnings: compliance-core, compliance-agent, compliance-dashboard --features server and compliance-dashboard --features web, all with --all-targets: clean
  • Unit tests:
    • core finding_breakdown: the open-status set, severity order, per-type counts and their order, top-level folders with root files as /, the two-level split and its >50% threshold (half is not most), no split without subfolders, findings in no file, worst severity, JSON round trip, and a doc test
    • agent: path_regex (anchored, literal, /, src/*, no srcfoo/ match), FindingsFilter.path, status=undecided, the breakdown's Mongo filter, and the role-gate router tests with the new route
    • dashboard: the route round trip with the chart filters (old links, argument order, path=/ and src/*), segment and tile routes, the breadcrumb, the list's status behind a chart, the texts, and the target-id guard; the whole dashboard lib suite passes (133 tests)
  • Not tested against a live database or in a browser; that is left for review on stage.

Open points

  • Folder names with & or = cannot be carried by the Dioxus query parser (it decodes before splitting). Such a folder's link would lose the filter.
  • When a user changes a select while a chart filter is in the URL, the breadcrumb still names the URL filter. "Zurück" resets it.
  • The breadcrumb does not name the target ("Repo › Ansicht › Auswahl" from the issue). That fits better once the per-repo tabs (#952) exist.

Part of #957

🤖 Generated with Claude Code

## What changed The "Befunde" view of #957: the findings page of one target (`/findings?target=<id>`) now opens with two charts of the target's **open** findings. Each chart element is a link, and its filter goes into the URL. 1. **Open findings by type**: one horizontal bar per finding type (the `scan_type` the list already filters by), as long as its share of the largest type. Each bar is stacked by severity with a 2px gap, on one red scale: kritisch `#7E2318`, hoch `#B3452F`, mittel `#D9765F`, niedrig `#E8A08C`, and info `#EDEFF7` with a hairline. There is a legend and a total at the end of each bar. Every segment is a real `<button>` with `aria-label` "Datenschutz, mittel: 9". 2. **Where the findings are**: a flex-wrap tree map of the folders. Each tile is a `<button>` whose `flex-grow` is its open count, coloured by its most severe finding, with white text on the two darkest colours. Open findings in no file (CVEs in dependencies, DAST) are not in the map, and a note gives their number. 3. **Behind a click**: the list is filtered to target + type + severity, or to target + folder. The page then shows a breadcrumb "Befunde › Datenschutz · mittel" (or "Befunde › src/api/") and "← Zurück zum Diagramm" in place of the charts. 4. **Table toggle**: an `aria-pressed` toggle called "Tabelle" shows the same numbers as two tables. Every non-zero count in them opens its list too. New files: `compliance-core/src/finding_breakdown.rs` (shared DTO and the pure counting function), `compliance-agent/src/api/handlers/finding_breakdown.rs`, `compliance-dashboard/src/components/finding_breakdown.rs`, `compliance-dashboard/src/infrastructure/finding_breakdown.rs`. The texts are in a new `finding_breakdown` module at the end of `texts.rs`, and the styles are `.fb-*` classes at the end of `main.css`. ## API `GET /api/v1/targets/{id}/finding-breakdown` is tenant-scoped through `tenant_db` like `GET /api/v1/findings`. As a GET it is read-gated by the role middleware (a row was added to `role_gate/router_tests.rs`). It is not added to the API-key `KEY_SCOPES`. ```json { "data": { "by_type": [ { "scan_type": "gdpr", "counts": { "critical": 0, "high": 2, "medium": 9, "low": 1, "info": 0 } } ], "folders": [ { "path": "src/api/", "count": 7, "worst": "high" }, { "path": "src/*", "count": 2, "worst": "medium" }, { "path": "/", "count": 1, "worst": "low" } ], "without_file": 3, "total": 15 }, "total": 15 } ``` - `by_type` is sorted by most findings first, then by type name. `folders` is sorted by most findings, then by path. The order therefore does not depend on Mongo's cursor order. - The handler projects `scan_type`, `severity` and `file_path` of the open findings, and `compliance_core::finding_breakdown::breakdown` counts them. That one pure function is unit-tested. - **Folders**: a folder is the top-level directory (`docs/`). When one top-level directory holds more than half of the open findings that have a file, and it has subfolders with findings, it is shown two levels deep (`src/api/`), and the files directly in it become `src/*`. Files in the root are `/`. ## "Open" Open means undecided: `Open`, `Triaged` and `NeedsReview`. These are the statuses of `ISSUE_STATUSES` in `pipeline/issue_creation.rs`, i.e. findings that still get a tracker issue. The list is `OPEN_STATUSES` in core, with a test pinning it. Resolved, false-positive (rule or mapping), accepted-risk and ignored findings are decided and not counted. So that the list behind a chart shows the findings the chart counted, the findings list API takes **`status=undecided`** (`$in` the three statuses). The status select gains an "Offen (unentschieden)" entry, and a URL with a chart filter starts the list on it. ## URL filters The route is now `#[route("/findings?:scan_type&:severity&:path&:target")]`. The three new fields are `Option<String>`, so a link without a chart filter keeps its old form `/findings?target=<id>`, and old links still parse. `target` comes last because the router writes `&` after each argument that is set, and the macro wants the fields in the order of the arguments. Examples: - `/findings?scan_type=gdpr&severity=medium&target=<id>` - `/findings?path=src/api/&target=<id>`, `path=src/*` (only the files directly in `src`), `path=/` (the root) The findings list API takes an optional **`path`** filter. `q` cannot express "under folder X": it is unanchored, case-insensitive, and OR'd with title, description and rule. `dto::path_regex` builds an anchored literal regex with `literal_regex`: | key | regex | | --- | --- | | `/` | `^/?[^/]+$` | | `src/*` | `^/?src/[^/]+$` | | `src/` or `src` | `^/?src/` | There is no `i` option. Stored paths are relative already (`source_text::relative_path`); the `/?` only tolerates a leading slash, which the chart ignores too. `FindingsPage` keeps its hooks when only the query changes. A `use_reactive` effect therefore moves the URL's filters into the page's filter signals, writing only on a real change. The severity, type and status selects now mark the selected option, so they show what the URL set. **Note for other branches:** `Route::FindingsPage` now has four fields, so a `Route::FindingsPage { target }` literal no longer compiles. The new `Route::findings(target)` builds the plain list link. The 7 existing call sites use it now (one-line changes in sidebar, demo_targets, scan_runs, overview, target, targets and onboarding). A branch that adds such a link (e.g. #952 on overview, targets or target) needs the same one-line change after rebasing. The edits to `pages/findings.rs` are kept small (the props, seeding the signals and the effect, mounting the component, `path` in the query, and `selected` on options), because #958 and #961 (#951) also edit that file. ## How tested - `cargo fmt --all --check`: clean - `cargo clippy -D warnings`: compliance-core, compliance-agent, compliance-dashboard `--features server` and compliance-dashboard `--features web`, all with `--all-targets`: clean - Unit tests: - core `finding_breakdown`: the open-status set, severity order, per-type counts and their order, top-level folders with root files as `/`, the two-level split and its >50% threshold (half is not most), no split without subfolders, findings in no file, worst severity, JSON round trip, and a doc test - agent: `path_regex` (anchored, literal, `/`, `src/*`, no `srcfoo/` match), `FindingsFilter.path`, `status=undecided`, the breakdown's Mongo filter, and the role-gate router tests with the new route - dashboard: the route round trip with the chart filters (old links, argument order, `path=/` and `src/*`), segment and tile routes, the breadcrumb, the list's status behind a chart, the texts, and the target-id guard; the whole dashboard lib suite passes (133 tests) - Not tested against a live database or in a browser; that is left for review on stage. ## Open points - Folder names with `&` or `=` cannot be carried by the Dioxus query parser (it decodes before splitting). Such a folder's link would lose the filter. - When a user changes a select while a chart filter is in the URL, the breadcrumb still names the URL filter. "Zurück" resets it. - The breadcrumb does not name the target ("Repo › Ansicht › Auswahl" from the issue). That fits better once the per-repo tabs (#952) exist. Part of #957 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sharang added 1 commit 2026-11-10 15:18:42 +00:00
feat(dashboard): open findings by type and folder as clickable charts (#957)
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 / Agent integration (pull_request) Successful in 5m26s
CI / Check (pull_request) Successful in 20m56s
32af227142
The findings page of one target (/findings?target=...) now opens with two
charts of its open findings: a bar per finding type stacked by severity
(one red scale, every segment a button), and a tree map of the folders
they are in (area = open findings, colour = the most severe). A click
opens the list narrowed to that type and severity, or to that folder; the
filter goes into the URL, a breadcrumb names it and leads back to the
charts. A "Tabelle" toggle shows the same numbers as tables.

- core: finding_breakdown (the shared DTO and the pure counting function;
  open = Open, Triaged, NeedsReview as for tracker issues)
- agent: GET /api/v1/targets/{id}/finding-breakdown; the findings list
  takes an anchored literal `path` folder filter and `status=undecided`
- dashboard: FindingsPage takes scan_type, severity and path from the
  query (Route::findings(target) builds the plain list link)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sharang force-pushed feat/957-findings-view from c5ba9635e0 to 32af227142 2026-11-10 15:18:42 +00:00 Compare
sharang merged commit cd90a26558 into main 2026-11-10 15:40:06 +00:00
Sign in to join this conversation.