fix(dashboard): targets named owner/repo can be edited and saved #527

Merged
sharang merged 1 commits from fix/a2-target-name into main 2026-10-08 21:24:16 +00:00
Owner

What was wrong

Targets created automatically from a managed git repo are named owner/repo (e.g. bp-test/plc-codesys). The dashboard's target-name check refused any slash ("No slashes — the name becomes a folder"), so the Bearbeiten dialog of these targets could not be saved (type, token, artifacts) until the target was renamed. The message was also English in the German UI. Affects existing production targets of K-00001.

What changed

  • The agent never uses the raw target name as a path: pipeline::git::clone_dir collapses it to one safe segment via tenant_path::name_segment (owner/repo -> owner_repo, traversal stripped, covered by the existing tests name_segment_collapses_path_hostile_names and clone_dir_sanitises_traversal_in_the_target_name); SBOM/VEX/evidence downloads are named by id or a slug; PATCH /api/v1/targets/{id} does not validate the name. No agent change needed.
  • validate_target_name (dashboard) now refuses only an empty name and leading/trailing spaces, and returns an i18n Text (DE + EN) instead of an English string. Used by both the wizard (Prüfobjekt anlegen) and the edit dialog.
  • Moved a stray doc comment that sat on is_file_kind back to validate_target_name.

Tests

  • New unit test a_target_name_may_carry_slashes_but_not_blanks (dashboard, infrastructure::onboarding).
  • cargo test -p compliance-dashboard --features server --no-default-features --lib infrastructure::onboarding (9 passed).
  • cargo fmt --all --check, clippy -D warnings for compliance-dashboard with server and with web.

Stage re-test

  1. Open Prüfobjekte and a target created from a managed git repo (name owner/repo).
  2. Click Bearbeiten, change the Typ (or set a new token) and click Speichern: it saves, no slash error.
  3. Type a leading space in the name: "Bitte Leerzeichen am Anfang und Ende entfernen" appears and Speichern is disabled (EN: "Remove the leading/trailing spaces"); an empty name also disables Speichern.
  4. Start a scan on that target: the clone works as before.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

## What was wrong Targets created automatically from a managed git repo are named `owner/repo` (e.g. `bp-test/plc-codesys`). The dashboard's target-name check refused any slash ("No slashes — the name becomes a folder"), so the Bearbeiten dialog of these targets could not be saved (type, token, artifacts) until the target was renamed. The message was also English in the German UI. Affects existing production targets of K-00001. ## What changed - The agent never uses the raw target name as a path: `pipeline::git::clone_dir` collapses it to one safe segment via `tenant_path::name_segment` (`owner/repo` -> `owner_repo`, traversal stripped, covered by the existing tests `name_segment_collapses_path_hostile_names` and `clone_dir_sanitises_traversal_in_the_target_name`); SBOM/VEX/evidence downloads are named by id or a slug; `PATCH /api/v1/targets/{id}` does not validate the name. No agent change needed. - `validate_target_name` (dashboard) now refuses only an empty name and leading/trailing spaces, and returns an i18n `Text` (DE + EN) instead of an English string. Used by both the wizard (Prüfobjekt anlegen) and the edit dialog. - Moved a stray doc comment that sat on `is_file_kind` back to `validate_target_name`. ## Tests - New unit test `a_target_name_may_carry_slashes_but_not_blanks` (dashboard, `infrastructure::onboarding`). - `cargo test -p compliance-dashboard --features server --no-default-features --lib infrastructure::onboarding` (9 passed). - `cargo fmt --all --check`, clippy `-D warnings` for compliance-dashboard with `server` and with `web`. ## Stage re-test 1. Open Prüfobjekte and a target created from a managed git repo (name `owner/repo`). 2. Click Bearbeiten, change the Typ (or set a new token) and click Speichern: it saves, no slash error. 3. Type a leading space in the name: "Bitte Leerzeichen am Anfang und Ende entfernen" appears and Speichern is disabled (EN: "Remove the leading/trailing spaces"); an empty name also disables Speichern. 4. Start a scan on that target: the clone works as before. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang added 1 commit 2026-10-08 21:04:23 +00:00
fix(dashboard): targets named owner/repo can be edited and saved
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 10m53s
97b4a73f1a
Targets created from a managed git repo are named "owner/repo". The
target name check refused slashes ("the name becomes a folder"), so the
edit dialog of every such target could not be saved until it was renamed,
and the message was English in the German UI.

The agent never uses the raw name as a path: clone_dir collapses it to
one safe segment (tenant_path::name_segment), downloads are named by id,
and the target update handler does not validate the name. So the
dashboard only refuses an empty name and outer spaces now, with German
and English messages.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang merged commit ffe31964e6 into main 2026-10-08 21:24:16 +00:00
Sign in to join this conversation.