feat(targets): git tokens for private repositories, kept across edits (#303, #304) #346

Merged
sharang merged 1 commits from feat/git-credentials into main 2026-09-23 14:19:19 +00:00
Owner

Closes #303, closes #304. Part of the pilot P0 (#338), item D. Stacked on #345.

#303: a git token for a private repository

  • ArtifactInput (create, add, PATCH artifacts) takes optional token and username.
  • The token is sealed with SecretBox as enc:v1: and never returned; responses keep auth.method = "token", so the UI can say "token set".
  • A value replaces the token, an empty string removes it, and leaving it out keeps it.
  • The clone uses the stored username, or x-access-token.

#304: edits keep what the client cannot send

  • Artifacts: each incoming artifact is matched to the first unused stored artifact of the same kind and source. It keeps that artifact's id, uploaded file (stored_path), ingest record and credentials.
  • Scan config: PATCH takes a ScanConfigUpdate whose fields are all optional, and only the fields it names change. "Enable opt-in scans" no longer removes the issue tracker.
    • Tracker and pentest credentials inside a sent block behave as before (#302).
    • A field cannot be cleared by sending null. No client did that.
  • New module api/handlers/target_input.rs holds the input types and merge rules. It replaces seal_scan_config_credentials.

Dashboard

  • Wizard: for a git repository, a password field "Zugangstoken (nur für private Repositories)" and an optional username. The staged list and review show "Token gesetzt".
  • Target editor:
    • "Token gesetzt" or "Token wird beim Speichern entfernt";
    • a new-token field and a remove button per git repository;
    • a token field when adding one.
  • Editor fix: it now keeps a PLC project's plc_format. It sent none before, so every edit reset a .projectarchive to PLCopen XML.

Verification

  • Unit tests (agent):
    • a token is stored sealed;
    • editing keeps the token and the upload;
    • a token can be replaced or cleared;
    • enabling a scan keeps the tracker and its token.
  • Integration test against a local MongoDB (tests/credentials.rs): create with a token → editor-style PATCH (no token) → enable a scan. The git token and tracker token are unchanged in storage, and no response contains either. All 4 credential tests pass.
  • Dashboard unit test: has_token is never sent, and a token is sent only when it changes. 39 lib tests pass.
  • clippy with the CI flags (agent; dashboard server/web); fmt.
  • Not yet tried against a real private repository. Planned for the staging dry run with a Gitea PAT.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

Closes #303, closes #304. Part of the pilot P0 (#338), item D. **Stacked on #345.** ## #303: a git token for a private repository - `ArtifactInput` (create, add, `PATCH` artifacts) takes optional `token` and `username`. - The token is sealed with `SecretBox` as `enc:v1:` and never returned; responses keep `auth.method = "token"`, so the UI can say "token set". - A value replaces the token, an empty string removes it, and leaving it out keeps it. - The clone uses the stored username, or `x-access-token`. ## #304: edits keep what the client cannot send - **Artifacts:** each incoming artifact is matched to the first unused stored artifact of the same kind and source. It keeps that artifact's id, uploaded file (`stored_path`), ingest record and credentials. - **Scan config:** `PATCH` takes a `ScanConfigUpdate` whose fields are all optional, and only the fields it names change. "Enable opt-in scans" no longer removes the issue tracker. - Tracker and pentest credentials inside a sent block behave as before (#302). - A field cannot be cleared by sending `null`. No client did that. - New module `api/handlers/target_input.rs` holds the input types and merge rules. It replaces `seal_scan_config_credentials`. ## Dashboard - **Wizard:** for a git repository, a password field "Zugangstoken (nur für private Repositories)" and an optional username. The staged list and review show "Token gesetzt". - **Target editor:** - "Token gesetzt" or "Token wird beim Speichern entfernt"; - a new-token field and a remove button per git repository; - a token field when adding one. - **Editor fix:** it now keeps a PLC project's `plc_format`. It sent none before, so every edit reset a `.projectarchive` to PLCopen XML. ## Verification - Unit tests (agent): - a token is stored sealed; - editing keeps the token and the upload; - a token can be replaced or cleared; - enabling a scan keeps the tracker and its token. - Integration test against a local MongoDB (`tests/credentials.rs`): create with a token → editor-style `PATCH` (no token) → enable a scan. The git token and tracker token are unchanged in storage, and no response contains either. All 4 credential tests pass. - Dashboard unit test: `has_token` is never sent, and a token is sent only when it changes. 39 lib tests pass. - clippy with the CI flags (agent; dashboard `server`/`web`); fmt. - Not yet tried against a real private repository. Planned for the staging dry run with a Gitea PAT. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang changed target branch from feat/findings-pages to main 2026-09-23 14:11:37 +00:00
sharang added 1 commit 2026-09-23 14:11:37 +00:00
feat(targets): git tokens for private repositories, kept across edits (#303, #304)
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 7m26s
827980e532
#303: no API path stored credentials on an artifact, so a private
repository could not be cloned. Artifact inputs (create, add, update) now
take an optional `token` and `username`; the token is sealed with
SecretBox, never returned, and can be replaced (a value) or removed (an
empty string). Left out, it is kept.

#304: editing a target rebuilt every artifact from its input and dropped
the git token, the uploaded file and the ingest record; enabling a scan
replaced the whole scan config and dropped the issue tracker. An edited
artifact now keeps what its stored counterpart (same kind and source)
holds, and a scan-config update changes only the fields it names.

Dashboard: a token (and optional username) field for git repositories in
the wizard and the target editor, "token set" where one is stored, and a
remove button. The editor also keeps a PLC project's format; it sent none,
which reset a .projectarchive to PLCopen XML on every edit.

Tests: unit tests for sealing, keeping, replacing and clearing a token,
keeping an upload across an edit, and a scan-config merge; an integration
test (MongoDB) that renames a target and enables a scan and finds both
the git token and the tracker token still stored.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang force-pushed feat/git-credentials from 792a60cd9f to 827980e532 2026-09-23 14:11:38 +00:00 Compare
sharang merged commit fe318c2b85 into main 2026-09-23 14:19:19 +00:00
Sign in to join this conversation.