Closes#131. The REST surface the onboarding wizard drives, on the unified OnboardedTarget model.
Endpoints (api/handlers/onboarding.rs, routes in routes.rs)
Method
Path
Purpose
GET / POST
/api/v1/targets
list (paginated) / create
GET / PATCH / DELETE
/api/v1/targets/{id}
fetch / update / delete (+cascade findings·scans by repo_id)
POST
/api/v1/targets/{id}/artifacts
attach an artifact by reference
GET
/api/v1/targets/{id}/applicable-scans
scan-applicability matrix + pentest support
POST
/api/v1/targets/{id}/detect
kind-based classification
Follows the existing conventions exactly (ApiResponse, PaginationParams, tenant_db, collect_cursor_async, TenantCtx — so it inherits the global JWT/tenant gate). Clients send a light ArtifactInput (kind + source_ref + optional branch/plc_format); the server builds the Artifact (and its id).
/detect is the lightweight pass — it classifies from artifact kinds without ingesting (cloning) sources, so it returns immediately (e.g. a PLC-project artifact → suggests plc_sps). Deep detection after ingest (with tramiton firmware analysis) is a follow-up background step, as is multipart artifact upload and the scan-trigger endpoint (which needs the unified pipeline, #133).
Also fixes the integration harness
TestServer used a 37-char db-name prefix, over the pool's 30-char cap — so TestServer::start() panicked and every API integration test was silently broken locally (CI runs --lib only, so it went unnoticed). Shortened to a 16-hex suffix.
Testing
3 HTTP integration tests (create/list/applicable-scans; detect→PLC; add-artifact/delete) — pass against local Mongo. (Not run in CI, which is --lib-only.)
Closes #131. The REST surface the onboarding wizard drives, on the unified `OnboardedTarget` model.
## Endpoints (`api/handlers/onboarding.rs`, routes in `routes.rs`)
| Method | Path | Purpose |
|---|---|---|
| GET / POST | `/api/v1/targets` | list (paginated) / create |
| GET / PATCH / DELETE | `/api/v1/targets/{id}` | fetch / update / delete (+cascade findings·scans by `repo_id`) |
| POST | `/api/v1/targets/{id}/artifacts` | attach an artifact by reference |
| GET | `/api/v1/targets/{id}/applicable-scans` | scan-applicability matrix + pentest support |
| POST | `/api/v1/targets/{id}/detect` | kind-based classification |
Follows the existing conventions exactly (`ApiResponse`, `PaginationParams`, `tenant_db`, `collect_cursor_async`, `TenantCtx` — so it inherits the global JWT/tenant gate). Clients send a light `ArtifactInput` (kind + source_ref + optional branch/plc_format); the server builds the `Artifact` (and its id).
`/detect` is the **lightweight** pass — it classifies from artifact kinds without ingesting (cloning) sources, so it returns immediately (e.g. a PLC-project artifact → suggests `plc_sps`). Deep detection after ingest (with tramiton firmware analysis) is a follow-up background step, as is multipart artifact **upload** and the **scan-trigger** endpoint (which needs the unified pipeline, #133).
## Also fixes the integration harness
`TestServer` used a 37-char db-name prefix, over the pool's 30-char cap — so `TestServer::start()` panicked and **every API integration test was silently broken locally** (CI runs `--lib` only, so it went unnoticed). Shortened to a 16-hex suffix.
## Testing
3 HTTP integration tests (create/list/applicable-scans; detect→PLC; add-artifact/delete) — **pass** against local Mongo. (Not run in CI, which is `--lib`-only.)
Refs #118.
sharang
added this to the Onboarding v1 milestone 2026-07-10 18:06:55 +00:00
REST surface the wizard drives onboarding through:
- GET/POST /api/v1/targets (list paginated / create)
- GET/PATCH/DELETE /api/v1/targets/{id} (fetch / update / delete + cascade
findings/scans by repo_id)
- POST /api/v1/targets/{id}/artifacts (attach an artifact by reference)
- GET /api/v1/targets/{id}/applicable-scans (scan matrix + pentest support)
- POST /api/v1/targets/{id}/detect (kind-based classification — no ingest;
deep post-ingest detection is a follow-up)
Follows the existing axum handler/route/DTO conventions (ApiResponse,
PaginationParams, tenant_db, collect_cursor_async, TenantCtx). Multipart artifact
upload and the scan-trigger endpoint (needs the unified pipeline, #133) are
follow-ups.
Also fixes the TestServer db-name prefix (was 37 chars, over the pool's 30-char
cap) which had silently broken every API integration test locally.
3 HTTP integration tests (create/list/applicable-scans, detect->PLC,
add-artifact/delete) — pass against local Mongo.
Closes#131.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
sharang
merged commit a204f0c59c into main2026-07-12 20:15:22 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Closes #131. The REST surface the onboarding wizard drives, on the unified
OnboardedTargetmodel.Endpoints (
api/handlers/onboarding.rs, routes inroutes.rs)/api/v1/targets/api/v1/targets/{id}repo_id)/api/v1/targets/{id}/artifacts/api/v1/targets/{id}/applicable-scans/api/v1/targets/{id}/detectFollows the existing conventions exactly (
ApiResponse,PaginationParams,tenant_db,collect_cursor_async,TenantCtx— so it inherits the global JWT/tenant gate). Clients send a lightArtifactInput(kind + source_ref + optional branch/plc_format); the server builds theArtifact(and its id)./detectis the lightweight pass — it classifies from artifact kinds without ingesting (cloning) sources, so it returns immediately (e.g. a PLC-project artifact → suggestsplc_sps). Deep detection after ingest (with tramiton firmware analysis) is a follow-up background step, as is multipart artifact upload and the scan-trigger endpoint (which needs the unified pipeline, #133).Also fixes the integration harness
TestServerused a 37-char db-name prefix, over the pool's 30-char cap — soTestServer::start()panicked and every API integration test was silently broken locally (CI runs--libonly, so it went unnoticed). Shortened to a 16-hex suffix.Testing
3 HTTP integration tests (create/list/applicable-scans; detect→PLC; add-artifact/delete) — pass against local Mongo. (Not run in CI, which is
--lib-only.)Refs #118.
REST surface the wizard drives onboarding through: - GET/POST /api/v1/targets (list paginated / create) - GET/PATCH/DELETE /api/v1/targets/{id} (fetch / update / delete + cascade findings/scans by repo_id) - POST /api/v1/targets/{id}/artifacts (attach an artifact by reference) - GET /api/v1/targets/{id}/applicable-scans (scan matrix + pentest support) - POST /api/v1/targets/{id}/detect (kind-based classification — no ingest; deep post-ingest detection is a follow-up) Follows the existing axum handler/route/DTO conventions (ApiResponse, PaginationParams, tenant_db, collect_cursor_async, TenantCtx). Multipart artifact upload and the scan-trigger endpoint (needs the unified pipeline, #133) are follow-ups. Also fixes the TestServer db-name prefix (was 37 chars, over the pool's 30-char cap) which had silently broken every API integration test locally. 3 HTTP integration tests (create/list/applicable-scans, detect->PLC, add-artifact/delete) — pass against local Mongo. Closes #131. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>