diff --git a/README.md b/README.md index d78c3f65..ed9e50ae 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ > [!IMPORTANT] > **Breaking Technology Preview change:** GMP ticket discovery is not exposed by -> `rust-gvm-api`; the former `/api/v1/tickets` routes were removed under +> `rust-gvm-api`; the former `/gvm/public/v1/tickets` routes were removed under > [issue #500](https://github.com/greenbone-hive/rust-gvm-api/issues/500). > Direct GMP consumers may continue using `rust-gvm`, while gateway integrations > should manage tickets through their external ticketing system. @@ -153,7 +153,7 @@ Run the compose-backed REST end-to-end tests through the wrapper script: ./scripts/run-e2e-tests.sh ``` -The wrapper waits for `/ready`, prints feed status for diagnostics, then polls the REST resources required by the discovery scan test: discovery scan configs, OpenVAS scanner availability, and usable port lists. This is stricter than feed status alone because gvmd can accept GMP connections before first-boot data imports have populated REST-visible scan configs. +The wrapper waits for `/gvm/ready`, prints feed status for diagnostics, then polls the REST resources required by the discovery scan test: discovery scan configs, OpenVAS scanner availability, and usable port lists. This is stricter than feed status alone because gvmd can accept GMP connections before first-boot data imports have populated REST-visible scan configs. Run the weekly-scope performance slice through its dedicated wrapper: @@ -234,8 +234,8 @@ Useful follow-up commands: - [Documentation index](docs/README.md) - [Developer guide](docs/development.md) - [Human-readable REST API reference](docs/user/api-reference.md) -- Runtime API documentation: `GET /api/v1/docs` -- Runtime-generated OpenAPI: `GET /api/v1/openapi.json` +- Runtime API documentation: `GET /gvm/public/v1/docs` +- Runtime-generated OpenAPI: `GET /gvm/public/v1/openapi.json` - Release-shipped user docs source: - [docs/user/index.md](docs/user/index.md) - [docs/user/usage.md](docs/user/usage.md) diff --git a/crates/gvm-gateway-app/src/jobs.rs b/crates/gvm-gateway-app/src/jobs.rs index 7014734e..85974922 100644 --- a/crates/gvm-gateway-app/src/jobs.rs +++ b/crates/gvm-gateway-app/src/jobs.rs @@ -646,7 +646,7 @@ impl GatewayService { state_changed.notify_waiters(); return Ok(()); } - let result_location = format!("/api/v1/jobs/{job_id}/result"); + let result_location = format!("/gvm/public/v1/jobs/{job_id}/result"); record.job.status = JobStatus::Succeeded; record.job.completed_at = Some(format_epoch_secs(now)); record.job.expires_at = Some(format_epoch_secs(now + retention_secs)); diff --git a/crates/gvm-gateway-gvmd/src/conversions_test.rs b/crates/gvm-gateway-gvmd/src/conversions_test.rs index 3942edc3..8cb3cc46 100644 --- a/crates/gvm-gateway-gvmd/src/conversions_test.rs +++ b/crates/gvm-gateway-gvmd/src/conversions_test.rs @@ -84,7 +84,7 @@ async fn typed_scanner_error_status(status_text: &str) -> axum::http::StatusCode .expect_err("scripted scanner response should fail typed execution"); let gateway_error = map_gvm_error(error); - RestError::from_gateway_error(gateway_error, "/api/v1/scanners") + RestError::from_gateway_error(gateway_error, "/gvm/public/v1/scanners") .into_response() .status() } @@ -199,7 +199,7 @@ fn unclassified_typed_gmp_status_400_maps_to_rest_bad_request() { 400, "backend rejected an unclassified request".to_string(), ), - "/api/v1/scanners", + "/gvm/public/v1/scanners", ) .into_response(); @@ -376,7 +376,7 @@ fn operating_system_delete_classifications_survive_direct_and_parsed_server_erro for (error, expected_status) in cases { let response = RestError::from_gateway_error( map_gvm_error(error), - "/api/v1/operating-systems/550e8400-e29b-41d4-a716-446655440134", + "/gvm/public/v1/operating-systems/550e8400-e29b-41d4-a716-446655440134", ) .into_response(); assert_eq!(response.status(), expected_status); diff --git a/crates/gvm-gateway-gvmd/tests/architecture.rs b/crates/gvm-gateway-gvmd/tests/architecture.rs index b5603be3..2664b8d0 100644 --- a/crates/gvm-gateway-gvmd/tests/architecture.rs +++ b/crates/gvm-gateway-gvmd/tests/architecture.rs @@ -816,8 +816,12 @@ fn administration_and_cleanup_dispositions_stay_explicit_and_non_public() { let router = fs::read_to_string(manifest_dir.join("../gvm-gateway-rest/src/router.rs")) .expect("read REST router"); - let scanner_routes = section_between(&router, "// Scanners", "\"/api/v1/operating-systems\""); - assert_eq!(scanner_routes.matches("/api/v1/scanners").count(), 2); + let scanner_routes = section_between( + &router, + "// Scanners", + "\"/gvm/public/v1/operating-systems\"", + ); + assert_eq!(scanner_routes.matches("/gvm/public/v1/scanners").count(), 2); assert_eq!(scanner_routes.matches("get_with(").count(), 2); for mutating_route in ["post_with(", "put_with(", "delete_with("] { assert!( diff --git a/crates/gvm-gateway-gvmd/tests/gvmd_adapter_test.rs b/crates/gvm-gateway-gvmd/tests/gvmd_adapter_test.rs index 8b959edd..62afcf19 100644 --- a/crates/gvm-gateway-gvmd/tests/gvmd_adapter_test.rs +++ b/crates/gvm-gateway-gvmd/tests/gvmd_adapter_test.rs @@ -86,7 +86,7 @@ async fn gvmd_adapter_probe_version_reports_mock_version() { #[tokio::test] async fn gvmd_adapter_readiness_reports_ready_when_probe_succeeds() { - // Covers the production `/ready` contract: a reachable GMP backend must + // Covers the production `/gvm/ready` contract: a reachable GMP backend must // be reported as ready instead of relying on startup-only state. let server = MockGmpServer::builder() .mode(ServerMode::Stateful) @@ -106,7 +106,7 @@ async fn gvmd_adapter_readiness_reports_ready_when_probe_succeeds() { #[tokio::test] async fn gvmd_adapter_readiness_reports_not_ready_when_socket_is_missing() { - // Regression coverage for compose startup races: `/ready` must degrade + // Regression coverage for compose startup races: `/gvm/ready` must degrade // while gvmd has not created its Unix socket yet. let adapter = GvmdAdapter::unix_socket("/tmp/nonexistent-gvmd-readiness.sock"); let status = adapter.readiness().await.unwrap(); diff --git a/crates/gvm-gateway-rest/src/active_directory_test.rs b/crates/gvm-gateway-rest/src/active_directory_test.rs index ade4054c..5ace614a 100644 --- a/crates/gvm-gateway-rest/src/active_directory_test.rs +++ b/crates/gvm-gateway-rest/src/active_directory_test.rs @@ -161,7 +161,9 @@ async fn malformed_and_unsupported_search_responses_are_no_store_and_sanitized() let response = search_active_directory_objects( State(service), HeaderMap::new(), - OriginalUri(Uri::from_static("/api/v1/active-directory/object-searches")), + OriginalUri(Uri::from_static( + "/gvm/public/v1/active-directory/object-searches", + )), Bytes::from_static(br#"{"credentialId":"secret DN"}"#), ) .await; @@ -176,7 +178,9 @@ async fn malformed_and_unsupported_search_responses_are_no_store_and_sanitized() let response = search_active_directory_objects( State(service), HeaderMap::new(), - OriginalUri(Uri::from_static("/api/v1/active-directory/object-searches")), + OriginalUri(Uri::from_static( + "/gvm/public/v1/active-directory/object-searches", + )), Bytes::from(format!("{{\"credentialId\":\"{ID}\"}}")), ) .await; @@ -198,7 +202,9 @@ async fn static_backend_does_not_emulate_directory_success() { let response = search_active_directory_objects( State(service), headers, - OriginalUri(Uri::from_static("/api/v1/active-directory/object-searches")), + OriginalUri(Uri::from_static( + "/gvm/public/v1/active-directory/object-searches", + )), Bytes::from(format!("{{\"credentialId\":\"{ID}\"}}")), ) .await; diff --git a/crates/gvm-gateway-rest/src/agents.rs b/crates/gvm-gateway-rest/src/agents.rs index e79f6a6c..5caf9886 100644 --- a/crates/gvm-gateway-rest/src/agents.rs +++ b/crates/gvm-gateway-rest/src/agents.rs @@ -1090,7 +1090,7 @@ pub async fn clone_agent_group( headers, id, uri, - "/api/v1/agent-groups", + "/gvm/public/v1/agent-groups", |service, token, id| async move { service.clone_agent_group(&token, &id).await }, ) .await @@ -1264,7 +1264,7 @@ fn support_bundle_response(mut response: TransformResponse) -> TransformRe response } -/// OpenAPI transform for `GET /api/v1/agents`. +/// OpenAPI transform for `GET /gvm/public/v1/agents`. pub(crate) fn list_agents_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { list_docs::( op.input::>(), @@ -1274,27 +1274,27 @@ pub(crate) fn list_agents_docs(op: TransformOperation<'_>) -> TransformOperation ) } -/// OpenAPI transform for `GET /api/v1/agents/{id}`. +/// OpenAPI transform for `GET /gvm/public/v1/agents/{id}`. pub(crate) fn get_agent_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { item_docs::(op, "getAgent", "Agents", "Agent details") } -/// OpenAPI transform for `PUT /api/v1/agents/{id}`. +/// OpenAPI transform for `PUT /gvm/public/v1/agents/{id}`. pub(crate) fn modify_agent_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { update_docs::(op, "modifyAgent", "Agents", "Updated agent") } -/// OpenAPI transform for `DELETE /api/v1/agents/{id}`. +/// OpenAPI transform for `DELETE /gvm/public/v1/agents/{id}`. pub(crate) fn delete_agent_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { delete_docs(op, "deleteAgent", "Agents", "Agent deleted", false) } -/// OpenAPI transform for `POST /api/v1/agents/sync`. +/// OpenAPI transform for `POST /gvm/public/v1/agents/sync`. pub(crate) fn sync_agents_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { action_no_content_docs(op, "syncAgents", "Agents", "Agent synchronization started") } -/// OpenAPI transform for `GET /api/v1/agents/{id}/support-bundle`. +/// OpenAPI transform for `GET /gvm/public/v1/agents/{id}/support-bundle`. pub(crate) fn get_agent_support_bundle_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getAgentSupportBundle") @@ -1318,7 +1318,7 @@ pub(crate) fn get_agent_support_bundle_docs(op: TransformOperation<'_>) -> Trans problem_response::<504>(op, "Backend request timed out") } -/// OpenAPI transform for `PUT /api/v1/agent-control-scan-configs/{id}`. +/// OpenAPI transform for `PUT /gvm/public/v1/agent-control-scan-configs/{id}`. pub(crate) fn modify_agent_control_scan_config_docs( op: TransformOperation<'_>, ) -> TransformOperation<'_> { @@ -1346,7 +1346,7 @@ pub(crate) fn modify_agent_control_scan_config_docs( problem_response::<504>(op, "Backend request timed out") } -/// OpenAPI transform for `GET /api/v1/scanners/{id}/agent-installer-instruction`. +/// OpenAPI transform for `GET /gvm/public/v1/scanners/{id}/agent-installer-instruction`. pub(crate) fn get_agent_installer_instruction_docs( op: TransformOperation<'_>, ) -> TransformOperation<'_> { @@ -1374,7 +1374,7 @@ pub(crate) fn get_agent_installer_instruction_docs( problem_response::<504>(op, "Backend request timed out") } -/// OpenAPI transform for `GET /api/v1/agent-groups`. +/// OpenAPI transform for `GET /gvm/public/v1/agent-groups`. pub(crate) fn list_agent_groups_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { list_docs::( op.input::>(), @@ -1384,7 +1384,7 @@ pub(crate) fn list_agent_groups_docs(op: TransformOperation<'_>) -> TransformOpe ) } -/// OpenAPI transform for `POST /api/v1/agent-groups`. +/// OpenAPI transform for `POST /gvm/public/v1/agent-groups`. pub(crate) fn create_agent_group_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { create_docs::( op, @@ -1394,12 +1394,12 @@ pub(crate) fn create_agent_group_docs(op: TransformOperation<'_>) -> TransformOp ) } -/// OpenAPI transform for `GET /api/v1/agent-groups/{id}`. +/// OpenAPI transform for `GET /gvm/public/v1/agent-groups/{id}`. pub(crate) fn get_agent_group_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { item_docs::(op, "getAgentGroup", "Agent Groups", "Agent group details") } -/// OpenAPI transform for `PUT /api/v1/agent-groups/{id}`. +/// OpenAPI transform for `PUT /gvm/public/v1/agent-groups/{id}`. pub(crate) fn modify_agent_group_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { update_docs::( op, @@ -1409,7 +1409,7 @@ pub(crate) fn modify_agent_group_docs(op: TransformOperation<'_>) -> TransformOp ) } -/// OpenAPI transform for `DELETE /api/v1/agent-groups/{id}`. +/// OpenAPI transform for `DELETE /gvm/public/v1/agent-groups/{id}`. pub(crate) fn delete_agent_group_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { delete_docs( op, @@ -1420,7 +1420,7 @@ pub(crate) fn delete_agent_group_docs(op: TransformOperation<'_>) -> TransformOp ) } -/// OpenAPI transform for `POST /api/v1/agent-groups/{id}/clone`. +/// OpenAPI transform for `POST /gvm/public/v1/agent-groups/{id}/clone`. pub(crate) fn clone_agent_group_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("cloneAgentGroup") diff --git a/crates/gvm-gateway-rest/src/auth_policy.rs b/crates/gvm-gateway-rest/src/auth_policy.rs index 426686ff..56b40ffb 100644 --- a/crates/gvm-gateway-rest/src/auth_policy.rs +++ b/crates/gvm-gateway-rest/src/auth_policy.rs @@ -22,25 +22,25 @@ pub(crate) enum RestRouteAuthPolicy { /// Classifies a runtime REST path into its auth policy bucket. pub(crate) fn classify_runtime_route(method: &Method, path: &str) -> Option { - if matches!(path, "/health" | "/ready") { + if matches!(path, "/gvm/health" | "/gvm/ready") { return Some(RestRouteAuthPolicy::Public); } if matches!( path, - "/api/v1/version" - | "/api/v1/openapi.json" - | "/api/v1/docs" - | "/api/v1/docs/redoc.standalone.js" + "/gvm/public/v1/version" + | "/gvm/public/v1/openapi.json" + | "/gvm/public/v1/docs" + | "/gvm/public/v1/docs/redoc.standalone.js" ) { return Some(RestRouteAuthPolicy::Public); } - if path == "/api/v1/session" && *method == Method::POST { + if path == "/gvm/public/v1/session" && *method == Method::POST { return Some(RestRouteAuthPolicy::SessionCreate); } - if path == "/api/v1/session" { + if path == "/gvm/public/v1/session" { return Some(RestRouteAuthPolicy::SessionCurrent); } @@ -48,7 +48,7 @@ pub(crate) fn classify_runtime_route(method: &Method, path: &str) -> Option Option bool { - path.strip_prefix("/api/v1/reports/") + path.strip_prefix("/gvm/public/v1/reports/") .and_then(|path| path.strip_suffix("/exports")) .is_some_and(|report_id| !report_id.is_empty() && !report_id.contains('/')) } @@ -64,10 +64,10 @@ fn is_report_export_job_collection(path: &str) -> bool { /// Maps a served OpenAPI path back to the runtime path used by the router. pub(crate) fn runtime_path_from_openapi_path(path: &str) -> String { match path { - "/health" | "/ready" => path.to_string(), - "/version" => "/api/v1/version".to_string(), - "/openapi.json" => "/api/v1/openapi.json".to_string(), - _ => format!("/api/v1{path}"), + "/gvm/health" | "/gvm/ready" => path.to_string(), + "/version" => "/gvm/public/v1/version".to_string(), + "/openapi.json" => "/gvm/public/v1/openapi.json".to_string(), + _ => format!("/gvm/public/v1{path}"), } } diff --git a/crates/gvm-gateway-rest/src/auth_policy_test.rs b/crates/gvm-gateway-rest/src/auth_policy_test.rs index b9995398..fe02ba59 100644 --- a/crates/gvm-gateway-rest/src/auth_policy_test.rs +++ b/crates/gvm-gateway-rest/src/auth_policy_test.rs @@ -7,27 +7,27 @@ use axum::http::Method; #[test] fn classifies_public_routes() { assert_eq!( - classify_runtime_route(&Method::GET, "/health"), + classify_runtime_route(&Method::GET, "/gvm/health"), Some(RestRouteAuthPolicy::Public) ); assert_eq!( - classify_runtime_route(&Method::GET, "/ready"), + classify_runtime_route(&Method::GET, "/gvm/ready"), Some(RestRouteAuthPolicy::Public) ); assert_eq!( - classify_runtime_route(&Method::GET, "/api/v1/version"), + classify_runtime_route(&Method::GET, "/gvm/public/v1/version"), Some(RestRouteAuthPolicy::Public) ); assert_eq!( - classify_runtime_route(&Method::GET, "/api/v1/openapi.json"), + classify_runtime_route(&Method::GET, "/gvm/public/v1/openapi.json"), Some(RestRouteAuthPolicy::Public) ); assert_eq!( - classify_runtime_route(&Method::GET, "/api/v1/docs"), + classify_runtime_route(&Method::GET, "/gvm/public/v1/docs"), Some(RestRouteAuthPolicy::Public) ); assert_eq!( - classify_runtime_route(&Method::GET, "/api/v1/docs/redoc.standalone.js"), + classify_runtime_route(&Method::GET, "/gvm/public/v1/docs/redoc.standalone.js"), Some(RestRouteAuthPolicy::Public) ); } @@ -35,11 +35,11 @@ fn classifies_public_routes() { #[test] fn classifies_session_routes() { assert_eq!( - classify_runtime_route(&Method::POST, "/api/v1/session"), + classify_runtime_route(&Method::POST, "/gvm/public/v1/session"), Some(RestRouteAuthPolicy::SessionCreate) ); assert_eq!( - classify_runtime_route(&Method::GET, "/api/v1/session"), + classify_runtime_route(&Method::GET, "/gvm/public/v1/session"), Some(RestRouteAuthPolicy::SessionCurrent) ); } @@ -50,8 +50,8 @@ fn classifies_only_report_export_job_creation_as_bearer_only() { // retain a persistent bearer session instead of a request-scoped Basic // session that middleware tears down as soon as the response is returned. for path in [ - "/api/v1/reports/550e8400-e29b-41d4-a716-446655440000/exports", - "/api/v1/reports/{id}/exports", + "/gvm/public/v1/reports/550e8400-e29b-41d4-a716-446655440000/exports", + "/gvm/public/v1/reports/{id}/exports", ] { assert_eq!( classify_runtime_route(&Method::POST, path), @@ -62,12 +62,12 @@ fn classifies_only_report_export_job_creation_as_bearer_only() { assert_eq!( classify_runtime_route( &Method::GET, - "/api/v1/reports/550e8400-e29b-41d4-a716-446655440000/exports" + "/gvm/public/v1/reports/550e8400-e29b-41d4-a716-446655440000/exports" ), Some(RestRouteAuthPolicy::Protected) ); assert_eq!( - classify_runtime_route(&Method::POST, "/api/v1/reports/exports"), + classify_runtime_route(&Method::POST, "/gvm/public/v1/reports/exports"), Some(RestRouteAuthPolicy::Protected) ); } @@ -75,28 +75,28 @@ fn classifies_only_report_export_job_creation_as_bearer_only() { #[test] fn treats_non_session_api_routes_as_protected_by_default() { assert_eq!( - classify_runtime_route(&Method::GET, "/api/v1/alerts"), + classify_runtime_route(&Method::GET, "/gvm/public/v1/alerts"), Some(RestRouteAuthPolicy::Protected) ); assert_eq!( - classify_runtime_route(&Method::GET, "/api/v1/future-resource"), + classify_runtime_route(&Method::GET, "/gvm/public/v1/future-resource"), Some(RestRouteAuthPolicy::Protected) ); assert_eq!( - classify_runtime_route(&Method::POST, "/api/v1/reports"), + classify_runtime_route(&Method::POST, "/gvm/public/v1/reports"), Some(RestRouteAuthPolicy::Protected) ); } #[test] fn maps_openapi_paths_back_to_runtime_paths() { - assert_eq!(runtime_path_from_openapi_path("/health"), "/health"); + assert_eq!(runtime_path_from_openapi_path("/gvm/health"), "/gvm/health"); assert_eq!( runtime_path_from_openapi_path("/version"), - "/api/v1/version" + "/gvm/public/v1/version" ); assert_eq!( runtime_path_from_openapi_path("/reports/{id}/exports"), - "/api/v1/reports/{id}/exports" + "/gvm/public/v1/reports/{id}/exports" ); } diff --git a/crates/gvm-gateway-rest/src/credentials.rs b/crates/gvm-gateway-rest/src/credentials.rs index 65cf0847..3a62df10 100644 --- a/crates/gvm-gateway-rest/src/credentials.rs +++ b/crates/gvm-gateway-rest/src/credentials.rs @@ -783,7 +783,7 @@ pub(crate) fn list_credentials_docs(op: TransformOperation<'_>) -> TransformOper problem_response::<401>(op, "Authentication required or session expired") } -/// OpenAPI transform for `GET /api/v1/credential-stores`. +/// OpenAPI transform for `GET /gvm/public/v1/credential-stores`. pub(crate) fn list_credential_stores_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getCredentialStores") diff --git a/crates/gvm-gateway-rest/src/docs.rs b/crates/gvm-gateway-rest/src/docs.rs index 7ba1d6d8..68dbb7e8 100644 --- a/crates/gvm-gateway-rest/src/docs.rs +++ b/crates/gvm-gateway-rest/src/docs.rs @@ -20,8 +20,8 @@ const REDOC_HTML: &str = r#" GVM REST API documentation - - + + "#; diff --git a/crates/gvm-gateway-rest/src/error_test.rs b/crates/gvm-gateway-rest/src/error_test.rs index 3891629d..5b99c23c 100644 --- a/crates/gvm-gateway-rest/src/error_test.rs +++ b/crates/gvm-gateway-rest/src/error_test.rs @@ -7,7 +7,7 @@ use super::*; fn session_expired_problem_uses_https_type_and_public_code() { let error = RestError::from_gateway_error( GatewayError::SessionExpired("session expired".to_string()), - "/api/v1/targets", + "/gvm/public/v1/targets", ); assert_eq!(error.status, StatusCode::UNAUTHORIZED); @@ -24,8 +24,10 @@ fn session_expired_problem_uses_https_type_and_public_code() { #[test] fn internal_error_problem_hides_private_detail() { let private_detail = "database password leaked in stack trace"; - let error = - RestError::from_gateway_error(GatewayError::Internal(private_detail.to_string()), "/ready"); + let error = RestError::from_gateway_error( + GatewayError::Internal(private_detail.to_string()), + "/gvm/ready", + ); assert_eq!(error.status, StatusCode::INTERNAL_SERVER_ERROR); let json = serde_json::to_value(&error.problem).unwrap(); @@ -42,7 +44,7 @@ fn backend_unavailable_problem_hides_private_detail() { let private_detail = "failed to connect to /run/gvmd/gvmd.sock as admin"; let error = RestError::from_gateway_error( GatewayError::BackendUnavailable(private_detail.to_string()), - "/api/v1/tasks", + "/gvm/public/v1/tasks", ); assert_eq!(error.status, StatusCode::BAD_GATEWAY); @@ -60,7 +62,7 @@ fn invalid_input_problem_keeps_client_actionable_detail() { let public_detail = "field 'name' is required"; let error = RestError::from_gateway_error( GatewayError::InvalidInput(public_detail.to_string()), - "/api/v1/targets", + "/gvm/public/v1/targets", ); assert_eq!(error.status, StatusCode::BAD_REQUEST); @@ -83,7 +85,7 @@ fn route_not_found_problem_uses_public_code() { #[test] fn service_unavailable_problem_uses_public_code() { - let error = RestError::service_unavailable("draining", "/api/v1/targets"); + let error = RestError::service_unavailable("draining", "/gvm/public/v1/targets"); assert_eq!(error.status, StatusCode::SERVICE_UNAVAILABLE); let json = serde_json::to_value(&error.problem).unwrap(); @@ -98,7 +100,7 @@ fn service_unavailable_problem_uses_public_code() { fn not_implemented_problem_uses_public_code() { let error = RestError::from_gateway_error( GatewayError::NotImplemented("backend does not support this command".to_string()), - "/api/v1/reports/123/vulnerabilities", + "/gvm/public/v1/reports/123/vulnerabilities", ); assert_eq!(error.status, StatusCode::NOT_IMPLEMENTED); @@ -116,7 +118,7 @@ fn temporary_inventory_issuance_failure_is_503_not_transport_502() { // A known but temporarily unavailable issuer is distinct from an unsupported command or transport failure. let error = RestError::from_gateway_error( GatewayError::ServiceUnavailable("Inventory issuance is temporarily unavailable.".into()), - "/api/v1/agents/inventory-token", + "/gvm/public/v1/agents/inventory-token", ); assert_eq!(error.status, StatusCode::SERVICE_UNAVAILABLE); assert_eq!(error.problem.code, "service_unavailable"); diff --git a/crates/gvm-gateway-rest/src/generic_resources.rs b/crates/gvm-gateway-rest/src/generic_resources.rs index b530af5b..834e110f 100644 --- a/crates/gvm-gateway-rest/src/generic_resources.rs +++ b/crates/gvm-gateway-rest/src/generic_resources.rs @@ -480,7 +480,7 @@ pub async fn clone_config( headers, id, uri, - "/api/v1/configs", + "/gvm/public/v1/configs", |service, token, id| async move { service.clone_config(&token, &id).await }, ) .await @@ -532,7 +532,7 @@ where problem_response::<502>(op, "Backend service unreachable or connection failed") } -/// OpenAPI transform for `GET /api/v1/assets`. +/// OpenAPI transform for `GET /gvm/public/v1/assets`. pub(crate) fn list_assets_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { list_docs::( op, @@ -543,7 +543,7 @@ pub(crate) fn list_assets_docs(op: TransformOperation<'_>) -> TransformOperation ) } -/// OpenAPI transform for `GET /api/v1/assets/{id}`. +/// OpenAPI transform for `GET /gvm/public/v1/assets/{id}`. pub(crate) fn get_asset_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getAsset") @@ -561,7 +561,7 @@ pub(crate) fn get_asset_docs(op: TransformOperation<'_>) -> TransformOperation<' problem_response::<502>(op, "Backend service unreachable or connection failed") } -/// OpenAPI transform for `PUT /api/v1/assets/{id}`. +/// OpenAPI transform for `PUT /gvm/public/v1/assets/{id}`. pub(crate) fn update_asset_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("modifyAsset") @@ -582,7 +582,7 @@ pub(crate) fn update_asset_docs(op: TransformOperation<'_>) -> TransformOperatio problem_response::<502>(op, "Backend service unreachable or connection failed") } -/// OpenAPI transform for `DELETE /api/v1/assets/{id}`. +/// OpenAPI transform for `DELETE /gvm/public/v1/assets/{id}`. pub(crate) fn delete_asset_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("deleteAsset") @@ -600,7 +600,7 @@ pub(crate) fn delete_asset_docs(op: TransformOperation<'_>) -> TransformOperatio problem_response::<502>(op, "Backend service unreachable or connection failed") } -/// OpenAPI transform for `GET /api/v1/configs`. +/// OpenAPI transform for `GET /gvm/public/v1/configs`. pub(crate) fn list_configs_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { list_docs::( op, @@ -611,12 +611,12 @@ pub(crate) fn list_configs_docs(op: TransformOperation<'_>) -> TransformOperatio ) } -/// OpenAPI transform for `GET /api/v1/configs/{id}`. +/// OpenAPI transform for `GET /gvm/public/v1/configs/{id}`. pub(crate) fn get_config_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { item_docs::(op, "getConfig", "Configs", "Get a generic config") } -/// OpenAPI transform for `DELETE /api/v1/configs/{id}`. +/// OpenAPI transform for `DELETE /gvm/public/v1/configs/{id}`. pub(crate) fn delete_config_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("deleteConfig") @@ -636,7 +636,7 @@ pub(crate) fn delete_config_docs(op: TransformOperation<'_>) -> TransformOperati problem_response::<502>(op, "Backend service unreachable or connection failed") } -/// OpenAPI transform for `POST /api/v1/configs/{id}/clone`. +/// OpenAPI transform for `POST /gvm/public/v1/configs/{id}/clone`. pub(crate) fn clone_config_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("cloneConfig") diff --git a/crates/gvm-gateway-rest/src/jobs.rs b/crates/gvm-gateway-rest/src/jobs.rs index 5bd3c3cf..ee188fad 100644 --- a/crates/gvm-gateway-rest/src/jobs.rs +++ b/crates/gvm-gateway-rest/src/jobs.rs @@ -401,7 +401,7 @@ pub(crate) async fn create_report_export_job( .await { Ok(job) => { - let location = format!("/api/v1/jobs/{}", job.id); + let location = format!("/gvm/public/v1/jobs/{}", job.id); ( StatusCode::ACCEPTED, [ @@ -496,7 +496,7 @@ pub(crate) async fn download_job_result( } } -/// OpenAPI transform for `POST /api/v1/reports/{id}/exports`. +/// OpenAPI transform for `POST /gvm/public/v1/reports/{id}/exports`. pub(crate) fn create_report_export_job_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("createReportExportJob") @@ -518,7 +518,7 @@ pub(crate) fn create_report_export_job_docs(op: TransformOperation<'_>) -> Trans problem_response::<502>(op, "Backend service unreachable or connection failed") } -/// OpenAPI transform for `GET /api/v1/jobs/{id}`. +/// OpenAPI transform for `GET /gvm/public/v1/jobs/{id}`. pub(crate) fn get_job_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getJob") @@ -533,7 +533,7 @@ pub(crate) fn get_job_docs(op: TransformOperation<'_>) -> TransformOperation<'_> problem_response::<404>(op, "Resource not found") } -/// OpenAPI transform for `DELETE /api/v1/jobs/{id}`. +/// OpenAPI transform for `DELETE /gvm/public/v1/jobs/{id}`. pub(crate) fn cancel_job_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("cancelJob") @@ -552,7 +552,7 @@ pub(crate) fn cancel_job_docs(op: TransformOperation<'_>) -> TransformOperation< problem_response::<409>(op, "Resource state conflict") } -/// OpenAPI transform for `GET /api/v1/jobs/{id}/result`. +/// OpenAPI transform for `GET /gvm/public/v1/jobs/{id}/result`. pub(crate) fn download_job_result_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("downloadJobResult") diff --git a/crates/gvm-gateway-rest/src/openapi.rs b/crates/gvm-gateway-rest/src/openapi.rs index e70ab6d5..05ddbdcd 100644 --- a/crates/gvm-gateway-rest/src/openapi.rs +++ b/crates/gvm-gateway-rest/src/openapi.rs @@ -127,7 +127,7 @@ fn retry_after_header(description: &'static str) -> ReferenceOr
{ pub(crate) fn finalize_document(mut document: Value) -> Value { document["servers"] = json!([ { - "url": "/api/v1", + "url": "/gvm/public/v1", "description": "Base path for versioned API endpoints" } ]); @@ -447,7 +447,10 @@ fn operation_can_proxy_to_backend(path: &str, method_name: &str) -> bool { | RestRouteAuthPolicy::BearerOnly, ) => true, Some(RestRouteAuthPolicy::Public) => { - matches!(runtime_path.as_str(), "/ready" | "/api/v1/version") + matches!( + runtime_path.as_str(), + "/gvm/ready" | "/gvm/public/v1/version" + ) } Some(RestRouteAuthPolicy::SessionCurrent) | None => false, } @@ -546,7 +549,7 @@ fn normalize_paths(source_paths: &Map) -> Map { source_paths .iter() .map(|(source_path, path_item)| { - let normalized_path = source_path.strip_prefix("/api/v1").map_or_else( + let normalized_path = source_path.strip_prefix("/gvm/public/v1").map_or_else( || source_path.clone(), |suffix| { if suffix.is_empty() { @@ -569,7 +572,7 @@ fn add_probe_server_overrides(normalized_paths: &mut Map) { } ]); - for path in ["/health", "/ready"] { + for path in ["/gvm/health", "/gvm/ready"] { if let Some(path_item) = normalized_paths .get_mut(path) .and_then(Value::as_object_mut) diff --git a/crates/gvm-gateway-rest/src/openapi/doc.rs b/crates/gvm-gateway-rest/src/openapi/doc.rs index a8266d1c..7be76c75 100644 --- a/crates/gvm-gateway-rest/src/openapi/doc.rs +++ b/crates/gvm-gateway-rest/src/openapi/doc.rs @@ -39,7 +39,7 @@ impl ProblemDetailDoc { title: "Bad Request".to_string(), status: 400, detail: Some("request validation failed".to_string()), - instance: Some("/api/v1/targets".to_string()), + instance: Some("/gvm/public/v1/targets".to_string()), } } } diff --git a/crates/gvm-gateway-rest/src/openapi_test.rs b/crates/gvm-gateway-rest/src/openapi_test.rs index e2969cc8..faa3f196 100644 --- a/crates/gvm-gateway-rest/src/openapi_test.rs +++ b/crates/gvm-gateway-rest/src/openapi_test.rs @@ -1937,21 +1937,21 @@ fn generated_openapi_excludes_the_browser_docs_ui() { #[test] fn normalize_paths_strips_runtime_api_prefix() { let source_paths = serde_json::from_value::>(serde_json::json!({ - "/health": { "get": {} }, - "/ready": { "get": {} }, - "/api/v1/version": { "get": {} }, - "/api/v1/reports/{id}/exports": { "post": {} } + "/gvm/health": { "get": {} }, + "/gvm/ready": { "get": {} }, + "/gvm/public/v1/version": { "get": {} }, + "/gvm/public/v1/reports/{id}/exports": { "post": {} } })) .unwrap(); let normalized = normalize_paths(&source_paths); - assert!(normalized.contains_key("/health")); - assert!(normalized.contains_key("/ready")); + assert!(normalized.contains_key("/gvm/health")); + assert!(normalized.contains_key("/gvm/ready")); assert!(normalized.contains_key("/version")); assert!(normalized.contains_key("/reports/{id}/exports")); - assert!(!normalized.contains_key("/api/v1/version")); - assert!(!normalized.contains_key("/api/v1/reports/{id}/exports")); + assert!(!normalized.contains_key("/gvm/public/v1/version")); + assert!(!normalized.contains_key("/gvm/public/v1/reports/{id}/exports")); } fn root_spec() -> Value { diff --git a/crates/gvm-gateway-rest/src/rate_limit.rs b/crates/gvm-gateway-rest/src/rate_limit.rs index 4efcc1c8..f25eef99 100644 --- a/crates/gvm-gateway-rest/src/rate_limit.rs +++ b/crates/gvm-gateway-rest/src/rate_limit.rs @@ -178,7 +178,7 @@ fn prune_expired_buckets(state: &mut RateLimitState, now: u64, window_secs: u64) } pub(crate) fn is_rate_limited_path(path: &str) -> bool { - path.starts_with("/api/v1/") && path != "/api/v1/openapi.json" + path.starts_with("/gvm/public/v1/") && path != "/gvm/public/v1/openapi.json" } pub(crate) fn too_many_requests_response(instance: &str, retry_after_secs: u64) -> Response { @@ -197,7 +197,7 @@ pub(crate) fn too_many_requests_response(instance: &str, retry_after_secs: u64) fn rate_limit_subject(request: &Request, trusted_proxy_cidrs: &[TrustedProxyCidr]) -> String { let path = request.uri().path(); - if path == "/api/v1/session" { + if path == "/gvm/public/v1/session" { return format!( "session-create:{}", source_subject(request, trusted_proxy_cidrs) diff --git a/crates/gvm-gateway-rest/src/rate_limit_test.rs b/crates/gvm-gateway-rest/src/rate_limit_test.rs index c21829c5..baccb853 100644 --- a/crates/gvm-gateway-rest/src/rate_limit_test.rs +++ b/crates/gvm-gateway-rest/src/rate_limit_test.rs @@ -40,7 +40,7 @@ fn trusted_loopback() -> Vec { fn bearer_subject_uses_intentional_stable_digest() { // This locks the rate-limit bucket contract so Rust hasher changes or // process restarts cannot reshuffle authenticated subjects. - let mut request = request("/api/v1/targets"); + let mut request = request("/gvm/public/v1/targets"); request.headers_mut().insert( header::AUTHORIZATION, "Bearer gvm_sess_secret".parse().unwrap(), @@ -53,7 +53,7 @@ fn bearer_subject_uses_intentional_stable_digest() { fn basic_subject_uses_intentional_stable_digest() { // Request-scoped Basic auth remains separately bucketed without keeping // the credential material in the bucket key. - let mut request = request("/api/v1/targets"); + let mut request = request("/gvm/public/v1/targets"); request.headers_mut().insert( header::AUTHORIZATION, "Basic YWRtaW46YWRtaW4=".parse().unwrap(), @@ -66,7 +66,7 @@ fn basic_subject_uses_intentional_stable_digest() { fn session_creation_uses_source_ip_even_when_basic_auth_is_present() { // Session creation happens before the caller has an authenticated // subject, so brute-force pressure is bucketed by source address. - let mut request = request("/api/v1/session"); + let mut request = request("/gvm/public/v1/session"); request.headers_mut().insert( header::AUTHORIZATION, "Basic YWRtaW46YWRtaW4=".parse().unwrap(), @@ -88,14 +88,14 @@ fn session_creation_uses_source_ip_even_when_basic_auth_is_present() { fn session_creation_source_key_ignores_ephemeral_port() { // Multiple TCP connections from the same client IP must share the same // unauthenticated session-creation bucket. - let mut first = request("/api/v1/session"); + let mut first = request("/gvm/public/v1/session"); first .extensions_mut() .insert(ConnectInfo(ClientPeerAddr(SocketAddr::new( IpAddr::V4(Ipv4Addr::new(192, 0, 2, 10)), 40_000, )))); - let mut second = request("/api/v1/session"); + let mut second = request("/gvm/public/v1/session"); second .extensions_mut() .insert(ConnectInfo(ClientPeerAddr(SocketAddr::new( @@ -113,8 +113,16 @@ fn session_creation_source_key_ignores_ephemeral_port() { fn anonymous_subject_uses_source_ip_for_protected_routes() { // Missing credentials on protected routes must not collapse every // unauthenticated caller into one shared subject bucket. - let first = request_from_ip("/api/v1/targets", Ipv4Addr::new(192, 0, 2, 10), 40_000); - let second = request_from_ip("/api/v1/targets", Ipv4Addr::new(192, 0, 2, 11), 40_001); + let first = request_from_ip( + "/gvm/public/v1/targets", + Ipv4Addr::new(192, 0, 2, 10), + 40_000, + ); + let second = request_from_ip( + "/gvm/public/v1/targets", + Ipv4Addr::new(192, 0, 2, 11), + 40_001, + ); assert_eq!(rate_limit_subject(&first, &[]), "anonymous:ip:192.0.2.10"); assert_eq!(rate_limit_subject(&second, &[]), "anonymous:ip:192.0.2.11"); @@ -124,8 +132,16 @@ fn anonymous_subject_uses_source_ip_for_protected_routes() { fn anonymous_subject_ignores_ephemeral_port_for_protected_routes() { // A caller opening multiple connections from the same IP should still // consume the same unauthenticated protected-route bucket. - let first = request_from_ip("/api/v1/targets", Ipv4Addr::new(192, 0, 2, 10), 40_000); - let second = request_from_ip("/api/v1/targets", Ipv4Addr::new(192, 0, 2, 10), 40_001); + let first = request_from_ip( + "/gvm/public/v1/targets", + Ipv4Addr::new(192, 0, 2, 10), + 40_000, + ); + let second = request_from_ip( + "/gvm/public/v1/targets", + Ipv4Addr::new(192, 0, 2, 10), + 40_001, + ); assert_eq!( rate_limit_subject(&first, &[]), @@ -138,7 +154,11 @@ fn trusted_proxy_session_creation_uses_forwarded_client_ip() { // In the container proxy deployment, the direct TCP peer is the proxy. // When that proxy is explicitly trusted, unauthenticated login pressure // must bucket by the original client IP instead of the shared proxy IP. - let mut request = request_from_ip("/api/v1/session", Ipv4Addr::new(127, 0, 0, 1), 40_000); + let mut request = request_from_ip( + "/gvm/public/v1/session", + Ipv4Addr::new(127, 0, 0, 1), + 40_000, + ); request .headers_mut() .insert(X_FORWARDED_FOR, "198.51.100.10".parse().unwrap()); @@ -153,7 +173,11 @@ fn trusted_proxy_session_creation_uses_forwarded_client_ip() { fn untrusted_peer_ignores_forwarded_client_ip() { // X-Forwarded-For is caller-controlled unless the direct peer is a // configured proxy, so spoofed headers must not move the bucket key. - let mut request = request_from_ip("/api/v1/session", Ipv4Addr::new(203, 0, 113, 20), 40_000); + let mut request = request_from_ip( + "/gvm/public/v1/session", + Ipv4Addr::new(203, 0, 113, 20), + 40_000, + ); request .headers_mut() .insert(X_FORWARDED_FOR, "198.51.100.10".parse().unwrap()); @@ -168,7 +192,11 @@ fn untrusted_peer_ignores_forwarded_client_ip() { fn malformed_forwarded_client_ip_falls_back_to_proxy_peer() { // A trusted proxy with a malformed forwarded header should fail closed // to the direct peer instead of creating an attacker-chosen bucket. - let mut request = request_from_ip("/api/v1/session", Ipv4Addr::new(127, 0, 0, 1), 40_000); + let mut request = request_from_ip( + "/gvm/public/v1/session", + Ipv4Addr::new(127, 0, 0, 1), + 40_000, + ); request .headers_mut() .insert(X_FORWARDED_FOR, "not-an-ip".parse().unwrap()); @@ -183,7 +211,11 @@ fn malformed_forwarded_client_ip_falls_back_to_proxy_peer() { fn trusted_proxy_uses_first_forwarded_client_ip() { // X-Forwarded-For is an ordered chain. The first address is the client // that should receive the unauthenticated session-creation bucket. - let mut request = request_from_ip("/api/v1/session", Ipv4Addr::new(127, 0, 0, 1), 40_000); + let mut request = request_from_ip( + "/gvm/public/v1/session", + Ipv4Addr::new(127, 0, 0, 1), + 40_000, + ); request.headers_mut().insert( X_FORWARDED_FOR, "198.51.100.10, 203.0.113.30".parse().unwrap(), @@ -223,7 +255,10 @@ fn poisoned_rate_limit_state_fails_closed() { })) .is_err()); - assert_eq!(limiter.check_request(&request("/api/v1/targets")), Some(60)); + assert_eq!( + limiter.check_request(&request("/gvm/public/v1/targets")), + Some(60) + ); } #[test] diff --git a/crates/gvm-gateway-rest/src/reports.rs b/crates/gvm-gateway-rest/src/reports.rs index 5a040712..8276f4b5 100644 --- a/crates/gvm-gateway-rest/src/reports.rs +++ b/crates/gvm-gateway-rest/src/reports.rs @@ -829,7 +829,7 @@ pub async fn import_report(State(service): State, request: Reque ) .await { - Ok(id) => created_resource("/api/v1/reports", &id), + Ok(id) => created_resource("/gvm/public/v1/reports", &id), Err(error) => RestError::from_gateway_error(error, instance).into_response(), } } @@ -1246,7 +1246,7 @@ pub async fn get_report_cves( // OpenAPI transforms // ============================================================================ -/// OpenAPI transform for `POST /api/v1/reports`. +/// OpenAPI transform for `POST /gvm/public/v1/reports`. pub(crate) fn import_report_docs(mut op: TransformOperation<'_>) -> TransformOperation<'_> { op = op .id("importReport") @@ -1283,7 +1283,7 @@ pub(crate) fn import_report_docs(mut op: TransformOperation<'_>) -> TransformOpe problem_response::<504>(op, "Backend request timed out") } -/// OpenAPI transform for `GET /api/v1/reports`. +/// OpenAPI transform for `GET /gvm/public/v1/reports`. pub(crate) fn list_reports_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getReports") @@ -1297,7 +1297,7 @@ pub(crate) fn list_reports_docs(op: TransformOperation<'_>) -> TransformOperatio problem_response::<401>(op, "Authentication required or session expired") } -/// OpenAPI transform for `GET /api/v1/reports/{id}`. +/// OpenAPI transform for `GET /gvm/public/v1/reports/{id}`. pub(crate) fn get_report_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getReport") @@ -1316,7 +1316,7 @@ pub(crate) fn get_report_docs(op: TransformOperation<'_>) -> TransformOperation< problem_response::<404>(op, "Resource not found") } -/// OpenAPI transform for `DELETE /api/v1/reports/{id}`. +/// OpenAPI transform for `DELETE /gvm/public/v1/reports/{id}`. pub(crate) fn delete_report_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("deleteReport") @@ -1332,7 +1332,7 @@ pub(crate) fn delete_report_docs(op: TransformOperation<'_>) -> TransformOperati problem_response::<404>(op, "Resource not found") } -/// OpenAPI transform for `GET /api/v1/reports/{id}/results`. +/// OpenAPI transform for `GET /gvm/public/v1/reports/{id}/results`. pub(crate) fn get_report_results_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getReportResults") @@ -1352,7 +1352,7 @@ pub(crate) fn get_report_results_docs(op: TransformOperation<'_>) -> TransformOp ) } -/// OpenAPI transform for `GET /api/v1/reports/{id}/vulnerabilities`. +/// OpenAPI transform for `GET /gvm/public/v1/reports/{id}/vulnerabilities`. pub(crate) fn get_report_vulnerabilities_docs( op: TransformOperation<'_>, ) -> TransformOperation<'_> { @@ -1376,7 +1376,7 @@ pub(crate) fn get_report_vulnerabilities_docs( problem_response::<502>(op, "Backend service unreachable or connection failed") } -/// OpenAPI transform for `GET /api/v1/reports/{id}/tls-certificates`. +/// OpenAPI transform for `GET /gvm/public/v1/reports/{id}/tls-certificates`. pub(crate) fn get_report_tls_certificates_docs( op: TransformOperation<'_>, ) -> TransformOperation<'_> { @@ -1400,7 +1400,7 @@ pub(crate) fn get_report_tls_certificates_docs( problem_response::<502>(op, "Backend service unreachable or connection failed") } -/// OpenAPI transform for `GET /api/v1/reports/{id}/errors`. +/// OpenAPI transform for `GET /gvm/public/v1/reports/{id}/errors`. pub(crate) fn get_report_errors_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getReportErrors") @@ -1422,7 +1422,7 @@ pub(crate) fn get_report_errors_docs(op: TransformOperation<'_>) -> TransformOpe problem_response::<502>(op, "Backend service unreachable or connection failed") } -/// OpenAPI transform for `GET /api/v1/reports/{id}/closed-cves`. +/// OpenAPI transform for `GET /gvm/public/v1/reports/{id}/closed-cves`. pub(crate) fn get_report_closed_cves_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getReportClosedCves") @@ -1444,7 +1444,7 @@ pub(crate) fn get_report_closed_cves_docs(op: TransformOperation<'_>) -> Transfo problem_response::<502>(op, "Backend service unreachable or connection failed") } -/// OpenAPI transform for `GET /api/v1/reports/{id}/hosts`. +/// OpenAPI transform for `GET /gvm/public/v1/reports/{id}/hosts`. pub(crate) fn get_report_hosts_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getReportHosts") @@ -1466,7 +1466,7 @@ pub(crate) fn get_report_hosts_docs(op: TransformOperation<'_>) -> TransformOper ) } -/// OpenAPI transform for `GET /api/v1/reports/{id}/ports`. +/// OpenAPI transform for `GET /gvm/public/v1/reports/{id}/ports`. pub(crate) fn get_report_ports_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getReportPorts") @@ -1488,7 +1488,7 @@ pub(crate) fn get_report_ports_docs(op: TransformOperation<'_>) -> TransformOper ) } -/// OpenAPI transform for `GET /api/v1/reports/{id}/applications`. +/// OpenAPI transform for `GET /gvm/public/v1/reports/{id}/applications`. pub(crate) fn get_report_applications_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getReportApplications") @@ -1510,7 +1510,7 @@ pub(crate) fn get_report_applications_docs(op: TransformOperation<'_>) -> Transf ) } -/// OpenAPI transform for `GET /api/v1/reports/{id}/operating-systems`. +/// OpenAPI transform for `GET /gvm/public/v1/reports/{id}/operating-systems`. pub(crate) fn get_report_operating_systems_docs( op: TransformOperation<'_>, ) -> TransformOperation<'_> { @@ -1534,7 +1534,7 @@ pub(crate) fn get_report_operating_systems_docs( ) } -/// OpenAPI transform for `GET /api/v1/reports/{id}/cves`. +/// OpenAPI transform for `GET /gvm/public/v1/reports/{id}/cves`. pub(crate) fn get_report_cves_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getReportCves") diff --git a/crates/gvm-gateway-rest/src/results.rs b/crates/gvm-gateway-rest/src/results.rs index 52d89055..da8c60eb 100644 --- a/crates/gvm-gateway-rest/src/results.rs +++ b/crates/gvm-gateway-rest/src/results.rs @@ -370,7 +370,7 @@ pub async fn get_result( // OpenAPI transforms // ============================================================================ -/// OpenAPI transform for `GET /api/v1/results`. +/// OpenAPI transform for `GET /gvm/public/v1/results`. pub(crate) fn list_results_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getResults") @@ -384,7 +384,7 @@ pub(crate) fn list_results_docs(op: TransformOperation<'_>) -> TransformOperatio problem_response::<401>(op, "Authentication required or session expired") } -/// OpenAPI transform for `GET /api/v1/results/{id}`. +/// OpenAPI transform for `GET /gvm/public/v1/results/{id}`. pub(crate) fn get_result_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getResult") diff --git a/crates/gvm-gateway-rest/src/router.rs b/crates/gvm-gateway-rest/src/router.rs index fa4fc393..32e3c29e 100644 --- a/crates/gvm-gateway-rest/src/router.rs +++ b/crates/gvm-gateway-rest/src/router.rs @@ -233,9 +233,9 @@ pub fn build_router_with_runtime_and_security( let router: Router = documented_router() // Browser documentation is operational UI, not part of the REST API // contract generated from `ApiRouter`. - .route("/api/v1/docs", get(api_docs)) - .route("/api/v1/docs/redoc.standalone.js", get(redoc_js)) - .route("/api/v1/openapi.json", get(serve_openapi)) + .route("/gvm/public/v1/docs", get(api_docs)) + .route("/gvm/public/v1/docs/redoc.standalone.js", get(redoc_js)) + .route("/gvm/public/v1/openapi.json", get(serve_openapi)) .fallback(not_found) .into(); @@ -272,681 +272,792 @@ pub(crate) fn build_openapi() -> Value { fn documented_router() -> ApiRouter { ApiRouter::new() - .api_route("/health", get_with(health, health_docs)) - .api_route("/ready", get_with(ready, ready_docs)) - .api_route("/api/v1/version", get_with(version, version_docs)) + .api_route("/gvm/health", get_with(health, health_docs)) + .api_route("/gvm/ready", get_with(ready, ready_docs)) + .api_route("/gvm/public/v1/version", get_with(version, version_docs)) .api_route( - "/api/v1/timezones", + "/gvm/public/v1/timezones", get_with(list_timezones, list_timezones_docs), ) // Session lifecycle .api_route( - "/api/v1/session", + "/gvm/public/v1/session", post_with(create_session, create_session_docs), ) - .api_route("/api/v1/session", get_with(get_session, get_session_docs)) .api_route( - "/api/v1/session", + "/gvm/public/v1/session", + get_with(get_session, get_session_docs), + ) + .api_route( + "/gvm/public/v1/session", delete_with(delete_session, delete_session_docs), ) // Targets - .api_route("/api/v1/targets", get_with(list_targets, list_targets_docs)) .api_route( - "/api/v1/targets", + "/gvm/public/v1/targets", + get_with(list_targets, list_targets_docs), + ) + .api_route( + "/gvm/public/v1/targets", post_with(create_target, create_target_docs), ) .api_route( - "/api/v1/targets/{id}", + "/gvm/public/v1/targets/{id}", get_with(get_target, get_target_docs), ) .api_route( - "/api/v1/targets/{id}", + "/gvm/public/v1/targets/{id}", put_with(update_target, update_target_docs), ) .api_route( - "/api/v1/targets/{id}", + "/gvm/public/v1/targets/{id}", delete_with(delete_target, delete_target_docs), ) .api_route( - "/api/v1/targets/{id}/clone", + "/gvm/public/v1/targets/{id}/clone", post_with(clone_target, clone_target_docs), ) // Agents and agent groups .api_route( - "/api/v1/agents/inventory-token", + "/gvm/public/v1/agents/inventory-token", post_with(get_agent_inventory_token, get_agent_inventory_token_docs), ) - .api_route("/api/v1/agents", get_with(list_agents, list_agents_docs)) - .api_route("/api/v1/agents/{id}", get_with(get_agent, get_agent_docs)) .api_route( - "/api/v1/agents/{id}", + "/gvm/public/v1/agents", + get_with(list_agents, list_agents_docs), + ) + .api_route( + "/gvm/public/v1/agents/{id}", + get_with(get_agent, get_agent_docs), + ) + .api_route( + "/gvm/public/v1/agents/{id}", put_with(update_agent, modify_agent_docs), ) .api_route( - "/api/v1/agents/{id}", + "/gvm/public/v1/agents/{id}", delete_with(delete_agent, delete_agent_docs), ) .api_route( - "/api/v1/agents/sync", + "/gvm/public/v1/agents/sync", post_with(sync_agents, sync_agents_docs), ) .api_route( - "/api/v1/agents/{id}/support-bundle", + "/gvm/public/v1/agents/{id}/support-bundle", get_with(get_agent_support_bundle, get_agent_support_bundle_docs), ) .api_route( - "/api/v1/agent-control-scan-configs/{id}", + "/gvm/public/v1/agent-control-scan-configs/{id}", put_with( update_agent_control_scan_config, modify_agent_control_scan_config_docs, ), ) .api_route( - "/api/v1/scanners/{id}/agent-installer-instruction", + "/gvm/public/v1/scanners/{id}/agent-installer-instruction", get_with( get_agent_installer_instruction, get_agent_installer_instruction_docs, ), ) .api_route( - "/api/v1/agent-groups", + "/gvm/public/v1/agent-groups", get_with(list_agent_groups, list_agent_groups_docs), ) .api_route( - "/api/v1/agent-groups", + "/gvm/public/v1/agent-groups", post_with(create_agent_group, create_agent_group_docs), ) .api_route( - "/api/v1/agent-groups/{id}", + "/gvm/public/v1/agent-groups/{id}", get_with(get_agent_group, get_agent_group_docs), ) .api_route( - "/api/v1/agent-groups/{id}", + "/gvm/public/v1/agent-groups/{id}", put_with(update_agent_group, modify_agent_group_docs), ) .api_route( - "/api/v1/agent-groups/{id}", + "/gvm/public/v1/agent-groups/{id}", delete_with(delete_agent_group, delete_agent_group_docs), ) .api_route( - "/api/v1/agent-groups/{id}/clone", + "/gvm/public/v1/agent-groups/{id}/clone", post_with(clone_agent_group, clone_agent_group_docs), ) // Generic assets/configs remain distinct from specialized hosts/scan-configs contracts. - .api_route("/api/v1/assets", get_with(list_assets, list_assets_docs)) - .api_route("/api/v1/assets/{id}", get_with(get_asset, get_asset_docs)) .api_route( - "/api/v1/assets/{id}", + "/gvm/public/v1/assets", + get_with(list_assets, list_assets_docs), + ) + .api_route( + "/gvm/public/v1/assets/{id}", + get_with(get_asset, get_asset_docs), + ) + .api_route( + "/gvm/public/v1/assets/{id}", put_with(update_asset, update_asset_docs), ) .api_route( - "/api/v1/assets/{id}", + "/gvm/public/v1/assets/{id}", delete_with(delete_asset, delete_asset_docs), ) - .api_route("/api/v1/configs", get_with(list_configs, list_configs_docs)) .api_route( - "/api/v1/configs/{id}", + "/gvm/public/v1/configs", + get_with(list_configs, list_configs_docs), + ) + .api_route( + "/gvm/public/v1/configs/{id}", get_with(get_config, get_config_docs), ) .api_route( - "/api/v1/configs/{id}", + "/gvm/public/v1/configs/{id}", delete_with(delete_config, delete_config_docs), ) .api_route( - "/api/v1/configs/{id}/clone", + "/gvm/public/v1/configs/{id}/clone", post_with(clone_config, clone_config_docs), ) // New target families from current GVMD .api_route( - "/api/v1/oci-image-targets", + "/gvm/public/v1/oci-image-targets", get_with(list_oci_image_targets, list_oci_image_targets_docs), ) .api_route( - "/api/v1/oci-image-targets", + "/gvm/public/v1/oci-image-targets", post_with(create_oci_image_target, create_oci_image_target_docs), ) .api_route( - "/api/v1/oci-image-targets/{id}", + "/gvm/public/v1/oci-image-targets/{id}", get_with(get_oci_image_target, get_oci_image_target_docs), ) .api_route( - "/api/v1/oci-image-targets/{id}", + "/gvm/public/v1/oci-image-targets/{id}", put_with(update_oci_image_target, update_oci_image_target_docs), ) .api_route( - "/api/v1/oci-image-targets/{id}", + "/gvm/public/v1/oci-image-targets/{id}", delete_with(delete_oci_image_target, delete_oci_image_target_docs), ) .api_route( - "/api/v1/oci-image-targets/{id}/clone", + "/gvm/public/v1/oci-image-targets/{id}/clone", post_with(clone_oci_image_target, clone_oci_image_target_docs), ) .api_route( - "/api/v1/web-application-targets", + "/gvm/public/v1/web-application-targets", get_with( list_web_application_targets, list_web_application_targets_docs, ), ) .api_route( - "/api/v1/web-application-targets", + "/gvm/public/v1/web-application-targets", post_with( create_web_application_target, create_web_application_target_docs, ), ) .api_route( - "/api/v1/web-application-targets/{id}", + "/gvm/public/v1/web-application-targets/{id}", get_with(get_web_application_target, get_web_application_target_docs), ) .api_route( - "/api/v1/web-application-targets/{id}", + "/gvm/public/v1/web-application-targets/{id}", put_with( update_web_application_target, update_web_application_target_docs, ), ) .api_route( - "/api/v1/web-application-targets/{id}", + "/gvm/public/v1/web-application-targets/{id}", delete_with( delete_web_application_target, delete_web_application_target_docs, ), ) .api_route( - "/api/v1/web-application-targets/{id}/clone", + "/gvm/public/v1/web-application-targets/{id}/clone", post_with( clone_web_application_target, clone_web_application_target_docs, ), ) // Alerts - .api_route("/api/v1/alerts", get_with(list_alerts, list_alerts_docs)) - .api_route("/api/v1/alerts", post_with(create_alert, create_alert_docs)) - .api_route("/api/v1/alerts/{id}", get_with(get_alert, get_alert_docs)) .api_route( - "/api/v1/alerts/{id}", + "/gvm/public/v1/alerts", + get_with(list_alerts, list_alerts_docs), + ) + .api_route( + "/gvm/public/v1/alerts", + post_with(create_alert, create_alert_docs), + ) + .api_route( + "/gvm/public/v1/alerts/{id}", + get_with(get_alert, get_alert_docs), + ) + .api_route( + "/gvm/public/v1/alerts/{id}", put_with(update_alert, update_alert_docs), ) .api_route( - "/api/v1/alerts/{id}", + "/gvm/public/v1/alerts/{id}", delete_with(delete_alert, delete_alert_docs), ) // Schedules .api_route( - "/api/v1/schedules", + "/gvm/public/v1/schedules", get_with(list_schedules, list_schedules_docs), ) .api_route( - "/api/v1/schedules", + "/gvm/public/v1/schedules", post_with(create_schedule, create_schedule_docs), ) .api_route( - "/api/v1/schedules/{id}", + "/gvm/public/v1/schedules/{id}", get_with(get_schedule, get_schedule_docs), ) .api_route( - "/api/v1/schedules/{id}", + "/gvm/public/v1/schedules/{id}", put_with(update_schedule, update_schedule_docs), ) .api_route( - "/api/v1/schedules/{id}", + "/gvm/public/v1/schedules/{id}", delete_with(delete_schedule, delete_schedule_docs), ) // Credentials .api_route( - "/api/v1/active-directory/object-searches", + "/gvm/public/v1/active-directory/object-searches", post_with( crate::active_directory::search_active_directory_objects, crate::active_directory::search_active_directory_objects_docs, ), ) .api_route( - "/api/v1/credentials/{id}/actions/verify-active-directory", + "/gvm/public/v1/credentials/{id}/actions/verify-active-directory", post_with( verify_active_directory_saved, verify_active_directory_saved_docs, ), ) .api_route( - "/api/v1/active-directory/credential-verifications", + "/gvm/public/v1/active-directory/credential-verifications", post_with( verify_active_directory_inline, verify_active_directory_inline_docs, ), ) .api_route( - "/api/v1/credential-stores", + "/gvm/public/v1/credential-stores", get_with(list_credential_stores, list_credential_stores_docs), ) .api_route( - "/api/v1/credential-stores/{id}", + "/gvm/public/v1/credential-stores/{id}", get_with(get_credential_store, get_credential_store_docs), ) .api_route( - "/api/v1/credential-stores/{id}", + "/gvm/public/v1/credential-stores/{id}", put_with(update_credential_store, update_credential_store_docs), ) .api_route( - "/api/v1/credential-stores/{id}/actions/verify", + "/gvm/public/v1/credential-stores/{id}/actions/verify", post_with(verify_credential_store, verify_credential_store_docs), ) .api_route( - "/api/v1/credentials", + "/gvm/public/v1/credentials", get_with(list_credentials, list_credentials_docs), ) .api_route( - "/api/v1/credentials", + "/gvm/public/v1/credentials", post_with(create_credential, create_credential_docs), ) .api_route( - "/api/v1/credentials/{id}", + "/gvm/public/v1/credentials/{id}", get_with(get_credential, get_credential_docs), ) .api_route( - "/api/v1/credentials/{id}", + "/gvm/public/v1/credentials/{id}", put_with(update_credential, update_credential_docs), ) .api_route( - "/api/v1/credentials/{id}", + "/gvm/public/v1/credentials/{id}", delete_with(delete_credential, delete_credential_docs), ) // Port Lists .api_route( - "/api/v1/port-lists", + "/gvm/public/v1/port-lists", get_with(list_port_lists, list_port_lists_docs), ) .api_route( - "/api/v1/port-lists", + "/gvm/public/v1/port-lists", post_with(create_port_list, create_port_list_docs), ) .api_route( - "/api/v1/port-lists/{id}", + "/gvm/public/v1/port-lists/{id}", get_with(get_port_list, get_port_list_docs), ) .api_route( - "/api/v1/port-lists/{id}", + "/gvm/public/v1/port-lists/{id}", put_with(update_port_list, update_port_list_docs), ) .api_route( - "/api/v1/port-lists/{id}", + "/gvm/public/v1/port-lists/{id}", delete_with(delete_port_list, delete_port_list_docs), ) // Feeds - .api_route("/api/v1/feeds", get_with(list_feeds, list_feeds_docs)) + .api_route( + "/gvm/public/v1/feeds", + get_with(list_feeds, list_feeds_docs), + ) // Supporting resources - .api_route("/api/v1/hosts", get_with(list_hosts, list_hosts_docs)) - .api_route("/api/v1/hosts", post_with(create_host, create_host_docs)) - .api_route("/api/v1/hosts/{id}", get_with(get_host, get_host_docs)) .api_route( - "/api/v1/hosts/{id}", + "/gvm/public/v1/hosts", + get_with(list_hosts, list_hosts_docs), + ) + .api_route( + "/gvm/public/v1/hosts", + post_with(create_host, create_host_docs), + ) + .api_route( + "/gvm/public/v1/hosts/{id}", + get_with(get_host, get_host_docs), + ) + .api_route( + "/gvm/public/v1/hosts/{id}", put_with(update_host, update_host_docs), ) .api_route( - "/api/v1/hosts/{id}", + "/gvm/public/v1/hosts/{id}", delete_with(delete_host, delete_host_docs), ) .api_route( - "/api/v1/tls-certificates", + "/gvm/public/v1/tls-certificates", get_with(list_tls_certificates, list_tls_certificates_docs), ) .api_route( - "/api/v1/tls-certificates/{id}", + "/gvm/public/v1/tls-certificates/{id}", get_with(get_tls_certificate, get_tls_certificate_docs), ) .api_route( - "/api/v1/report-formats", + "/gvm/public/v1/report-formats", get_with(list_report_formats, list_report_formats_docs), ) .api_route( - "/api/v1/report-formats/{id}", + "/gvm/public/v1/report-formats/{id}", get_with(get_report_format, get_report_format_docs), ) - .api_route("/api/v1/filters", get_with(list_filters, list_filters_docs)) .api_route( - "/api/v1/filters", + "/gvm/public/v1/filters", + get_with(list_filters, list_filters_docs), + ) + .api_route( + "/gvm/public/v1/filters", post_with(create_filter, create_filter_docs), ) .api_route( - "/api/v1/filters/{id}", + "/gvm/public/v1/filters/{id}", get_with(get_filter, get_filter_docs), ) .api_route( - "/api/v1/filters/{id}", + "/gvm/public/v1/filters/{id}", put_with(update_filter, update_filter_docs), ) .api_route( - "/api/v1/filters/{id}", + "/gvm/public/v1/filters/{id}", delete_with(delete_filter, delete_filter_docs), ) .api_route( - "/api/v1/filters/{id}/clone", + "/gvm/public/v1/filters/{id}/clone", post_with(clone_filter, clone_filter_docs), ) - .api_route("/api/v1/tags", get_with(list_tags, list_tags_docs)) - .api_route("/api/v1/tags", post_with(create_tag, create_tag_docs)) - .api_route("/api/v1/tags/{id}", get_with(get_tag, get_tag_docs)) - .api_route("/api/v1/tags/{id}", put_with(update_tag, update_tag_docs)) + .api_route("/gvm/public/v1/tags", get_with(list_tags, list_tags_docs)) .api_route( - "/api/v1/tags/{id}", + "/gvm/public/v1/tags", + post_with(create_tag, create_tag_docs), + ) + .api_route("/gvm/public/v1/tags/{id}", get_with(get_tag, get_tag_docs)) + .api_route( + "/gvm/public/v1/tags/{id}", + put_with(update_tag, update_tag_docs), + ) + .api_route( + "/gvm/public/v1/tags/{id}", delete_with(delete_tag, delete_tag_docs), ) .api_route( - "/api/v1/tags/{id}/clone", + "/gvm/public/v1/tags/{id}/clone", post_with(clone_tag, clone_tag_docs), ) - .api_route("/api/v1/notes", get_with(list_notes, list_notes_docs)) - .api_route("/api/v1/notes", post_with(create_note, create_note_docs)) - .api_route("/api/v1/notes/{id}", get_with(get_note, get_note_docs)) .api_route( - "/api/v1/notes/{id}", + "/gvm/public/v1/notes", + get_with(list_notes, list_notes_docs), + ) + .api_route( + "/gvm/public/v1/notes", + post_with(create_note, create_note_docs), + ) + .api_route( + "/gvm/public/v1/notes/{id}", + get_with(get_note, get_note_docs), + ) + .api_route( + "/gvm/public/v1/notes/{id}", put_with(update_note, update_note_docs), ) .api_route( - "/api/v1/notes/{id}", + "/gvm/public/v1/notes/{id}", delete_with(delete_note, delete_note_docs), ) .api_route( - "/api/v1/overrides", + "/gvm/public/v1/overrides", get_with(list_overrides, list_overrides_docs), ) .api_route( - "/api/v1/overrides", + "/gvm/public/v1/overrides", post_with(create_override, create_override_docs), ) .api_route( - "/api/v1/overrides/{id}", + "/gvm/public/v1/overrides/{id}", get_with(get_override, get_override_docs), ) .api_route( - "/api/v1/overrides/{id}", + "/gvm/public/v1/overrides/{id}", put_with(update_override, update_override_docs), ) .api_route( - "/api/v1/overrides/{id}", + "/gvm/public/v1/overrides/{id}", delete_with(delete_override, delete_override_docs), ) - .api_route("/api/v1/nvts", get_with(list_nvts, list_nvts_docs)) - .api_route("/api/v1/nvts/{id}", get_with(get_nvt, get_nvt_docs)) + .api_route("/gvm/public/v1/nvts", get_with(list_nvts, list_nvts_docs)) + .api_route("/gvm/public/v1/nvts/{id}", get_with(get_nvt, get_nvt_docs)) .api_route( - "/api/v1/vulnerabilities", + "/gvm/public/v1/vulnerabilities", get_with(list_vulnerabilities, list_vulnerabilities_docs), ) - .api_route("/api/v1/cves", get_with(list_cves, list_cves_docs)) - .api_route("/api/v1/cves/{id}", get_with(get_cve, get_cve_docs)) - .api_route("/api/v1/cpes", get_with(list_cpes, list_cpes_docs)) - .api_route("/api/v1/cpes/{id}", get_with(get_cpe, get_cpe_docs)) + .api_route("/gvm/public/v1/cves", get_with(list_cves, list_cves_docs)) + .api_route("/gvm/public/v1/cves/{id}", get_with(get_cve, get_cve_docs)) + .api_route("/gvm/public/v1/cpes", get_with(list_cpes, list_cpes_docs)) + .api_route("/gvm/public/v1/cpes/{id}", get_with(get_cpe, get_cpe_docs)) .api_route( - "/api/v1/cert-bund-advisories", + "/gvm/public/v1/cert-bund-advisories", get_with(list_cert_bund_advisories, list_cert_bund_advisories_docs), ) .api_route( - "/api/v1/cert-bund-advisories/{id}", + "/gvm/public/v1/cert-bund-advisories/{id}", get_with(get_cert_bund_advisory, get_cert_bund_advisory_docs), ) .api_route( - "/api/v1/dfn-cert-advisories", + "/gvm/public/v1/dfn-cert-advisories", get_with(list_dfn_cert_advisories, list_dfn_cert_advisories_docs), ) .api_route( - "/api/v1/dfn-cert-advisories/{id}", + "/gvm/public/v1/dfn-cert-advisories/{id}", get_with(get_dfn_cert_advisory, get_dfn_cert_advisory_docs), ) .api_route( - "/api/v1/nvt-families", + "/gvm/public/v1/nvt-families", get_with(list_nvt_families, list_nvt_families_docs), ) // Identity and access control - .api_route("/api/v1/users", get_with(list_users, list_users_docs)) - .api_route("/api/v1/users", post_with(create_user, create_user_docs)) - .api_route("/api/v1/users/{id}", get_with(get_user, get_user_docs)) .api_route( - "/api/v1/users/{id}", + "/gvm/public/v1/users", + get_with(list_users, list_users_docs), + ) + .api_route( + "/gvm/public/v1/users", + post_with(create_user, create_user_docs), + ) + .api_route( + "/gvm/public/v1/users/{id}", + get_with(get_user, get_user_docs), + ) + .api_route( + "/gvm/public/v1/users/{id}", put_with(update_user, update_user_docs), ) .api_route( - "/api/v1/users/{id}", + "/gvm/public/v1/users/{id}", delete_with(delete_user, delete_user_docs), ) - .api_route("/api/v1/groups", get_with(list_groups, list_groups_docs)) - .api_route("/api/v1/groups", post_with(create_group, create_group_docs)) - .api_route("/api/v1/groups/{id}", get_with(get_group, get_group_docs)) .api_route( - "/api/v1/groups/{id}", + "/gvm/public/v1/groups", + get_with(list_groups, list_groups_docs), + ) + .api_route( + "/gvm/public/v1/groups", + post_with(create_group, create_group_docs), + ) + .api_route( + "/gvm/public/v1/groups/{id}", + get_with(get_group, get_group_docs), + ) + .api_route( + "/gvm/public/v1/groups/{id}", put_with(update_group, update_group_docs), ) .api_route( - "/api/v1/groups/{id}", + "/gvm/public/v1/groups/{id}", delete_with(delete_group, delete_group_docs), ) - .api_route("/api/v1/roles", get_with(list_roles, list_roles_docs)) - .api_route("/api/v1/roles", post_with(create_role, create_role_docs)) - .api_route("/api/v1/roles/{id}", get_with(get_role, get_role_docs)) .api_route( - "/api/v1/roles/{id}", + "/gvm/public/v1/roles", + get_with(list_roles, list_roles_docs), + ) + .api_route( + "/gvm/public/v1/roles", + post_with(create_role, create_role_docs), + ) + .api_route( + "/gvm/public/v1/roles/{id}", + get_with(get_role, get_role_docs), + ) + .api_route( + "/gvm/public/v1/roles/{id}", put_with(update_role, update_role_docs), ) .api_route( - "/api/v1/roles/{id}", + "/gvm/public/v1/roles/{id}", delete_with(delete_role, delete_role_docs), ) .api_route( - "/api/v1/permissions", + "/gvm/public/v1/permissions", get_with(list_permissions, list_permissions_docs), ) .api_route( - "/api/v1/permissions", + "/gvm/public/v1/permissions", post_with(create_permission, create_permission_docs), ) .api_route( - "/api/v1/permissions/{id}", + "/gvm/public/v1/permissions/{id}", get_with(get_permission, get_permission_docs), ) .api_route( - "/api/v1/permissions/{id}", + "/gvm/public/v1/permissions/{id}", put_with(update_permission, update_permission_docs), ) .api_route( - "/api/v1/permissions/{id}", + "/gvm/public/v1/permissions/{id}", delete_with(delete_permission, delete_permission_docs), ) .api_route( - "/api/v1/user-settings", + "/gvm/public/v1/user-settings", get_with(list_user_settings, list_user_settings_docs), ) .api_route( - "/api/v1/user-settings/{id}", + "/gvm/public/v1/user-settings/{id}", get_with(get_user_setting, get_user_setting_docs), ) .api_route( - "/api/v1/user-settings/{id}", + "/gvm/public/v1/user-settings/{id}", put_with(update_user_setting, update_user_setting_docs), ) // Tasks - .api_route("/api/v1/tasks", get_with(list_tasks, list_tasks_docs)) - .api_route("/api/v1/tasks", post_with(create_task, create_task_docs)) - .api_route("/api/v1/tasks/{id}", get_with(get_task, get_task_docs)) .api_route( - "/api/v1/tasks/{id}", + "/gvm/public/v1/tasks", + get_with(list_tasks, list_tasks_docs), + ) + .api_route( + "/gvm/public/v1/tasks", + post_with(create_task, create_task_docs), + ) + .api_route( + "/gvm/public/v1/tasks/{id}", + get_with(get_task, get_task_docs), + ) + .api_route( + "/gvm/public/v1/tasks/{id}", put_with(update_task, update_task_docs), ) .api_route( - "/api/v1/tasks/{id}", + "/gvm/public/v1/tasks/{id}", delete_with(delete_task, delete_task_docs), ) .api_route( - "/api/v1/tasks/{id}/clone", + "/gvm/public/v1/tasks/{id}/clone", post_with(clone_task, clone_task_docs), ) .api_route( - "/api/v1/tasks/{id}/start", + "/gvm/public/v1/tasks/{id}/start", post_with(start_task, start_task_docs), ) .api_route( - "/api/v1/tasks/{id}/stop", + "/gvm/public/v1/tasks/{id}/stop", post_with(stop_task, stop_task_docs), ) .api_route( - "/api/v1/tasks/{id}/resume", + "/gvm/public/v1/tasks/{id}/resume", post_with(resume_task, resume_task_docs), ) // Audits (compliance tasks; get/start/stop/resume reuse task handlers) - .api_route("/api/v1/audits", get_with(list_audits, list_audits_docs)) - .api_route("/api/v1/audits", post_with(create_audit, create_audit_docs)) - .api_route("/api/v1/audits/{id}", get_with(get_audit, get_audit_docs)) .api_route( - "/api/v1/audits/{id}", + "/gvm/public/v1/audits", + get_with(list_audits, list_audits_docs), + ) + .api_route( + "/gvm/public/v1/audits", + post_with(create_audit, create_audit_docs), + ) + .api_route( + "/gvm/public/v1/audits/{id}", + get_with(get_audit, get_audit_docs), + ) + .api_route( + "/gvm/public/v1/audits/{id}", put_with(update_audit, update_audit_docs), ) .api_route( - "/api/v1/audits/{id}", + "/gvm/public/v1/audits/{id}", delete_with(delete_audit, delete_audit_docs), ) .api_route( - "/api/v1/audits/{id}/start", + "/gvm/public/v1/audits/{id}/start", post_with(start_audit, start_audit_docs), ) .api_route( - "/api/v1/audits/{id}/stop", + "/gvm/public/v1/audits/{id}/stop", post_with(stop_audit, stop_audit_docs), ) .api_route( - "/api/v1/audits/{id}/resume", + "/gvm/public/v1/audits/{id}/resume", post_with(resume_audit, resume_audit_docs), ) // Reports - .api_route("/api/v1/reports", get_with(list_reports, list_reports_docs)) .api_route( - "/api/v1/reports", + "/gvm/public/v1/reports", + get_with(list_reports, list_reports_docs), + ) + .api_route( + "/gvm/public/v1/reports", post_with(import_report, import_report_docs), ) .api_route( - "/api/v1/reports/{id}", + "/gvm/public/v1/reports/{id}", get_with(get_report, get_report_docs), ) .api_route( - "/api/v1/reports/{id}/exports", + "/gvm/public/v1/reports/{id}/exports", post_with(create_report_export_job, create_report_export_job_docs), ) .api_route( - "/api/v1/reports/{id}", + "/gvm/public/v1/reports/{id}", delete_with(delete_report, delete_report_docs), ) .api_route( - "/api/v1/reports/{id}/results", + "/gvm/public/v1/reports/{id}/results", get_with(get_report_results, get_report_results_docs), ) .api_route( - "/api/v1/reports/{id}/vulnerabilities", + "/gvm/public/v1/reports/{id}/vulnerabilities", get_with(get_report_vulnerabilities, get_report_vulnerabilities_docs), ) .api_route( - "/api/v1/reports/{id}/tls-certificates", + "/gvm/public/v1/reports/{id}/tls-certificates", get_with( get_report_tls_certificates, get_report_tls_certificates_docs, ), ) .api_route( - "/api/v1/reports/{id}/errors", + "/gvm/public/v1/reports/{id}/errors", get_with(get_report_errors, get_report_errors_docs), ) .api_route( - "/api/v1/reports/{id}/closed-cves", + "/gvm/public/v1/reports/{id}/closed-cves", get_with(get_report_closed_cves, get_report_closed_cves_docs), ) .api_route( - "/api/v1/reports/{id}/hosts", + "/gvm/public/v1/reports/{id}/hosts", get_with(get_report_hosts, get_report_hosts_docs), ) .api_route( - "/api/v1/reports/{id}/ports", + "/gvm/public/v1/reports/{id}/ports", get_with(get_report_ports, get_report_ports_docs), ) .api_route( - "/api/v1/reports/{id}/applications", + "/gvm/public/v1/reports/{id}/applications", get_with(get_report_applications, get_report_applications_docs), ) .api_route( - "/api/v1/reports/{id}/operating-systems", + "/gvm/public/v1/reports/{id}/operating-systems", get_with( get_report_operating_systems, get_report_operating_systems_docs, ), ) .api_route( - "/api/v1/reports/{id}/cves", + "/gvm/public/v1/reports/{id}/cves", get_with(get_report_cves, get_report_cves_docs), ) // Jobs - .api_route("/api/v1/jobs/{id}", get_with(get_job, get_job_docs)) + .api_route("/gvm/public/v1/jobs/{id}", get_with(get_job, get_job_docs)) .api_route( - "/api/v1/jobs/{id}", + "/gvm/public/v1/jobs/{id}", delete_with(cancel_job, cancel_job_docs), ) .api_route( - "/api/v1/jobs/{id}/result", + "/gvm/public/v1/jobs/{id}/result", get_with(download_job_result, download_job_result_docs), ) // Results - .api_route("/api/v1/results", get_with(list_results, list_results_docs)) .api_route( - "/api/v1/results/{id}", + "/gvm/public/v1/results", + get_with(list_results, list_results_docs), + ) + .api_route( + "/gvm/public/v1/results/{id}", get_with(get_result, get_result_docs), ) // Scan Configs .api_route( - "/api/v1/scan-configs", + "/gvm/public/v1/scan-configs", get_with(list_scan_configs, list_scan_configs_docs), ) .api_route( - "/api/v1/scan-configs", + "/gvm/public/v1/scan-configs", post_with(create_scan_config, create_scan_config_docs), ) .api_route( - "/api/v1/scan-configs/{id}", + "/gvm/public/v1/scan-configs/{id}", get_with(get_scan_config, get_scan_config_docs), ) .api_route( - "/api/v1/scan-configs/{id}", + "/gvm/public/v1/scan-configs/{id}", put_with(update_scan_config, update_scan_config_docs), ) .api_route( - "/api/v1/scan-configs/{id}", + "/gvm/public/v1/scan-configs/{id}", delete_with(delete_scan_config, delete_scan_config_docs), ) .api_route( - "/api/v1/scan-configs/{id}/nvts", + "/gvm/public/v1/scan-configs/{id}/nvts", get_with(list_scan_config_nvts, list_scan_config_nvts_docs), ) .api_route( - "/api/v1/scan-configs/{id}/nvts/{oid}", + "/gvm/public/v1/scan-configs/{id}/nvts/{oid}", get_with(get_scan_config_nvt, get_scan_config_nvt_docs), ) .api_route( - "/api/v1/scan-configs/{id}/preferences", + "/gvm/public/v1/scan-configs/{id}/preferences", get_with( list_scan_config_preferences, list_scan_config_preferences_docs, ), ) .api_route( - "/api/v1/scan-configs/{id}/preferences/{name}", + "/gvm/public/v1/scan-configs/{id}/preferences/{name}", get_with(get_scan_config_preference, get_scan_config_preference_docs), ) .api_route( - "/api/v1/scan-configs/{id}/preferences/{name}", + "/gvm/public/v1/scan-configs/{id}/preferences/{name}", put_with(set_scan_config_preference, set_scan_config_preference_docs), ) .api_route( - "/api/v1/scan-configs/{id}/families/{family}/nvts", + "/gvm/public/v1/scan-configs/{id}/families/{family}/nvts", put_with( set_scan_config_nvt_selection, set_scan_config_nvt_selection_docs, ), ) .api_route( - "/api/v1/scan-configs/{id}/family-selection", + "/gvm/public/v1/scan-configs/{id}/family-selection", put_with( set_scan_config_family_selection, set_scan_config_family_selection_docs, @@ -954,48 +1065,48 @@ fn documented_router() -> ApiRouter { ) // Policies (compliance scan configs; get reuses the scan-config handler) .api_route( - "/api/v1/policies", + "/gvm/public/v1/policies", get_with(list_policies, list_policies_docs), ) .api_route( - "/api/v1/policies", + "/gvm/public/v1/policies", post_with(create_policy, create_policy_docs), ) .api_route( - "/api/v1/policies/{id}", + "/gvm/public/v1/policies/{id}", get_with(get_policy, get_policy_docs), ) .api_route( - "/api/v1/policies/{id}", + "/gvm/public/v1/policies/{id}", put_with(update_policy, update_policy_docs), ) .api_route( - "/api/v1/policies/{id}", + "/gvm/public/v1/policies/{id}", delete_with(delete_policy, delete_policy_docs), ) // Scanners .api_route( - "/api/v1/scanners", + "/gvm/public/v1/scanners", get_with(list_scanners, list_scanners_docs), ) .api_route( - "/api/v1/scanners/{id}", + "/gvm/public/v1/scanners/{id}", get_with(get_scanner, get_scanner_docs), ) .api_route( - "/api/v1/operating-systems", + "/gvm/public/v1/operating-systems", get_with(list_operating_systems, list_operating_systems_docs), ) .api_route( - "/api/v1/operating-systems/{id}", + "/gvm/public/v1/operating-systems/{id}", get_with(get_operating_system, get_operating_system_docs), ) .api_route( - "/api/v1/operating-systems/{id}", + "/gvm/public/v1/operating-systems/{id}", put_with(update_operating_system, modify_operating_system_docs), ) .api_route( - "/api/v1/operating-systems/{id}", + "/gvm/public/v1/operating-systems/{id}", delete_with(delete_operating_system, delete_operating_system_docs), ) } @@ -1074,7 +1185,7 @@ async fn shutdown_gate_middleware( } fn should_bypass_shutdown_gate(path: &str) -> bool { - matches!(path, "/health" | "/ready") + matches!(path, "/gvm/health" | "/gvm/ready") } #[derive(Clone, Default)] diff --git a/crates/gvm-gateway-rest/src/router_test.rs b/crates/gvm-gateway-rest/src/router_test.rs index d87b1678..31ce97fb 100644 --- a/crates/gvm-gateway-rest/src/router_test.rs +++ b/crates/gvm-gateway-rest/src/router_test.rs @@ -117,7 +117,7 @@ async fn draining_router_rejects_new_non_probe_requests() { let response = app .oneshot( Request::builder() - .uri("/api/v1/version") + .uri("/gvm/public/v1/version") .body(Body::empty()) .unwrap(), ) @@ -142,7 +142,7 @@ async fn draining_router_keeps_readiness_probe_available() { let response = app .oneshot( Request::builder() - .uri("/ready") + .uri("/gvm/ready") .body(Body::empty()) .unwrap(), ) @@ -161,7 +161,7 @@ async fn specialized_target_routes_require_authentication() { let response = app .oneshot( Request::builder() - .uri("/api/v1/oci-image-targets") + .uri("/gvm/public/v1/oci-image-targets") .body(Body::empty()) .unwrap(), ) @@ -183,7 +183,7 @@ async fn user_setting_routes_preserve_auth_validation_and_problem_contracts() { .clone() .oneshot( Request::builder() - .uri("/api/v1/user-settings") + .uri("/gvm/public/v1/user-settings") .body(Body::empty()) .unwrap(), ) @@ -200,7 +200,7 @@ async fn user_setting_routes_preserve_auth_validation_and_problem_contracts() { .oneshot( Request::builder() .method(Method::PUT) - .uri(format!("/api/v1/user-settings/{id}")) + .uri(format!("/gvm/public/v1/user-settings/{id}")) .header(axum::http::header::AUTHORIZATION, "Basic YWRtaW46c2VjcmV0") .header(CONTENT_TYPE, "application/json") .body(Body::from("{}")) @@ -224,7 +224,7 @@ async fn user_setting_routes_preserve_auth_validation_and_problem_contracts() { .oneshot( Request::builder() .method(Method::PUT) - .uri(format!("/api/v1/user-settings/{id}")) + .uri(format!("/gvm/public/v1/user-settings/{id}")) .header(axum::http::header::AUTHORIZATION, "Basic YWRtaW46c2VjcmV0") .header(CONTENT_TYPE, "application/json") .body(Body::from(r#"{"value":""}"#)) @@ -243,18 +243,30 @@ async fn generic_resource_routes_dispatch_to_typed_services() { let app = build_router(static_gateway_service()); let id = "123e4567-e89b-12d3-a456-426614174000"; for (method, uri, body) in [ - (Method::GET, "/api/v1/assets?type=host".to_string(), ""), - (Method::GET, format!("/api/v1/assets/{id}?type=host"), ""), + ( + Method::GET, + "/gvm/public/v1/assets?type=host".to_string(), + "", + ), + ( + Method::GET, + format!("/gvm/public/v1/assets/{id}?type=host"), + "", + ), ( Method::PUT, - format!("/api/v1/assets/{id}?type=host"), + format!("/gvm/public/v1/assets/{id}?type=host"), r#"{"comment":"updated"}"#, ), - (Method::DELETE, format!("/api/v1/assets/{id}"), ""), - (Method::GET, "/api/v1/configs".to_string(), ""), - (Method::GET, format!("/api/v1/configs/{id}"), ""), - (Method::DELETE, format!("/api/v1/configs/{id}"), ""), - (Method::POST, format!("/api/v1/configs/{id}/clone"), ""), + (Method::DELETE, format!("/gvm/public/v1/assets/{id}"), ""), + (Method::GET, "/gvm/public/v1/configs".to_string(), ""), + (Method::GET, format!("/gvm/public/v1/configs/{id}"), ""), + (Method::DELETE, format!("/gvm/public/v1/configs/{id}"), ""), + ( + Method::POST, + format!("/gvm/public/v1/configs/{id}/clone"), + "", + ), ] { let response = app .clone() @@ -280,11 +292,11 @@ async fn generic_resource_routes_dispatch_to_typed_services() { // Unsupported generic creation/config modification methods are omitted // from the contract and use the normal known-path 405 response. for (method, uri) in [ - (Method::POST, "/api/v1/assets"), - (Method::POST, "/api/v1/configs"), + (Method::POST, "/gvm/public/v1/assets"), + (Method::POST, "/gvm/public/v1/configs"), ( Method::PUT, - "/api/v1/configs/123e4567-e89b-12d3-a456-426614174000", + "/gvm/public/v1/configs/123e4567-e89b-12d3-a456-426614174000", ), ] { let response = app @@ -312,7 +324,7 @@ async fn browser_docs_use_repository_bundled_redoc() { .clone() .oneshot( Request::builder() - .uri("/api/v1/docs") + .uri("/gvm/public/v1/docs") .body(Body::empty()) .unwrap(), ) @@ -333,15 +345,15 @@ async fn browser_docs_use_repository_bundled_redoc() { .await .unwrap(); let html = String::from_utf8(body.to_vec()).unwrap(); - assert!(html.contains("spec-url=\"/api/v1/openapi.json\"")); - assert!(html.contains("src=\"/api/v1/docs/redoc.standalone.js\"")); + assert!(html.contains("spec-url=\"/gvm/public/v1/openapi.json\"")); + assert!(html.contains("src=\"/gvm/public/v1/docs/redoc.standalone.js\"")); assert!(html.contains("integrity=\"sha512-")); assert!(!html.contains("cdn.redoc.ly")); let response = app .oneshot( Request::builder() - .uri("/api/v1/docs/redoc.standalone.js") + .uri("/gvm/public/v1/docs/redoc.standalone.js") .body(Body::empty()) .unwrap(), ) @@ -376,8 +388,8 @@ async fn current_gvmd_report_and_operating_system_routes_dispatch_to_backend_bou let app = build_router(service); for path in [ - "/api/v1/reports/123e4567-e89b-12d3-a456-426614174000/hosts", - "/api/v1/operating-systems", + "/gvm/public/v1/reports/123e4567-e89b-12d3-a456-426614174000/hosts", + "/gvm/public/v1/operating-systems", ] { let response = app .clone() @@ -430,7 +442,7 @@ async fn request_trace_context_returns_trace_headers_without_echoing_baggage() { let response = app .oneshot( Request::builder() - .uri("/health") + .uri("/gvm/health") .header( "traceparent", "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01", @@ -457,7 +469,7 @@ async fn request_trace_context_returns_trace_headers_without_echoing_baggage() { let output = String::from_utf8(logs.lock().unwrap().clone()).unwrap(); assert!(output.contains("http.request")); assert!(output.contains("http_method=GET")); - assert!(output.contains("http_route=/health")); + assert!(output.contains("http_route=/gvm/health")); assert!(!output.contains("secret=user-token")); } @@ -473,7 +485,7 @@ async fn session_trace_labels_do_not_include_bearer_tokens() { .oneshot( Request::builder() .method("POST") - .uri("/api/v1/session") + .uri("/gvm/public/v1/session") .header(axum::http::header::AUTHORIZATION, "Basic YWRtaW46c2VjcmV0") .body(Body::empty()) .unwrap(), @@ -491,7 +503,7 @@ async fn session_trace_labels_do_not_include_bearer_tokens() { let response = app .oneshot( Request::builder() - .uri("/api/v1/session") + .uri("/gvm/public/v1/session") .header(axum::http::header::AUTHORIZATION, format!("Bearer {token}")) .body(Body::empty()) .unwrap(), @@ -502,7 +514,7 @@ async fn session_trace_labels_do_not_include_bearer_tokens() { assert_eq!(response.status(), StatusCode::OK); let output = String::from_utf8(logs.lock().unwrap().clone()).unwrap(); - assert!(output.contains("http_route=/api/v1/session")); + assert!(output.contains("http_route=/gvm/public/v1/session")); assert!(!output.contains(token)); } @@ -514,16 +526,16 @@ async fn unsupported_methods_on_known_paths_return_problem_responses() { // Covers the centralized 405 fallback so published paths cannot fall // through to the unknown-route fallback when a method is unsupported. for (method, uri) in [ - ("PATCH", "/api/v1/scan-configs"), + ("PATCH", "/gvm/public/v1/scan-configs"), ( "PATCH", - "/api/v1/scanners/123e4567-e89b-12d3-a456-426614174000", + "/gvm/public/v1/scanners/123e4567-e89b-12d3-a456-426614174000", ), - ("POST", "/api/v1/report-formats"), - ("POST", "/api/v1/user-settings"), + ("POST", "/gvm/public/v1/report-formats"), + ("POST", "/gvm/public/v1/user-settings"), ( "DELETE", - "/api/v1/user-settings/123e4567-e89b-12d3-a456-426614174000", + "/gvm/public/v1/user-settings/123e4567-e89b-12d3-a456-426614174000", ), ] { let response = app @@ -552,7 +564,7 @@ async fn unsupported_methods_on_known_paths_return_problem_responses() { let response = app .oneshot( Request::builder() - .uri("/api/v1/does-not-exist") + .uri("/gvm/public/v1/does-not-exist") .body(Body::empty()) .unwrap(), ) @@ -576,8 +588,8 @@ async fn removed_ticket_routes_use_the_unknown_route_problem_contract() { let app = build_router(static_gateway_service()); for uri in [ - "/api/v1/tickets", - "/api/v1/tickets/123e4567-e89b-12d3-a456-426614174000", + "/gvm/public/v1/tickets", + "/gvm/public/v1/tickets/123e4567-e89b-12d3-a456-426614174000", ] { let response = app .clone() @@ -610,3 +622,27 @@ async fn removed_ticket_routes_use_the_unknown_route_problem_contract() { assert_eq!(problem["instance"], serde_json::json!(uri)); } } + +#[tokio::test] +async fn service_prefix_exposes_probes_and_does_not_alias_legacy_routes() { + // Ingress can forward /gvm unchanged for public API and operational probes. + // Probes stay unauthenticated; legacy root paths are not aliases. + let app = build_router(static_gateway_service()); + for (path, expected) in [ + ("/gvm/health", StatusCode::OK), + ("/gvm/ready", StatusCode::OK), + ("/health", StatusCode::NOT_FOUND), + ("/ready", StatusCode::NOT_FOUND), + ("/gvm/public/v1/openapi.json", StatusCode::OK), + ("/api/v1/openapi.json", StatusCode::NOT_FOUND), + ("/api/v1/docs", StatusCode::NOT_FOUND), + ("/api/v1/version", StatusCode::NOT_FOUND), + ] { + let response = app + .clone() + .oneshot(Request::builder().uri(path).body(Body::empty()).unwrap()) + .await + .unwrap(); + assert_eq!(response.status(), expected, "{path}"); + } +} diff --git a/crates/gvm-gateway-rest/src/scan_configs.rs b/crates/gvm-gateway-rest/src/scan_configs.rs index 16c91736..99f8391f 100644 --- a/crates/gvm-gateway-rest/src/scan_configs.rs +++ b/crates/gvm-gateway-rest/src/scan_configs.rs @@ -839,7 +839,7 @@ pub async fn set_scan_config_preference( // OpenAPI transforms // ============================================================================ -/// OpenAPI transform for `GET /api/v1/scan-configs`. +/// OpenAPI transform for `GET /gvm/public/v1/scan-configs`. pub(crate) fn list_scan_configs_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getScanConfigs") @@ -855,7 +855,7 @@ pub(crate) fn list_scan_configs_docs(op: TransformOperation<'_>) -> TransformOpe problem_response::<401>(op, "Authentication required or session expired") } -/// OpenAPI transform for `POST /api/v1/scan-configs`. +/// OpenAPI transform for `POST /gvm/public/v1/scan-configs`. pub(crate) fn create_scan_config_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("createScanConfig") @@ -872,7 +872,7 @@ pub(crate) fn create_scan_config_docs(op: TransformOperation<'_>) -> TransformOp problem_response::<401>(op, "Authentication required or session expired") } -/// OpenAPI transform for `GET /api/v1/scan-configs/{id}`. +/// OpenAPI transform for `GET /gvm/public/v1/scan-configs/{id}`. pub(crate) fn get_scan_config_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getScanConfig") @@ -887,7 +887,7 @@ pub(crate) fn get_scan_config_docs(op: TransformOperation<'_>) -> TransformOpera problem_response::<404>(op, "Resource not found") } -/// OpenAPI transform for `PUT /api/v1/scan-configs/{id}`. +/// OpenAPI transform for `PUT /gvm/public/v1/scan-configs/{id}`. pub(crate) fn update_scan_config_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("modifyScanConfig") @@ -903,7 +903,7 @@ pub(crate) fn update_scan_config_docs(op: TransformOperation<'_>) -> TransformOp problem_response::<404>(op, "Resource not found") } -/// OpenAPI transform for `DELETE /api/v1/scan-configs/{id}`. +/// OpenAPI transform for `DELETE /gvm/public/v1/scan-configs/{id}`. pub(crate) fn delete_scan_config_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("deleteScanConfig") @@ -1140,7 +1140,7 @@ pub async fn delete_policy( .await } -/// OpenAPI transform for `GET /api/v1/policies`. +/// OpenAPI transform for `GET /gvm/public/v1/policies`. pub(crate) fn list_policies_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getPolicies") @@ -1156,7 +1156,7 @@ pub(crate) fn list_policies_docs(op: TransformOperation<'_>) -> TransformOperati problem_response::<401>(op, "Authentication required or session expired") } -/// OpenAPI transform for `POST /api/v1/policies`. +/// OpenAPI transform for `POST /gvm/public/v1/policies`. pub(crate) fn create_policy_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("createPolicy") @@ -1171,7 +1171,7 @@ pub(crate) fn create_policy_docs(op: TransformOperation<'_>) -> TransformOperati problem_response::<401>(op, "Authentication required or session expired") } -/// OpenAPI transform for `GET /api/v1/policies/{id}`. +/// OpenAPI transform for `GET /gvm/public/v1/policies/{id}`. pub(crate) fn get_policy_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getPolicy") @@ -1186,7 +1186,7 @@ pub(crate) fn get_policy_docs(op: TransformOperation<'_>) -> TransformOperation< problem_response::<404>(op, "Resource not found") } -/// OpenAPI transform for `PUT /api/v1/policies/{id}`. +/// OpenAPI transform for `PUT /gvm/public/v1/policies/{id}`. pub(crate) fn update_policy_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("modifyPolicy") @@ -1202,7 +1202,7 @@ pub(crate) fn update_policy_docs(op: TransformOperation<'_>) -> TransformOperati problem_response::<404>(op, "Resource not found") } -/// OpenAPI transform for `DELETE /api/v1/policies/{id}`. +/// OpenAPI transform for `DELETE /gvm/public/v1/policies/{id}`. pub(crate) fn delete_policy_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("deletePolicy") diff --git a/crates/gvm-gateway-rest/src/scanners.rs b/crates/gvm-gateway-rest/src/scanners.rs index 7b724fed..faaf148b 100644 --- a/crates/gvm-gateway-rest/src/scanners.rs +++ b/crates/gvm-gateway-rest/src/scanners.rs @@ -210,7 +210,7 @@ pub async fn get_scanner( // OpenAPI transforms // ============================================================================ -/// OpenAPI transform for `GET /api/v1/scanners`. +/// OpenAPI transform for `GET /gvm/public/v1/scanners`. pub(crate) fn list_scanners_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getScanners") @@ -224,7 +224,7 @@ pub(crate) fn list_scanners_docs(op: TransformOperation<'_>) -> TransformOperati problem_response::<401>(op, "Authentication required or session expired") } -/// OpenAPI transform for `GET /api/v1/scanners/{id}`. +/// OpenAPI transform for `GET /gvm/public/v1/scanners/{id}`. pub(crate) fn get_scanner_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getScanner") diff --git a/crates/gvm-gateway-rest/src/security.rs b/crates/gvm-gateway-rest/src/security.rs index 61f9301b..091d15e6 100644 --- a/crates/gvm-gateway-rest/src/security.rs +++ b/crates/gvm-gateway-rest/src/security.rs @@ -233,7 +233,7 @@ pub(crate) fn apply_security_headers( HeaderName::from_static("referrer-policy"), HeaderValue::from_static("no-referrer"), ); - if path == "/api/v1/docs" { + if path == "/gvm/public/v1/docs" { headers.insert( HeaderName::from_static("content-security-policy"), HeaderValue::from_static( @@ -241,7 +241,7 @@ pub(crate) fn apply_security_headers( ), ); } - if path.starts_with("/api/") { + if path.starts_with("/gvm/public/") { headers.insert(header::CACHE_CONTROL, HeaderValue::from_static("no-store")); } if native_tls_enabled { diff --git a/crates/gvm-gateway-rest/src/security_test.rs b/crates/gvm-gateway-rest/src/security_test.rs index 718e1fe9..59585a04 100644 --- a/crates/gvm-gateway-rest/src/security_test.rs +++ b/crates/gvm-gateway-rest/src/security_test.rs @@ -24,10 +24,10 @@ fn basic_request(method: &str, path: &str) -> Request { #[test] fn request_scoped_basic_auth_skips_public_routes() { for path in [ - "/health", - "/ready", - "/api/v1/version", - "/api/v1/openapi.json", + "/gvm/health", + "/gvm/ready", + "/gvm/public/v1/version", + "/gvm/public/v1/openapi.json", ] { assert!( !uses_request_scoped_basic_auth(&basic_request("GET", path)), @@ -40,24 +40,24 @@ fn request_scoped_basic_auth_skips_public_routes() { fn request_scoped_basic_auth_keeps_session_lifecycle_special_cases() { assert!(!uses_request_scoped_basic_auth(&basic_request( "POST", - "/api/v1/session" + "/gvm/public/v1/session" ))); assert!(!uses_request_scoped_basic_auth(&basic_request( "GET", - "/api/v1/session" + "/gvm/public/v1/session" ))); } #[test] fn request_scoped_basic_auth_applies_to_protected_routes_by_default() { for path in [ - "/api/v1/alerts", - "/api/v1/credentials/stores", - "/api/v1/feeds", - "/api/v1/report-formats", - "/api/v1/timezones", - "/api/v1/users", - "/api/v1/future-resource", + "/gvm/public/v1/alerts", + "/gvm/public/v1/credentials/stores", + "/gvm/public/v1/feeds", + "/gvm/public/v1/report-formats", + "/gvm/public/v1/timezones", + "/gvm/public/v1/users", + "/gvm/public/v1/future-resource", ] { assert!( uses_request_scoped_basic_auth(&basic_request("GET", path)), @@ -70,7 +70,7 @@ fn request_scoped_basic_auth_applies_to_protected_routes_by_default() { fn request_scoped_basic_auth_is_rejected_for_report_export_job_creation() { let request = basic_request( "POST", - "/api/v1/reports/550e8400-e29b-41d4-a716-446655440000/exports", + "/gvm/public/v1/reports/550e8400-e29b-41d4-a716-446655440000/exports", ); // This policy decision happens before temporary-session creation, keeping diff --git a/crates/gvm-gateway-rest/src/sessions.rs b/crates/gvm-gateway-rest/src/sessions.rs index 1d8f91a4..2761357a 100644 --- a/crates/gvm-gateway-rest/src/sessions.rs +++ b/crates/gvm-gateway-rest/src/sessions.rs @@ -27,7 +27,7 @@ use crate::{ // Response DTOs // ============================================================================ -/// JSON body returned by `POST /api/v1/session`. +/// JSON body returned by `POST /gvm/public/v1/session`. #[derive(Serialize, JsonSchema)] #[schemars(rename = "SessionCreated")] pub(crate) struct SessionCreatedResponse { @@ -57,7 +57,7 @@ impl From for SessionState { } } -/// JSON body returned by `GET /api/v1/session`. +/// JSON body returned by `GET /gvm/public/v1/session`. #[derive(Serialize, JsonSchema)] #[schemars(rename = "SessionInfo")] pub(crate) struct SessionInfoResponse { @@ -79,7 +79,7 @@ pub(crate) struct SessionInfoResponse { /// Create a new session via HTTP Basic authentication. /// -/// `POST /api/v1/session` +/// `POST /gvm/public/v1/session` pub async fn create_session( State(service): State, headers: HeaderMap, @@ -111,7 +111,7 @@ pub async fn create_session( /// Inspect a session. /// -/// `GET /api/v1/session` +/// `GET /gvm/public/v1/session` pub async fn get_session( State(service): State, headers: HeaderMap, @@ -141,7 +141,7 @@ pub async fn get_session( /// Close and destroy a session. /// -/// `DELETE /api/v1/session` +/// `DELETE /gvm/public/v1/session` pub async fn delete_session( State(service): State, headers: HeaderMap, @@ -198,7 +198,7 @@ fn extract_basic_credentials(headers: &HeaderMap) -> Result<(String, String), Ga // OpenAPI transforms // ============================================================================ -/// OpenAPI transform for `POST /api/v1/session`. +/// OpenAPI transform for `POST /gvm/public/v1/session`. pub(crate) fn create_session_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("createSession") @@ -217,7 +217,7 @@ pub(crate) fn create_session_docs(op: TransformOperation<'_>) -> TransformOperat problem_response::<502>(op, "Backend service unreachable or connection failed") } -/// OpenAPI transform for `GET /api/v1/session`. +/// OpenAPI transform for `GET /gvm/public/v1/session`. pub(crate) fn get_session_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getSession") @@ -231,7 +231,7 @@ pub(crate) fn get_session_docs(op: TransformOperation<'_>) -> TransformOperation problem_response::<404>(op, "Session not found") } -/// OpenAPI transform for `DELETE /api/v1/session`. +/// OpenAPI transform for `DELETE /gvm/public/v1/session`. pub(crate) fn delete_session_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("deleteSession") diff --git a/crates/gvm-gateway-rest/src/specialized_targets.rs b/crates/gvm-gateway-rest/src/specialized_targets.rs index b3190a53..3d9f1da8 100644 --- a/crates/gvm-gateway-rest/src/specialized_targets.rs +++ b/crates/gvm-gateway-rest/src/specialized_targets.rs @@ -367,7 +367,7 @@ pub async fn clone_oci_image_target( headers, id, uri, - "/api/v1/oci-image-targets", + "/gvm/public/v1/oci-image-targets", |s, token, id| async move { s.clone_oci_image_target(&token, &id).await }, ) .await @@ -462,7 +462,7 @@ pub async fn clone_web_application_target( headers, id, uri, - "/api/v1/web-application-targets", + "/gvm/public/v1/web-application-targets", |s, token, id| async move { s.clone_web_application_target(&token, &id).await }, ) .await diff --git a/crates/gvm-gateway-rest/src/supporting_resources/filters.rs b/crates/gvm-gateway-rest/src/supporting_resources/filters.rs index 8dfe5ab1..6c69a43d 100644 --- a/crates/gvm-gateway-rest/src/supporting_resources/filters.rs +++ b/crates/gvm-gateway-rest/src/supporting_resources/filters.rs @@ -242,7 +242,7 @@ pub async fn clone_filter( Err(error) => return gateway_error(error, instance), }; match service.clone_filter(&session, &id).await { - Ok(new_id) => created_resource("/api/v1/filters", &new_id), + Ok(new_id) => created_resource("/gvm/public/v1/filters", &new_id), Err(error) => gateway_error(error, instance), } } diff --git a/crates/gvm-gateway-rest/src/supporting_resources/tags.rs b/crates/gvm-gateway-rest/src/supporting_resources/tags.rs index 2df25252..64f03768 100644 --- a/crates/gvm-gateway-rest/src/supporting_resources/tags.rs +++ b/crates/gvm-gateway-rest/src/supporting_resources/tags.rs @@ -263,7 +263,7 @@ pub async fn clone_tag( Err(error) => return gateway_error(error, instance), }; match service.clone_tag(&session, &id).await { - Ok(new_id) => created_resource("/api/v1/tags", &new_id), + Ok(new_id) => created_resource("/gvm/public/v1/tags", &new_id), Err(error) => gateway_error(error, instance), } } diff --git a/crates/gvm-gateway-rest/src/system.rs b/crates/gvm-gateway-rest/src/system.rs index 34c9c265..2ab41837 100644 --- a/crates/gvm-gateway-rest/src/system.rs +++ b/crates/gvm-gateway-rest/src/system.rs @@ -32,7 +32,7 @@ pub(crate) enum HealthState { Ok, } -/// JSON body returned by `GET /health`. +/// JSON body returned by `GET /gvm/health`. #[derive(Clone, Debug, Serialize, JsonSchema)] #[schemars(rename = "HealthStatus")] pub(crate) struct HealthStatusResponse { @@ -48,7 +48,7 @@ pub(crate) enum ReadinessState { NotReady, } -/// JSON body returned by `GET /ready`. +/// JSON body returned by `GET /gvm/ready`. #[derive(Clone, Debug, Serialize, JsonSchema)] #[schemars(rename = "ReadinessStatus")] pub(crate) struct ReadinessStatusResponse { @@ -57,7 +57,7 @@ pub(crate) struct ReadinessStatusResponse { reason: Option, } -/// JSON body returned by `GET /api/v1/version`. +/// JSON body returned by `GET /gvm/public/v1/version`. #[derive(Clone, Debug, Serialize, JsonSchema)] #[schemars(rename = "VersionInfo")] pub(crate) struct VersionInfoResponse { @@ -87,7 +87,7 @@ impl From for TimezoneResponse { } } -/// JSON body returned by `GET /api/v1/timezones`. +/// JSON body returned by `GET /gvm/public/v1/timezones`. #[derive(Clone, Debug, Serialize, JsonSchema)] #[schemars(rename = "TimezoneList")] pub(crate) struct TimezoneListResponse { @@ -138,7 +138,7 @@ pub(crate) async fn ready( }), ) .into_response(), - Err(error) => RestError::from_gateway_error(error, "/ready").into_response(), + Err(error) => RestError::from_gateway_error(error, "/gvm/ready").into_response(), } } @@ -152,7 +152,9 @@ pub(crate) async fn version(State(service): State) -> Response { }), ) .into_response(), - Err(error) => RestError::from_gateway_error(error, "/api/v1/version").into_response(), + Err(error) => { + RestError::from_gateway_error(error, "/gvm/public/v1/version").into_response() + } } } @@ -183,7 +185,7 @@ pub(crate) async fn list_timezones( // OpenAPI transforms // ============================================================================ -/// OpenAPI transform for `GET /health`. +/// OpenAPI transform for `GET /gvm/health`. pub(crate) fn health_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getHealth") @@ -197,7 +199,7 @@ pub(crate) fn health_docs(op: TransformOperation<'_>) -> TransformOperation<'_> problem_response::<400>(op, "Invalid request") } -/// OpenAPI transform for `GET /ready`. +/// OpenAPI transform for `GET /gvm/ready`. pub(crate) fn ready_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getReadiness") @@ -216,7 +218,7 @@ pub(crate) fn ready_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { problem_response::<400>(op, "Invalid request") } -/// OpenAPI transform for `GET /api/v1/version`. +/// OpenAPI transform for `GET /gvm/public/v1/version`. pub(crate) fn version_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getVersion") @@ -234,7 +236,7 @@ pub(crate) fn version_docs(op: TransformOperation<'_>) -> TransformOperation<'_> problem_response::<502>(op, "Backend service unreachable or connection failed") } -/// OpenAPI transform for `GET /api/v1/timezones`. +/// OpenAPI transform for `GET /gvm/public/v1/timezones`. pub(crate) fn list_timezones_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getTimezones") diff --git a/crates/gvm-gateway-rest/src/targets.rs b/crates/gvm-gateway-rest/src/targets.rs index 9bc421e3..c0fe683b 100644 --- a/crates/gvm-gateway-rest/src/targets.rs +++ b/crates/gvm-gateway-rest/src/targets.rs @@ -382,7 +382,7 @@ pub async fn clone_target( headers, id, uri, - "/api/v1/targets", + "/gvm/public/v1/targets", |service, session, id| async move { service.clone_target(&session, &id).await }, ) .await @@ -480,7 +480,7 @@ fn validate_optional_uuid(field: &str, value: Option<&str>) -> Result<(), Gatewa // OpenAPI transforms // ============================================================================ -/// OpenAPI transform for `GET /api/v1/targets`. +/// OpenAPI transform for `GET /gvm/public/v1/targets`. pub(crate) fn list_targets_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getTargets") @@ -495,7 +495,7 @@ pub(crate) fn list_targets_docs(op: TransformOperation<'_>) -> TransformOperatio problem_response::<401>(op, "Authentication required or session expired") } -/// OpenAPI transform for `POST /api/v1/targets`. +/// OpenAPI transform for `POST /gvm/public/v1/targets`. pub(crate) fn create_target_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("createTarget") @@ -510,7 +510,7 @@ pub(crate) fn create_target_docs(op: TransformOperation<'_>) -> TransformOperati problem_response::<401>(op, "Authentication required or session expired") } -/// OpenAPI transform for `POST /api/v1/targets/{id}/clone`. +/// OpenAPI transform for `POST /gvm/public/v1/targets/{id}/clone`. pub(crate) fn clone_target_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("cloneTarget") @@ -526,7 +526,7 @@ pub(crate) fn clone_target_docs(op: TransformOperation<'_>) -> TransformOperatio problem_response::<404>(op, "Resource not found") } -/// OpenAPI transform for `GET /api/v1/targets/{id}`. +/// OpenAPI transform for `GET /gvm/public/v1/targets/{id}`. pub(crate) fn get_target_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getTarget") @@ -542,7 +542,7 @@ pub(crate) fn get_target_docs(op: TransformOperation<'_>) -> TransformOperation< problem_response::<404>(op, "Resource not found") } -/// OpenAPI transform for `PUT /api/v1/targets/{id}`. +/// OpenAPI transform for `PUT /gvm/public/v1/targets/{id}`. pub(crate) fn update_target_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("modifyTarget") @@ -558,7 +558,7 @@ pub(crate) fn update_target_docs(op: TransformOperation<'_>) -> TransformOperati problem_response::<404>(op, "Resource not found") } -/// OpenAPI transform for `DELETE /api/v1/targets/{id}`. +/// OpenAPI transform for `DELETE /gvm/public/v1/targets/{id}`. pub(crate) fn delete_target_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("deleteTarget") diff --git a/crates/gvm-gateway-rest/src/tasks.rs b/crates/gvm-gateway-rest/src/tasks.rs index 408c9dfe..3a47a1a8 100644 --- a/crates/gvm-gateway-rest/src/tasks.rs +++ b/crates/gvm-gateway-rest/src/tasks.rs @@ -690,7 +690,7 @@ pub async fn clone_task( headers, id, uri, - "/api/v1/tasks", + "/gvm/public/v1/tasks", |service, session, id| async move { service.clone_task(&session, &id).await }, ) .await @@ -834,7 +834,7 @@ fn validate_optional_uuid(field: &str, value: Option<&str>) -> Result<(), Gatewa // OpenAPI transforms // ============================================================================ -/// OpenAPI transform for `GET /api/v1/tasks`. +/// OpenAPI transform for `GET /gvm/public/v1/tasks`. pub(crate) fn list_tasks_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getTasks") @@ -848,7 +848,7 @@ pub(crate) fn list_tasks_docs(op: TransformOperation<'_>) -> TransformOperation< problem_response::<401>(op, "Authentication required or session expired") } -/// OpenAPI transform for `POST /api/v1/tasks`. +/// OpenAPI transform for `POST /gvm/public/v1/tasks`. pub(crate) fn create_task_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("createTask") @@ -863,7 +863,7 @@ pub(crate) fn create_task_docs(op: TransformOperation<'_>) -> TransformOperation problem_response::<401>(op, "Authentication required or session expired") } -/// OpenAPI transform for `POST /api/v1/tasks/{id}/clone`. +/// OpenAPI transform for `POST /gvm/public/v1/tasks/{id}/clone`. pub(crate) fn clone_task_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("cloneTask") @@ -879,7 +879,7 @@ pub(crate) fn clone_task_docs(op: TransformOperation<'_>) -> TransformOperation< problem_response::<404>(op, "Resource not found") } -/// OpenAPI transform for `GET /api/v1/tasks/{id}`. +/// OpenAPI transform for `GET /gvm/public/v1/tasks/{id}`. pub(crate) fn get_task_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getTask") @@ -894,7 +894,7 @@ pub(crate) fn get_task_docs(op: TransformOperation<'_>) -> TransformOperation<'_ problem_response::<404>(op, "Resource not found") } -/// OpenAPI transform for `PUT /api/v1/tasks/{id}`. +/// OpenAPI transform for `PUT /gvm/public/v1/tasks/{id}`. pub(crate) fn update_task_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("modifyTask") @@ -910,7 +910,7 @@ pub(crate) fn update_task_docs(op: TransformOperation<'_>) -> TransformOperation problem_response::<404>(op, "Resource not found") } -/// OpenAPI transform for `DELETE /api/v1/tasks/{id}`. +/// OpenAPI transform for `DELETE /gvm/public/v1/tasks/{id}`. pub(crate) fn delete_task_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("deleteTask") @@ -925,7 +925,7 @@ pub(crate) fn delete_task_docs(op: TransformOperation<'_>) -> TransformOperation problem_response::<404>(op, "Resource not found") } -/// OpenAPI transform for `POST /api/v1/tasks/{id}/start`. +/// OpenAPI transform for `POST /gvm/public/v1/tasks/{id}/start`. pub(crate) fn start_task_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("startTask") @@ -942,7 +942,7 @@ pub(crate) fn start_task_docs(op: TransformOperation<'_>) -> TransformOperation< problem_response::<504>(op, "Backend service did not respond in time") } -/// OpenAPI transform for `POST /api/v1/tasks/{id}/stop`. +/// OpenAPI transform for `POST /gvm/public/v1/tasks/{id}/stop`. pub(crate) fn stop_task_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("stopTask") @@ -958,7 +958,7 @@ pub(crate) fn stop_task_docs(op: TransformOperation<'_>) -> TransformOperation<' problem_response::<409>(op, "Resource state conflict") } -/// OpenAPI transform for `POST /api/v1/tasks/{id}/resume`. +/// OpenAPI transform for `POST /gvm/public/v1/tasks/{id}/resume`. pub(crate) fn resume_task_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("resumeTask") @@ -1148,7 +1148,7 @@ pub async fn resume_audit( } } -/// OpenAPI transform for `GET /api/v1/audits`. +/// OpenAPI transform for `GET /gvm/public/v1/audits`. pub(crate) fn list_audits_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getAudits") @@ -1162,7 +1162,7 @@ pub(crate) fn list_audits_docs(op: TransformOperation<'_>) -> TransformOperation problem_response::<401>(op, "Authentication required or session expired") } -/// OpenAPI transform for `POST /api/v1/audits`. +/// OpenAPI transform for `POST /gvm/public/v1/audits`. pub(crate) fn create_audit_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("createAudit") @@ -1177,7 +1177,7 @@ pub(crate) fn create_audit_docs(op: TransformOperation<'_>) -> TransformOperatio problem_response::<401>(op, "Authentication required or session expired") } -/// OpenAPI transform for `GET /api/v1/audits/{id}`. +/// OpenAPI transform for `GET /gvm/public/v1/audits/{id}`. pub(crate) fn get_audit_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("getAudit") @@ -1192,7 +1192,7 @@ pub(crate) fn get_audit_docs(op: TransformOperation<'_>) -> TransformOperation<' problem_response::<404>(op, "Resource not found") } -/// OpenAPI transform for `PUT /api/v1/audits/{id}`. +/// OpenAPI transform for `PUT /gvm/public/v1/audits/{id}`. pub(crate) fn update_audit_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("modifyAudit") @@ -1208,7 +1208,7 @@ pub(crate) fn update_audit_docs(op: TransformOperation<'_>) -> TransformOperatio problem_response::<404>(op, "Resource not found") } -/// OpenAPI transform for `DELETE /api/v1/audits/{id}`. +/// OpenAPI transform for `DELETE /gvm/public/v1/audits/{id}`. pub(crate) fn delete_audit_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("deleteAudit") @@ -1223,7 +1223,7 @@ pub(crate) fn delete_audit_docs(op: TransformOperation<'_>) -> TransformOperatio problem_response::<404>(op, "Resource not found") } -/// OpenAPI transform for `POST /api/v1/audits/{id}/start`. +/// OpenAPI transform for `POST /gvm/public/v1/audits/{id}/start`. pub(crate) fn start_audit_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("startAudit") @@ -1242,7 +1242,7 @@ pub(crate) fn start_audit_docs(op: TransformOperation<'_>) -> TransformOperation problem_response::<504>(op, "Backend service did not respond in time") } -/// OpenAPI transform for `POST /api/v1/audits/{id}/stop`. +/// OpenAPI transform for `POST /gvm/public/v1/audits/{id}/stop`. pub(crate) fn stop_audit_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("stopAudit") @@ -1258,7 +1258,7 @@ pub(crate) fn stop_audit_docs(op: TransformOperation<'_>) -> TransformOperation< problem_response::<409>(op, "Resource state conflict") } -/// OpenAPI transform for `POST /api/v1/audits/{id}/resume`. +/// OpenAPI transform for `POST /gvm/public/v1/audits/{id}/resume`. pub(crate) fn resume_audit_docs(op: TransformOperation<'_>) -> TransformOperation<'_> { let op = op .id("resumeAudit") diff --git a/crates/gvm-gateway/tests/active_directory_credentials.rs b/crates/gvm-gateway/tests/active_directory_credentials.rs index 216f4f1d..b9e20a4c 100644 --- a/crates/gvm-gateway/tests/active_directory_credentials.rs +++ b/crates/gvm-gateway/tests/active_directory_credentials.rs @@ -145,12 +145,12 @@ async fn ad_saved_and_inline_verification_are_status_only_and_do_not_expose_secr let (addr, token, handle) = spawn_credential_server(Arc::new(AdFixturePort(calls.clone(), None))).await; let client = Client::new(); - let saved = client.post(format!("http://{addr}/api/v1/credentials/123e4567-e89b-12d3-a456-426614174000/actions/verify-active-directory")).bearer_auth(&token).send().await.unwrap(); + let saved = client.post(format!("http://{addr}/gvm/public/v1/credentials/123e4567-e89b-12d3-a456-426614174000/actions/verify-active-directory")).bearer_auth(&token).send().await.unwrap(); assert_eq!(saved.status(), StatusCode::NO_CONTENT); assert_eq!(saved.headers()["cache-control"], "no-store"); assert!(!saved.headers().contains_key("location")); assert!(saved.bytes().await.unwrap().is_empty()); - let inline = client.post(format!("http://{addr}/api/v1/active-directory/credential-verifications")).bearer_auth(&token).json(&serde_json::json!({"activeDirectory":{"host":"fixture.invalid","bindDn":"CN=bind<&>","baseDn":"DC=fixture","bindPassword":"http-unique-secret","tlsMode":"starttls"}})).send().await.unwrap(); + let inline = client.post(format!("http://{addr}/gvm/public/v1/active-directory/credential-verifications")).bearer_auth(&token).json(&serde_json::json!({"activeDirectory":{"host":"fixture.invalid","bindDn":"CN=bind<&>","baseDn":"DC=fixture","bindPassword":"http-unique-secret","tlsMode":"starttls"}})).send().await.unwrap(); assert_eq!(inline.status(), StatusCode::NO_CONTENT); assert_eq!(inline.headers()["cache-control"], "no-store"); assert!(inline.bytes().await.unwrap().is_empty()); @@ -185,7 +185,7 @@ async fn ad_invalid_combinations_fail_before_dispatch_without_payload_echo() { ), ] { let response = Client::new() - .post(format!("http://{addr}/api/v1{path}")) + .post(format!("http://{addr}/gvm/public/v1{path}")) .bearer_auth(&token) .json(&body) .send() @@ -212,7 +212,7 @@ async fn ad_verification_generated_and_curated_errors_cover_runtime_categories() ))) .await; let generated: serde_json::Value = Client::new() - .get(format!("http://{addr}/api/v1/openapi.json")) + .get(format!("http://{addr}/gvm/public/v1/openapi.json")) .send() .await .unwrap() @@ -263,7 +263,7 @@ async fn ad_saved_and_inline_errors_preserve_status_without_sensitive_payloads() "/active-directory/credential-verifications", ] { let request = Client::new() - .post(format!("http://{addr}/api/v1{path}")) + .post(format!("http://{addr}/gvm/public/v1{path}")) .bearer_auth(&token); let request = if path.starts_with("/active-directory/") { request.json(&serde_json::json!({"activeDirectory":{"host":"private-host.invalid","bindDn":"CN=private-bind","baseDn":"DC=private-base","bindPassword":"http-unique-secret","tlsMode":"starttls"}})) @@ -291,7 +291,7 @@ async fn ad_saved_and_inline_errors_preserve_status_without_sensitive_payloads() let problem: serde_json::Value = serde_json::from_str(&text).unwrap(); assert_eq!(problem["status"], status); assert_eq!(problem["code"], code); - assert_eq!(problem["instance"], format!("/api/v1{path}")); + assert_eq!(problem["instance"], format!("/gvm/public/v1{path}")); } assert_eq!(calls.lock().unwrap().len(), 2); handle.abort(); diff --git a/crates/gvm-gateway/tests/agents.rs b/crates/gvm-gateway/tests/agents.rs index a48e5d94..950bec59 100644 --- a/crates/gvm-gateway/tests/agents.rs +++ b/crates/gvm-gateway/tests/agents.rs @@ -58,7 +58,7 @@ async fn created_id(response: reqwest::Response, collection: &str) -> String { .as_str() .unwrap() .to_string(); - assert_eq!(location, format!("/api/v1/{collection}/{id}")); + assert_eq!(location, format!("/gvm/public/v1/{collection}/{id}")); id } @@ -70,7 +70,7 @@ async fn agent_rest_routes_cover_typed_actions_and_downloads() { let list = harness .client - .get(harness.url("/api/v1/agents?filter=name%3DManaged%20Agent&page=1&perPage=10")) + .get(harness.url("/gvm/public/v1/agents?filter=name%3DManaged%20Agent&page=1&perPage=10")) .bearer_auth(&harness.token) .send() .await @@ -81,7 +81,7 @@ async fn agent_rest_routes_cover_typed_actions_and_downloads() { let saved = harness .client - .get(harness.url(&format!("/api/v1/agents?filterId={SAVED_FILTER_ID}"))) + .get(harness.url(&format!("/gvm/public/v1/agents?filterId={SAVED_FILTER_ID}"))) .bearer_auth(&harness.token) .send() .await @@ -91,7 +91,7 @@ async fn agent_rest_routes_cover_typed_actions_and_downloads() { let get = harness .client - .get(harness.url(&format!("/api/v1/agents/{AGENT_ID}"))) + .get(harness.url(&format!("/gvm/public/v1/agents/{AGENT_ID}"))) .bearer_auth(&harness.token) .send() .await @@ -101,7 +101,7 @@ async fn agent_rest_routes_cover_typed_actions_and_downloads() { let update = harness .client - .put(harness.url(&format!("/api/v1/agents/{AGENT_ID}"))) + .put(harness.url(&format!("/gvm/public/v1/agents/{AGENT_ID}"))) .bearer_auth(&harness.token) .json(&json!({"authorized":false,"updateToLatest":false,"comment":"updated"})) .send() @@ -112,7 +112,7 @@ async fn agent_rest_routes_cover_typed_actions_and_downloads() { let sync = harness .client - .post(harness.url("/api/v1/agents/sync")) + .post(harness.url("/gvm/public/v1/agents/sync")) .bearer_auth(&harness.token) .send() .await @@ -121,7 +121,9 @@ async fn agent_rest_routes_cover_typed_actions_and_downloads() { let bundle = harness .client - .get(harness.url(&format!("/api/v1/agents/{AGENT_ID}/support-bundle?days=7"))) + .get(harness.url(&format!( + "/gvm/public/v1/agents/{AGENT_ID}/support-bundle?days=7" + ))) .bearer_auth(&harness.token) .send() .await @@ -142,7 +144,9 @@ async fn agent_rest_routes_cover_typed_actions_and_downloads() { let control = harness .client - .put(harness.url(&format!("/api/v1/agent-control-scan-configs/{SCANNER_ID}"))) + .put(harness.url(&format!( + "/gvm/public/v1/agent-control-scan-configs/{SCANNER_ID}" + ))) .bearer_auth(&harness.token) .json(&json!({"updateToLatest":true})) .send() @@ -153,7 +157,7 @@ async fn agent_rest_routes_cover_typed_actions_and_downloads() { let installer = harness .client .get(harness.url(&format!( - "/api/v1/scanners/{SCANNER_ID}/agent-installer-instruction?originUrl=https%3A%2F%2Fmanager.example.invalid&language=de" + "/gvm/public/v1/scanners/{SCANNER_ID}/agent-installer-instruction?originUrl=https%3A%2F%2Fmanager.example.invalid&language=de" ))) .bearer_auth(&harness.token) .send() @@ -169,7 +173,7 @@ async fn agent_rest_routes_cover_typed_actions_and_downloads() { let delete = harness .client - .delete(harness.url(&format!("/api/v1/agents/{AGENT_ID}"))) + .delete(harness.url(&format!("/gvm/public/v1/agents/{AGENT_ID}"))) .bearer_auth(&harness.token) .send() .await @@ -223,7 +227,7 @@ async fn agent_group_rest_lifecycle_filter_trash_and_ultimate_delete() { let create = harness .client - .post(harness.url("/api/v1/agent-groups")) + .post(harness.url("/gvm/public/v1/agent-groups")) .bearer_auth(&harness.token) .json(&json!({ "name": "Blue Team", @@ -239,7 +243,7 @@ async fn agent_group_rest_lifecycle_filter_trash_and_ultimate_delete() { let get = harness .client - .get(harness.url(&format!("/api/v1/agent-groups/{id}"))) + .get(harness.url(&format!("/gvm/public/v1/agent-groups/{id}"))) .bearer_auth(&harness.token) .send() .await @@ -251,7 +255,7 @@ async fn agent_group_rest_lifecycle_filter_trash_and_ultimate_delete() { let update = harness .client - .put(harness.url(&format!("/api/v1/agent-groups/{id}"))) + .put(harness.url(&format!("/gvm/public/v1/agent-groups/{id}"))) .bearer_auth(&harness.token) .json(&json!({ "name": "Updated", @@ -270,29 +274,32 @@ async fn agent_group_rest_lifecycle_filter_trash_and_ultimate_delete() { let clone = harness .client - .post(harness.url(&format!("/api/v1/agent-groups/{id}/clone"))) + .post(harness.url(&format!("/gvm/public/v1/agent-groups/{id}/clone"))) .bearer_auth(&harness.token) .send() .await .unwrap(); let clone_id = created_id(clone, "agent-groups").await; - let list = harness - .client - .get( - harness.url("/api/v1/agent-groups?filter=name%3DUpdated&page=1&perPage=10&trash=false"), - ) - .bearer_auth(&harness.token) - .send() - .await - .unwrap(); + let list = + harness + .client + .get(harness.url( + "/gvm/public/v1/agent-groups?filter=name%3DUpdated&page=1&perPage=10&trash=false", + )) + .bearer_auth(&harness.token) + .send() + .await + .unwrap(); assert_eq!(list.status(), StatusCode::OK); let list = list.json::().await.unwrap(); assert_eq!(list["pagination"]["perPage"], 10); let saved = harness .client - .get(harness.url(&format!("/api/v1/agent-groups?filterId={SAVED_FILTER_ID}"))) + .get(harness.url(&format!( + "/gvm/public/v1/agent-groups?filterId={SAVED_FILTER_ID}" + ))) .bearer_auth(&harness.token) .send() .await @@ -302,7 +309,7 @@ async fn agent_group_rest_lifecycle_filter_trash_and_ultimate_delete() { let trash = harness .client - .delete(harness.url(&format!("/api/v1/agent-groups/{clone_id}"))) + .delete(harness.url(&format!("/gvm/public/v1/agent-groups/{clone_id}"))) .bearer_auth(&harness.token) .send() .await @@ -311,7 +318,7 @@ async fn agent_group_rest_lifecycle_filter_trash_and_ultimate_delete() { let trash_list = harness .client - .get(harness.url("/api/v1/agent-groups?trash=true")) + .get(harness.url("/gvm/public/v1/agent-groups?trash=true")) .bearer_auth(&harness.token) .send() .await @@ -325,7 +332,7 @@ async fn agent_group_rest_lifecycle_filter_trash_and_ultimate_delete() { let delete = harness .client - .delete(harness.url(&format!("/api/v1/agent-groups/{id}?ultimate=true"))) + .delete(harness.url(&format!("/gvm/public/v1/agent-groups/{id}?ultimate=true"))) .bearer_auth(&harness.token) .send() .await @@ -355,7 +362,7 @@ async fn agent_group_update_preserves_replaces_and_rejects_empty_agent_selection let harness = specialized_target_harness(|_| {}).await; let create = harness .client - .post(harness.url("/api/v1/agent-groups")) + .post(harness.url("/gvm/public/v1/agent-groups")) .bearer_auth(&harness.token) .json(&json!({ "name": "Agent selection semantics", @@ -370,7 +377,7 @@ async fn agent_group_update_preserves_replaces_and_rejects_empty_agent_selection harness.server.clear_history(); let omitted = harness .client - .put(harness.url(&format!("/api/v1/agent-groups/{id}"))) + .put(harness.url(&format!("/gvm/public/v1/agent-groups/{id}"))) .bearer_auth(&harness.token) .json(&json!({ "name": "Renamed without replacing agents", @@ -394,7 +401,7 @@ async fn agent_group_update_preserves_replaces_and_rejects_empty_agent_selection harness.server.clear_history(); let replaced = harness .client - .put(harness.url(&format!("/api/v1/agent-groups/{id}"))) + .put(harness.url(&format!("/gvm/public/v1/agent-groups/{id}"))) .bearer_auth(&harness.token) .json(&json!({ "schedulerCronTime": "0 */45 * * *", @@ -419,7 +426,7 @@ async fn agent_group_update_preserves_replaces_and_rejects_empty_agent_selection harness.server.clear_history(); let clear = harness .client - .put(harness.url(&format!("/api/v1/agent-groups/{id}"))) + .put(harness.url(&format!("/gvm/public/v1/agent-groups/{id}"))) .bearer_auth(&harness.token) .json(&json!({ "schedulerCronTime": "0 0 * * *", @@ -446,7 +453,7 @@ async fn agent_routes_return_not_implemented_on_gmp_22_7() { let response = harness .client - .get(harness.url("/api/v1/agents")) + .get(harness.url("/gvm/public/v1/agents")) .bearer_auth(&harness.token) .send() .await @@ -460,7 +467,7 @@ async fn agent_routes_return_not_implemented_on_gmp_22_7() { async fn inventory_token_route_is_authenticated_confidential_and_has_no_body() { // Exercise the actual service/adapter route, not a local token generator. let harness = specialized_target_harness(seed_agent_resource).await; - let url = harness.url("/api/v1/agents/inventory-token"); + let url = harness.url("/gvm/public/v1/agents/inventory-token"); let response = harness .client .post(&url) @@ -512,22 +519,22 @@ async fn invalid_agent_and_group_delays_return_400_without_backend_dispatch() { for (method, path, body) in [ ( reqwest::Method::PUT, - format!("/api/v1/agents/{AGENT_ID}"), + format!("/gvm/public/v1/agents/{AGENT_ID}"), json!({"config":schedule}), ), ( reqwest::Method::PUT, - format!("/api/v1/agent-control-scan-configs/{SCANNER_ID}"), + format!("/gvm/public/v1/agent-control-scan-configs/{SCANNER_ID}"), json!({"agentDefaults":schedule}), ), ( reqwest::Method::POST, - "/api/v1/agent-groups".to_string(), + "/gvm/public/v1/agent-groups".to_string(), json!({"name":"group","schedulerCronTime":"* * * * *","maxDelaySeconds":delay}), ), ( reqwest::Method::PUT, - format!("/api/v1/agent-groups/{AGENT_ID}"), + format!("/gvm/public/v1/agent-groups/{AGENT_ID}"), json!({"schedulerCronTime":"* * * * *","maxDelaySeconds":delay}), ), ] { @@ -582,7 +589,7 @@ async fn inventory_token_malformed_success_is_sanitized_502_and_never_cacheable( let harness = common::specialized_target_harness_from_server(server).await; let response = harness .client - .post(harness.url("/api/v1/agents/inventory-token")) + .post(harness.url("/gvm/public/v1/agents/inventory-token")) .bearer_auth(&harness.token) .send() .await diff --git a/crates/gvm-gateway/tests/common/mod.rs b/crates/gvm-gateway/tests/common/mod.rs index 2483101a..0c7c888b 100644 --- a/crates/gvm-gateway/tests/common/mod.rs +++ b/crates/gvm-gateway/tests/common/mod.rs @@ -307,7 +307,7 @@ impl TargetHarness { pub async fn get_targets(&self) -> Response { self.client - .get(self.url("/api/v1/targets")) + .get(self.url("/gvm/public/v1/targets")) .bearer_auth(&self.token) .send() .await @@ -316,7 +316,7 @@ impl TargetHarness { pub async fn get_targets_with_query(&self, query: &str) -> Response { self.client - .get(self.url(&format!("/api/v1/targets?{query}"))) + .get(self.url(&format!("/gvm/public/v1/targets?{query}"))) .bearer_auth(&self.token) .send() .await @@ -325,7 +325,7 @@ impl TargetHarness { pub async fn get_targets_with_basic(&self, user: &str, password: &str) -> Response { self.client - .get(self.url("/api/v1/targets")) + .get(self.url("/gvm/public/v1/targets")) .basic_auth(user, Some(password)) .send() .await @@ -334,7 +334,7 @@ impl TargetHarness { pub async fn create_target(&self, payload: Value) -> Response { self.client - .post(self.url("/api/v1/targets")) + .post(self.url("/gvm/public/v1/targets")) .bearer_auth(&self.token) .json(&payload) .send() @@ -344,7 +344,7 @@ impl TargetHarness { pub async fn get_target(&self, id: &str) -> Response { self.client - .get(self.url(&format!("/api/v1/targets/{id}"))) + .get(self.url(&format!("/gvm/public/v1/targets/{id}"))) .bearer_auth(&self.token) .send() .await @@ -353,7 +353,7 @@ impl TargetHarness { pub async fn update_target(&self, id: &str, payload: Value) -> Response { self.client - .put(self.url(&format!("/api/v1/targets/{id}"))) + .put(self.url(&format!("/gvm/public/v1/targets/{id}"))) .bearer_auth(&self.token) .json(&payload) .send() @@ -363,7 +363,7 @@ impl TargetHarness { pub async fn delete_target(&self, id: &str) -> Response { self.client - .delete(self.url(&format!("/api/v1/targets/{id}"))) + .delete(self.url(&format!("/gvm/public/v1/targets/{id}"))) .bearer_auth(&self.token) .send() .await @@ -372,7 +372,7 @@ impl TargetHarness { pub async fn create_session_with_basic(&self, user: &str, password: &str) -> Response { self.client - .post(self.url("/api/v1/session")) + .post(self.url("/gvm/public/v1/session")) .basic_auth(user, Some(password)) .send() .await diff --git a/crates/gvm-gateway/tests/contract.rs b/crates/gvm-gateway/tests/contract.rs index 5bdb2bdb..e585b71d 100644 --- a/crates/gvm-gateway/tests/contract.rs +++ b/crates/gvm-gateway/tests/contract.rs @@ -45,7 +45,7 @@ async fn generated_openapi_endpoint_exposes_implemented_contract() { let adapter = StaticGvmdAdapter::ready("22.7"); let (addr, handle) = spawn_server(adapter.clone(), adapter).await; let response = Client::new() - .get(format!("http://{addr}/api/v1/openapi.json")) + .get(format!("http://{addr}/gvm/public/v1/openapi.json")) .send() .await .unwrap(); @@ -61,7 +61,7 @@ async fn generated_openapi_endpoint_exposes_implemented_contract() { let json = response.json::().await.unwrap(); assert!( - json["paths"]["/api/v1/agents/inventory-token"]["post"] + json["paths"]["/gvm/public/v1/agents/inventory-token"]["post"] .get("requestBody") .is_none(), "inventory-token issuance accepts no request body" @@ -130,7 +130,7 @@ async fn report_drill_down_and_operating_system_routes_expose_typed_contracts() let response = harness .client .get(harness.url(&format!( - "/api/v1/reports/{report_id}/{subresource}?filter=severity%3E3&page=1&perPage=10" + "/gvm/public/v1/reports/{report_id}/{subresource}?filter=severity%3E3&page=1&perPage=10" ))) .bearer_auth(&harness.token) .send() @@ -161,7 +161,7 @@ async fn report_drill_down_and_operating_system_routes_expose_typed_contracts() let response = harness .client .get(harness.url(&format!( - "/api/v1/reports/{report_id}/operating-systems?filter=severity%3E3&page=1&perPage=10" + "/gvm/public/v1/reports/{report_id}/operating-systems?filter=severity%3E3&page=1&perPage=10" ))) .bearer_auth(&harness.token) .send() @@ -190,7 +190,7 @@ async fn report_drill_down_and_operating_system_routes_expose_typed_contracts() let response = harness .client - .get(harness.url("/api/v1/operating-systems?page=1&perPage=10")) + .get(harness.url("/gvm/public/v1/operating-systems?page=1&perPage=10")) .bearer_auth(&harness.token) .send() .await @@ -206,7 +206,9 @@ async fn report_drill_down_and_operating_system_routes_expose_typed_contracts() let response = harness .client - .get(harness.url(&format!("/api/v1/operating-systems/{removable_os_id}"))) + .get(harness.url(&format!( + "/gvm/public/v1/operating-systems/{removable_os_id}" + ))) .bearer_auth(&harness.token) .send() .await @@ -218,7 +220,9 @@ async fn report_drill_down_and_operating_system_routes_expose_typed_contracts() let response = harness .client - .put(harness.url(&format!("/api/v1/operating-systems/{removable_os_id}"))) + .put(harness.url(&format!( + "/gvm/public/v1/operating-systems/{removable_os_id}" + ))) .bearer_auth(&harness.token) .json(&serde_json::json!({ "comment": "reviewed" })) .send() @@ -242,7 +246,7 @@ async fn report_drill_down_and_operating_system_routes_expose_typed_contracts() let response = harness .client .delete(harness.url(&format!( - "/api/v1/operating-systems/{removable_os_id}?ultimate=true" + "/gvm/public/v1/operating-systems/{removable_os_id}?ultimate=true" ))) .bearer_auth(&harness.token) .send() @@ -252,7 +256,7 @@ async fn report_drill_down_and_operating_system_routes_expose_typed_contracts() let response = harness .client - .delete(harness.url(&format!("/api/v1/operating-systems/{in_use_os_id}"))) + .delete(harness.url(&format!("/gvm/public/v1/operating-systems/{in_use_os_id}"))) .bearer_auth(&harness.token) .send() .await @@ -269,7 +273,9 @@ async fn report_drill_down_and_operating_system_routes_expose_typed_contracts() let response = harness .client - .delete(harness.url(&format!("/api/v1/operating-systems/{removable_os_id}"))) + .delete(harness.url(&format!( + "/gvm/public/v1/operating-systems/{removable_os_id}" + ))) .bearer_auth(&harness.token) .send() .await @@ -302,7 +308,9 @@ async fn assert_operating_system_delete_server_error(message: &str, expected: St let response = harness .client - .delete(harness.url(&format!("/api/v1/operating-systems/{operating_system_id}"))) + .delete(harness.url(&format!( + "/gvm/public/v1/operating-systems/{operating_system_id}" + ))) .bearer_auth(&harness.token) .send() .await @@ -351,37 +359,41 @@ async fn config_family_mutation_routes_return_not_found_without_dispatching_writ let cases = [ ( Method::PUT, - format!("/api/v1/scan-configs/{policy_id}"), + format!("/gvm/public/v1/scan-configs/{policy_id}"), Some(serde_json::json!({ "name": "must not be applied" })), ), ( Method::DELETE, - format!("/api/v1/scan-configs/{policy_id}"), + format!("/gvm/public/v1/scan-configs/{policy_id}"), None, ), ( Method::PUT, - format!("/api/v1/scan-configs/{policy_id}/families/General/nvts"), + format!("/gvm/public/v1/scan-configs/{policy_id}/families/General/nvts"), Some(serde_json::json!({ "nvtOids": ["1.3.6.1.4.1"] })), ), ( Method::PUT, - format!("/api/v1/scan-configs/{policy_id}/family-selection"), + format!("/gvm/public/v1/scan-configs/{policy_id}/family-selection"), Some(serde_json::json!({ "families": [{ "name": "General", "growing": false, "all": true }] })), ), ( Method::PUT, - format!("/api/v1/scan-configs/{policy_id}/preferences/Timeout"), + format!("/gvm/public/v1/scan-configs/{policy_id}/preferences/Timeout"), Some(serde_json::json!({ "value": "10" })), ), ( Method::PUT, - format!("/api/v1/policies/{scan_id}"), + format!("/gvm/public/v1/policies/{scan_id}"), Some(serde_json::json!({ "name": "must not be applied" })), ), - (Method::DELETE, format!("/api/v1/policies/{scan_id}"), None), + ( + Method::DELETE, + format!("/gvm/public/v1/policies/{scan_id}"), + None, + ), ]; for (method, path, body) in cases { @@ -436,7 +448,9 @@ async fn qod_is_consistent_across_shared_result_endpoints() { let client = Client::new(); let list = client - .get(format!("http://{addr}/api/v1/results?page=1&perPage=10")) + .get(format!( + "http://{addr}/gvm/public/v1/results?page=1&perPage=10" + )) .bearer_auth(&token) .send() .await @@ -447,7 +461,7 @@ async fn qod_is_consistent_across_shared_result_endpoints() { .await .expect("result list JSON"); let detail = client - .get(format!("http://{addr}/api/v1/results/{result_id}")) + .get(format!("http://{addr}/gvm/public/v1/results/{result_id}")) .bearer_auth(&token) .send() .await @@ -459,7 +473,7 @@ async fn qod_is_consistent_across_shared_result_endpoints() { .expect("result detail JSON"); let report_results = client .get(format!( - "http://{addr}/api/v1/reports/{report_id}/results?page=1&perPage=10" + "http://{addr}/gvm/public/v1/reports/{report_id}/results?page=1&perPage=10" )) .bearer_auth(&token) .send() @@ -472,7 +486,7 @@ async fn qod_is_consistent_across_shared_result_endpoints() { .expect("report results JSON"); let report = client .get(format!( - "http://{addr}/api/v1/reports/{report_id}?page=1&perPage=10" + "http://{addr}/gvm/public/v1/reports/{report_id}?page=1&perPage=10" )) .bearer_auth(&token) .send() @@ -503,7 +517,7 @@ async fn bounded_report_import_contract_creates_readable_resource_and_redacts_fa let harness = specialized_target_harness(|_| {}).await; let task_response = harness .client - .post(harness.url("/api/v1/tasks")) + .post(harness.url("/gvm/public/v1/tasks")) .bearer_auth(&harness.token) .json(&serde_json::json!({ "type": "import", @@ -520,7 +534,7 @@ async fn bounded_report_import_contract_creates_readable_resource_and_redacts_fa .as_str() .expect("created task ID") .to_string(); - let endpoint = format!("/api/v1/reports?taskId={task_id}&inAssets=false"); + let endpoint = format!("/gvm/public/v1/reports?taskId={task_id}&inAssets=false"); let unauthorized = harness .client @@ -545,7 +559,7 @@ async fn bounded_report_import_contract_creates_readable_resource_and_redacts_fa let invalid_task = harness .client - .post(harness.url("/api/v1/reports?taskId=not-a-uuid")) + .post(harness.url("/gvm/public/v1/reports?taskId=not-a-uuid")) .bearer_auth(&harness.token) .header("Content-Type", "application/xml") .body("") @@ -556,7 +570,7 @@ async fn bounded_report_import_contract_creates_readable_resource_and_redacts_fa let missing_task = harness .client - .post(harness.url("/api/v1/reports?taskId=aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa")) + .post(harness.url("/gvm/public/v1/reports?taskId=aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa")) .bearer_auth(&harness.token) .header("Content-Type", "application/xml") .body("") @@ -628,7 +642,7 @@ async fn bounded_report_import_contract_creates_readable_resource_and_redacts_fa .as_str() .expect("created report ID") .to_string(); - assert_eq!(location, format!("/api/v1/reports/{report_id}")); + assert_eq!(location, format!("/gvm/public/v1/reports/{report_id}")); let readback = harness .client @@ -655,7 +669,7 @@ async fn bounded_report_import_contract_creates_readable_resource_and_redacts_fa assert_eq!(deleted_report.status(), StatusCode::NO_CONTENT); let deleted_task = harness .client - .delete(harness.url(&format!("/api/v1/tasks/{task_id}"))) + .delete(harness.url(&format!("/gvm/public/v1/tasks/{task_id}"))) .bearer_auth(&harness.token) .send() .await @@ -724,7 +738,7 @@ async fn update_task_preserves_preferences_through_handler() { // full REST route path, not just direct request validation or gvmd emission. let response = Client::new() .put(format!( - "http://{addr}/api/v1/tasks/550e8400-e29b-41d4-a716-446655440000" + "http://{addr}/gvm/public/v1/tasks/550e8400-e29b-41d4-a716-446655440000" )) .bearer_auth(&token) .json(&serde_json::json!({ @@ -766,7 +780,9 @@ async fn create_report_export_job_bearer_survives_delayed_execution() { // a job location, deliberately delayed work keeps using the persistent // session after the response, and polling reaches a downloadable result. let create_response = client - .post(format!("http://{addr}/api/v1/reports/{report_id}/exports")) + .post(format!( + "http://{addr}/gvm/public/v1/reports/{report_id}/exports" + )) .bearer_auth(&token) .json(&serde_json::json!({ "format": "json" })) .send() @@ -785,12 +801,12 @@ async fn create_report_export_job_bearer_survives_delayed_execution() { assert_eq!(created["report"]["id"], report_id); let job_id = created["id"].as_str().unwrap(); - assert_eq!(location, format!("/api/v1/jobs/{job_id}")); + assert_eq!(location, format!("/gvm/public/v1/jobs/{job_id}")); let mut completed = None; for _ in 0..20 { let job = client - .get(format!("http://{addr}/api/v1/jobs/{job_id}")) + .get(format!("http://{addr}/gvm/public/v1/jobs/{job_id}")) .bearer_auth(&token) .send() .await @@ -807,13 +823,13 @@ async fn create_report_export_job_bearer_survives_delayed_execution() { let completed = completed.expect("report export job should succeed"); assert_eq!( completed["resultLocation"], - format!("/api/v1/jobs/{job_id}/result") + format!("/gvm/public/v1/jobs/{job_id}/result") ); assert_eq!(completed["result"]["contentType"], "application/json"); assert!(completed["expiresAt"].as_str().is_some()); let result_response = client - .get(format!("http://{addr}/api/v1/jobs/{job_id}/result")) + .get(format!("http://{addr}/gvm/public/v1/jobs/{job_id}/result")) .bearer_auth(&token) .send() .await @@ -858,7 +874,7 @@ async fn report_delete_rejects_obsolete_permanence_choice_before_permanent_delet // run. This prevents a successful response from implying trash semantics. let rejected = client .delete(format!( - "http://{addr}/api/v1/reports/{report_id}?ultimate=false" + "http://{addr}/gvm/public/v1/reports/{report_id}?ultimate=false" )) .bearer_auth(&token) .send() @@ -875,7 +891,10 @@ async fn report_delete_rejects_obsolete_permanence_choice_before_permanent_delet let problem = rejected.json::().await.expect("RFC 9457 response"); assert_eq!(problem["code"], "bad_request"); assert_eq!(problem["status"], 400); - assert_eq!(problem["instance"], format!("/api/v1/reports/{report_id}")); + assert_eq!( + problem["instance"], + format!("/gvm/public/v1/reports/{report_id}") + ); assert!(problem["detail"] .as_str() .is_some_and(|detail| detail.contains("always permanent"))); @@ -891,7 +910,7 @@ async fn report_delete_rejects_obsolete_permanence_choice_before_permanent_delet // and the no-choice delete contract reaches the port exactly once. let deleted = client .delete(format!( - "http://{addr}/api/v1/reports/{report_id}?reason=cleanup" + "http://{addr}/gvm/public/v1/reports/{report_id}?reason=cleanup" )) .bearer_auth(&token) .send() @@ -919,7 +938,9 @@ async fn report_export_jobs_are_hidden_from_other_users() { // contract: a different authenticated gvmd user must not be able to infer, // cancel, or download another user's export job. let created = client - .post(format!("http://{addr}/api/v1/reports/{report_id}/exports")) + .post(format!( + "http://{addr}/gvm/public/v1/reports/{report_id}/exports" + )) .bearer_auth(&owner_token) .json(&serde_json::json!({ "format": "json" })) .send() @@ -931,7 +952,7 @@ async fn report_export_jobs_are_hidden_from_other_users() { let job_id = created["id"].as_str().unwrap(); let status_response = client - .get(format!("http://{addr}/api/v1/jobs/{job_id}")) + .get(format!("http://{addr}/gvm/public/v1/jobs/{job_id}")) .bearer_auth(&other_token) .send() .await @@ -939,7 +960,7 @@ async fn report_export_jobs_are_hidden_from_other_users() { assert_eq!(status_response.status(), StatusCode::NOT_FOUND); let cancel_response = client - .delete(format!("http://{addr}/api/v1/jobs/{job_id}")) + .delete(format!("http://{addr}/gvm/public/v1/jobs/{job_id}")) .bearer_auth(&other_token) .send() .await @@ -947,7 +968,7 @@ async fn report_export_jobs_are_hidden_from_other_users() { assert_eq!(cancel_response.status(), StatusCode::NOT_FOUND); let result_response = client - .get(format!("http://{addr}/api/v1/jobs/{job_id}/result")) + .get(format!("http://{addr}/gvm/public/v1/jobs/{job_id}/result")) .bearer_auth(&other_token) .send() .await @@ -955,7 +976,7 @@ async fn report_export_jobs_are_hidden_from_other_users() { assert_eq!(result_response.status(), StatusCode::NOT_FOUND); let owner_response = client - .get(format!("http://{addr}/api/v1/jobs/{job_id}")) + .get(format!("http://{addr}/gvm/public/v1/jobs/{job_id}")) .bearer_auth(&owner_token) .send() .await @@ -974,7 +995,9 @@ async fn report_export_job_create_returns_not_found_for_missing_report() { // contract at job creation time instead of hiding the failure in a later // background status poll. let response = Client::new() - .post(format!("http://{addr}/api/v1/reports/{report_id}/exports")) + .post(format!( + "http://{addr}/gvm/public/v1/reports/{report_id}/exports" + )) .bearer_auth(&token) .json(&serde_json::json!({ "format": "json" })) .send() @@ -998,7 +1021,7 @@ async fn credential_store_capability_absence_returns_501_problem() { // generic bad gateway so clients can distinguish unsupported setup flows // from transient backend outages. let response = Client::new() - .get(format!("http://{addr}/api/v1/credential-stores")) + .get(format!("http://{addr}/gvm/public/v1/credential-stores")) .bearer_auth(&token) .send() .await @@ -1011,7 +1034,7 @@ async fn credential_store_capability_absence_returns_501_problem() { assert_eq!(json["status"], serde_json::json!(501)); assert_eq!( json["instance"], - serde_json::json!("/api/v1/credential-stores") + serde_json::json!("/gvm/public/v1/credential-stores") ); handle.abort(); @@ -1027,7 +1050,7 @@ async fn credential_store_backend_outage_returns_502_problem() { // Unrelated backend failures on the same route must not be widened into // the credential-store capability fallback; clients still receive 502. let response = Client::new() - .get(format!("http://{addr}/api/v1/credential-stores")) + .get(format!("http://{addr}/gvm/public/v1/credential-stores")) .bearer_auth(&token) .send() .await @@ -1040,7 +1063,7 @@ async fn credential_store_backend_outage_returns_502_problem() { assert_eq!(json["status"], serde_json::json!(502)); assert_eq!( json["instance"], - serde_json::json!("/api/v1/credential-stores") + serde_json::json!("/gvm/public/v1/credential-stores") ); handle.abort(); @@ -1071,7 +1094,7 @@ async fn representative_request_bodies_reject_unknown_fields_with_rfc9457_400() Case { name: "create target", method: Method::POST, - path: "/api/v1/targets".to_string(), + path: "/gvm/public/v1/targets".to_string(), body: serde_json::json!({ "name": "Example target", "hosts": ["192.0.2.1"], @@ -1082,7 +1105,7 @@ async fn representative_request_bodies_reject_unknown_fields_with_rfc9457_400() Case { name: "update task", method: Method::PUT, - path: format!("/api/v1/tasks/{task_id}"), + path: format!("/gvm/public/v1/tasks/{task_id}"), body: serde_json::json!({ "preferences": { "scanner.max_hosts": "64" @@ -1096,7 +1119,7 @@ async fn representative_request_bodies_reject_unknown_fields_with_rfc9457_400() Case { name: "create alert", method: Method::POST, - path: "/api/v1/alerts".to_string(), + path: "/gvm/public/v1/alerts".to_string(), body: serde_json::json!({ "name": "Notify ops", "event": "task_run_status_changed", @@ -1114,7 +1137,7 @@ async fn representative_request_bodies_reject_unknown_fields_with_rfc9457_400() Case { name: "create report export job", method: Method::POST, - path: format!("/api/v1/reports/{report_id}/exports"), + path: format!("/gvm/public/v1/reports/{report_id}/exports"), body: serde_json::json!({ "reportFormatId": "123e4567-e89b-12d3-a456-426614174000", "formatHint": "csv" @@ -1153,7 +1176,7 @@ async fn credential_store_capability_probe_does_not_change_credentials_list_cont // `/credentials` is unavailable for the same authenticated session. let client = Client::new(); let store_response = client - .get(format!("http://{addr}/api/v1/credential-stores")) + .get(format!("http://{addr}/gvm/public/v1/credential-stores")) .bearer_auth(&token) .send() .await @@ -1161,7 +1184,9 @@ async fn credential_store_capability_probe_does_not_change_credentials_list_cont assert_eq!(store_response.status(), StatusCode::NOT_IMPLEMENTED); let credentials_response = client - .get(format!("http://{addr}/api/v1/credentials?perPage=1000")) + .get(format!( + "http://{addr}/gvm/public/v1/credentials?perPage=1000" + )) .bearer_auth(&token) .send() .await @@ -1206,7 +1231,7 @@ async fn representative_request_bodies_accept_valid_payloads() { Case { name: "create target", method: Method::POST, - path: "/api/v1/targets".to_string(), + path: "/gvm/public/v1/targets".to_string(), body: serde_json::json!({ "name": "Example target", "hosts": ["192.0.2.1"], @@ -1219,7 +1244,7 @@ async fn representative_request_bodies_accept_valid_payloads() { Case { name: "update task", method: Method::PUT, - path: format!("/api/v1/tasks/{task_id}"), + path: format!("/gvm/public/v1/tasks/{task_id}"), body: serde_json::json!({ "preferences": { "scanner.max_hosts": "64", @@ -1233,7 +1258,7 @@ async fn representative_request_bodies_accept_valid_payloads() { Case { name: "create alert", method: Method::POST, - path: "/api/v1/alerts".to_string(), + path: "/gvm/public/v1/alerts".to_string(), body: serde_json::json!({ "name": "Notify ops", "event": "task_run_status_changed", @@ -1257,7 +1282,7 @@ async fn representative_request_bodies_accept_valid_payloads() { Case { name: "create report export job", method: Method::POST, - path: format!("/api/v1/reports/{report_id}/exports"), + path: format!("/gvm/public/v1/reports/{report_id}/exports"), body: serde_json::json!({ "format": "json" }), @@ -2371,7 +2396,7 @@ async fn trace_context_headers_propagated_without_baggage_echo() { let adapter = StaticGvmdAdapter::ready("22.7"); let (addr, handle) = spawn_server(adapter.clone(), adapter).await; let response = Client::new() - .get(format!("http://{addr}/health")) + .get(format!("http://{addr}/gvm/health")) .header( "traceparent", "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-00", @@ -2401,7 +2426,7 @@ async fn problem_details_shape_on_error() { let adapter = StaticGvmdAdapter::not_ready("backend offline", "22.7"); let (addr, handle) = spawn_server(adapter.clone(), adapter).await; let response = Client::new() - .get(format!("http://{addr}/api/v1/version")) + .get(format!("http://{addr}/gvm/public/v1/version")) .send() .await .unwrap(); @@ -2421,7 +2446,10 @@ async fn problem_details_shape_on_error() { serde_json::json!("The backend service is unavailable.") ); assert_ne!(json["detail"], serde_json::json!("backend offline")); - assert_eq!(json["instance"], serde_json::json!("/api/v1/version")); + assert_eq!( + json["instance"], + serde_json::json!("/gvm/public/v1/version") + ); handle.abort(); } @@ -2436,7 +2464,7 @@ async fn secinfo_item_routes_accept_non_uuid_ids() { // SecInfo ids are backend-defined strings like CVE and advisory names, so // item routes must not reject them through UUID-only path validation. let response = client - .get(format!("http://{addr}/api/v1/cves/CVE-2026-1000")) + .get(format!("http://{addr}/gvm/public/v1/cves/CVE-2026-1000")) .bearer_auth(&session_token) .send() .await @@ -2867,8 +2895,10 @@ fn build_route_probe_request( ); match runtime_path.as_str() { - "/health" | "/ready" | "/api/v1/version" | "/api/v1/openapi.json" => request, - "/api/v1/session" if method == "post" => { + "/gvm/health" | "/gvm/ready" | "/gvm/public/v1/version" | "/gvm/public/v1/openapi.json" => { + request + } + "/gvm/public/v1/session" if method == "post" => { request.header("Authorization", "Basic YWRtaW46c2VjcmV0") } _ => request.bearer_auth(session_token), @@ -2877,7 +2907,7 @@ fn build_route_probe_request( async fn create_route_probe_session(client: &Client, addr: std::net::SocketAddr) -> String { client - .post(format!("http://{addr}/api/v1/session")) + .post(format!("http://{addr}/gvm/public/v1/session")) .header("Authorization", "Basic YWRtaW46c2VjcmV0") .send() .await @@ -3576,7 +3606,7 @@ async fn ad_search_generated_and_curated_cache_header_schemas_match() { let adapter = StaticGvmdAdapter::ready("22.7"); let (addr, handle) = spawn_server(adapter.clone(), adapter).await; let generated: Value = Client::new() - .get(format!("http://{addr}/api/v1/openapi.json")) + .get(format!("http://{addr}/gvm/public/v1/openapi.json")) .send() .await .unwrap() diff --git a/crates/gvm-gateway/tests/generic_resources.rs b/crates/gvm-gateway/tests/generic_resources.rs index 235077af..b88cb9e9 100644 --- a/crates/gvm-gateway/tests/generic_resources.rs +++ b/crates/gvm-gateway/tests/generic_resources.rs @@ -39,7 +39,7 @@ async fn generic_asset_rest_contract_scopes_reads_and_limits_mutation() { let list = harness .client - .get(harness.url("/api/v1/assets?type=host&page=1&perPage=10")) + .get(harness.url("/gvm/public/v1/assets?type=host&page=1&perPage=10")) .bearer_auth(&harness.token) .send() .await @@ -55,7 +55,7 @@ async fn generic_asset_rest_contract_scopes_reads_and_limits_mutation() { let get = harness .client - .get(harness.url(&format!("/api/v1/assets/{HOST_ID}?type=host"))) + .get(harness.url(&format!("/gvm/public/v1/assets/{HOST_ID}?type=host"))) .bearer_auth(&harness.token) .send() .await @@ -65,7 +65,7 @@ async fn generic_asset_rest_contract_scopes_reads_and_limits_mutation() { let update = harness .client - .put(harness.url(&format!("/api/v1/assets/{HOST_ID}?type=host"))) + .put(harness.url(&format!("/gvm/public/v1/assets/{HOST_ID}?type=host"))) .bearer_auth(&harness.token) .json(&json!({"comment":"updated through generic REST"})) .send() @@ -79,7 +79,7 @@ async fn generic_asset_rest_contract_scopes_reads_and_limits_mutation() { let unsupported = harness .client - .delete(harness.url(&format!("/api/v1/assets/{HOST_ID}?ultimate=false"))) + .delete(harness.url(&format!("/gvm/public/v1/assets/{HOST_ID}?ultimate=false"))) .bearer_auth(&harness.token) .send() .await @@ -88,7 +88,7 @@ async fn generic_asset_rest_contract_scopes_reads_and_limits_mutation() { let delete = harness .client - .delete(harness.url(&format!("/api/v1/assets/{HOST_ID}"))) + .delete(harness.url(&format!("/gvm/public/v1/assets/{HOST_ID}"))) .bearer_auth(&harness.token) .send() .await @@ -125,7 +125,7 @@ async fn generic_config_rest_contract_preserves_open_usage_clone_and_ultimate() let list = harness .client - .get(harness.url("/api/v1/configs?usageType=future_usage&page=1&perPage=10")) + .get(harness.url("/gvm/public/v1/configs?usageType=future_usage&page=1&perPage=10")) .bearer_auth(&harness.token) .send() .await @@ -139,7 +139,7 @@ async fn generic_config_rest_contract_preserves_open_usage_clone_and_ultimate() let get = harness .client - .get(harness.url(&format!("/api/v1/configs/{FUTURE_CONFIG_ID}"))) + .get(harness.url(&format!("/gvm/public/v1/configs/{FUTURE_CONFIG_ID}"))) .bearer_auth(&harness.token) .send() .await @@ -152,7 +152,7 @@ async fn generic_config_rest_contract_preserves_open_usage_clone_and_ultimate() let clone = harness .client - .post(harness.url(&format!("/api/v1/configs/{FUTURE_CONFIG_ID}/clone"))) + .post(harness.url(&format!("/gvm/public/v1/configs/{FUTURE_CONFIG_ID}/clone"))) .bearer_auth(&harness.token) .send() .await @@ -169,11 +169,11 @@ async fn generic_config_rest_contract_preserves_open_usage_clone_and_ultimate() .as_str() .unwrap() .to_string(); - assert_eq!(location, format!("/api/v1/configs/{cloned_id}")); + assert_eq!(location, format!("/gvm/public/v1/configs/{cloned_id}")); let delete = harness .client - .delete(harness.url(&format!("/api/v1/configs/{cloned_id}?ultimate=true"))) + .delete(harness.url(&format!("/gvm/public/v1/configs/{cloned_id}?ultimate=true"))) .bearer_auth(&harness.token) .send() .await diff --git a/crates/gvm-gateway/tests/identity.rs b/crates/gvm-gateway/tests/identity.rs index 6befaf34..7484e8a1 100644 --- a/crates/gvm-gateway/tests/identity.rs +++ b/crates/gvm-gateway/tests/identity.rs @@ -37,7 +37,7 @@ async fn user_delete_rejects_all_ultimate_forms_before_backend_dispatch() { ] { let response = harness .client - .delete(harness.url(&format!("/api/v1/users/{USER_ID}?{query}"))) + .delete(harness.url(&format!("/gvm/public/v1/users/{USER_ID}?{query}"))) .bearer_auth(&harness.token) .send() .await @@ -68,7 +68,7 @@ async fn plain_user_delete_dispatches_one_canonical_typed_command() { let response = harness .client - .delete(harness.url(&format!("/api/v1/users/{USER_ID}"))) + .delete(harness.url(&format!("/gvm/public/v1/users/{USER_ID}"))) .bearer_auth(&harness.token) .send() .await diff --git a/crates/gvm-gateway/tests/security.rs b/crates/gvm-gateway/tests/security.rs index 8300fa15..7d435504 100644 --- a/crates/gvm-gateway/tests/security.rs +++ b/crates/gvm-gateway/tests/security.rs @@ -58,7 +58,7 @@ async fn create_report_export_job_rejects_basic_without_side_effects() { // when request-scoped Basic cleanup deletes its creating session. let response = harness .client - .post(harness.url(&format!("/api/v1/reports/{report_id}/exports"))) + .post(harness.url(&format!("/gvm/public/v1/reports/{report_id}/exports"))) .basic_auth("admin", Some("admin")) .json(&serde_json::json!({ "format": "json" })) .send() @@ -86,7 +86,7 @@ async fn malformed_basic_auth_on_protected_route_returns_401() { let response = harness .client - .get(harness.url("/api/v1/targets")) + .get(harness.url("/gvm/public/v1/targets")) .header("Authorization", "Basic not-base64") .send() .await @@ -105,7 +105,7 @@ async fn protected_endpoint_missing_bearer_rejected() { let response = harness .client - .get(harness.url("/api/v1/targets")) + .get(harness.url("/gvm/public/v1/targets")) .send() .await .unwrap(); @@ -120,7 +120,7 @@ async fn protected_endpoint_malformed_bearer_rejected() { let response = harness .client - .get(harness.url("/api/v1/targets")) + .get(harness.url("/gvm/public/v1/targets")) .header("Authorization", "Bearer") .send() .await @@ -136,7 +136,7 @@ async fn protected_endpoint_unknown_session_rejected() { let response = harness .client - .get(harness.url("/api/v1/targets")) + .get(harness.url("/gvm/public/v1/targets")) .bearer_auth("gvm_sess_unknown") .send() .await @@ -193,7 +193,10 @@ async fn cors_preflight_allowed_origin() { let response = harness .client - .request(reqwest::Method::OPTIONS, harness.url("/api/v1/targets")) + .request( + reqwest::Method::OPTIONS, + harness.url("/gvm/public/v1/targets"), + ) .header("Origin", "https://ui.example") .header("Access-Control-Request-Method", "GET") .send() @@ -226,7 +229,10 @@ async fn cors_preflight_denied_origin() { let response = harness .client - .request(reqwest::Method::OPTIONS, harness.url("/api/v1/targets")) + .request( + reqwest::Method::OPTIONS, + harness.url("/gvm/public/v1/targets"), + ) .header("Origin", "https://evil.example") .header("Access-Control-Request-Method", "GET") .send() @@ -356,7 +362,7 @@ async fn different_sessions_have_independent_subject_limits() { let second = harness .client - .get(harness.url("/api/v1/targets")) + .get(harness.url("/gvm/public/v1/targets")) .bearer_auth(&second_token) .send() .await @@ -392,7 +398,7 @@ async fn global_limit_applies_across_sessions() { let second = harness .client - .get(harness.url("/api/v1/targets")) + .get(harness.url("/gvm/public/v1/targets")) .bearer_auth(&second_token) .send() .await @@ -473,7 +479,7 @@ async fn session_creation_rate_limit_is_source_aware_before_authentication() { let second = harness .client - .post(harness.url("/api/v1/session")) + .post(harness.url("/gvm/public/v1/session")) .basic_auth("admin", Some("different-password")) .send() .await @@ -515,7 +521,7 @@ async fn trusted_forwarded_clients_have_independent_session_creation_limits() { let first = harness .client - .post(harness.url("/api/v1/session")) + .post(harness.url("/gvm/public/v1/session")) .header("X-Forwarded-For", "198.51.100.10") .basic_auth("admin", Some("admin")) .send() @@ -525,7 +531,7 @@ async fn trusted_forwarded_clients_have_independent_session_creation_limits() { let second = harness .client - .post(harness.url("/api/v1/session")) + .post(harness.url("/gvm/public/v1/session")) .header("X-Forwarded-For", "198.51.100.11") .basic_auth("admin", Some("admin")) .send() @@ -535,7 +541,7 @@ async fn trusted_forwarded_clients_have_independent_session_creation_limits() { let first_again = harness .client - .post(harness.url("/api/v1/session")) + .post(harness.url("/gvm/public/v1/session")) .header("X-Forwarded-For", "198.51.100.10") .basic_auth("admin", Some("admin")) .send() diff --git a/crates/gvm-gateway/tests/sessions.rs b/crates/gvm-gateway/tests/sessions.rs index b4a3629c..5a1c7d89 100644 --- a/crates/gvm-gateway/tests/sessions.rs +++ b/crates/gvm-gateway/tests/sessions.rs @@ -19,7 +19,7 @@ async fn create_session_valid_credentials() { let client = Client::new(); let response = client - .post(format!("http://{addr}/api/v1/session")) + .post(format!("http://{addr}/gvm/public/v1/session")) .header("Authorization", "Basic YWRtaW46c2VjcmV0") .send() .await @@ -36,7 +36,7 @@ async fn create_session_valid_credentials() { let json = response.json::().await.unwrap(); let token = json["sessionToken"].as_str().unwrap(); assert!(token.starts_with("gvm_sess_")); - assert_eq!(location, "/api/v1/session"); + assert_eq!(location, "/gvm/public/v1/session"); assert_eq!(json["expiresIn"], 300); assert_eq!(json["gmpVersion"], "22.7"); @@ -49,7 +49,7 @@ async fn create_session_missing_auth() { let (addr, handle) = spawn_server(adapter.clone(), adapter).await; let response = Client::new() - .post(format!("http://{addr}/api/v1/session")) + .post(format!("http://{addr}/gvm/public/v1/session")) .send() .await .unwrap(); @@ -85,13 +85,13 @@ async fn create_session_returns_429_when_session_limit_reached() { let client = Client::new(); let first = client - .post(format!("http://{addr}/api/v1/session")) + .post(format!("http://{addr}/gvm/public/v1/session")) .header("Authorization", "Basic YWRtaW46c2VjcmV0") .send() .await .unwrap(); let second = client - .post(format!("http://{addr}/api/v1/session")) + .post(format!("http://{addr}/gvm/public/v1/session")) .header("Authorization", "Basic YWRtaW46c2VjcmV0") .send() .await @@ -130,13 +130,13 @@ async fn create_session_replaces_expired_limited_session_without_reaper() { let client = Client::new(); let first = client - .post(format!("http://{addr}/api/v1/session")) + .post(format!("http://{addr}/gvm/public/v1/session")) .header("Authorization", "Basic YWRtaW46c2VjcmV0") .send() .await .unwrap(); let second = client - .post(format!("http://{addr}/api/v1/session")) + .post(format!("http://{addr}/gvm/public/v1/session")) .header("Authorization", "Basic YWRtaW46c2VjcmV0") .send() .await @@ -155,7 +155,7 @@ async fn get_session_returns_details() { let client = Client::new(); let create_resp = client - .post(format!("http://{addr}/api/v1/session")) + .post(format!("http://{addr}/gvm/public/v1/session")) .header("Authorization", "Basic YWRtaW46c2VjcmV0") .send() .await @@ -166,7 +166,7 @@ async fn get_session_returns_details() { .to_string(); let response = client - .get(format!("http://{addr}/api/v1/session")) + .get(format!("http://{addr}/gvm/public/v1/session")) .bearer_auth(&token) .send() .await @@ -188,7 +188,7 @@ async fn get_session_not_found() { let (addr, handle) = spawn_server(adapter.clone(), adapter).await; let response = Client::new() - .get(format!("http://{addr}/api/v1/session")) + .get(format!("http://{addr}/gvm/public/v1/session")) .bearer_auth("nonexistent-token") .send() .await @@ -205,7 +205,7 @@ async fn delete_session_closes_and_invalidates() { let client = Client::new(); let create_resp = client - .post(format!("http://{addr}/api/v1/session")) + .post(format!("http://{addr}/gvm/public/v1/session")) .header("Authorization", "Basic YWRtaW46c2VjcmV0") .send() .await @@ -216,7 +216,7 @@ async fn delete_session_closes_and_invalidates() { .to_string(); let response = client - .delete(format!("http://{addr}/api/v1/session")) + .delete(format!("http://{addr}/gvm/public/v1/session")) .bearer_auth(&token) .send() .await @@ -224,7 +224,7 @@ async fn delete_session_closes_and_invalidates() { assert_eq!(response.status(), StatusCode::NO_CONTENT); let response = client - .get(format!("http://{addr}/api/v1/session")) + .get(format!("http://{addr}/gvm/public/v1/session")) .bearer_auth(&token) .send() .await @@ -255,7 +255,7 @@ async fn session_reaper_cleans_up_expired_sessions() { let client = Client::new(); let create_resp = client - .post(format!("http://{addr}/api/v1/session")) + .post(format!("http://{addr}/gvm/public/v1/session")) .header("Authorization", "Basic YWRtaW46c2VjcmV0") .send() .await @@ -269,7 +269,7 @@ async fn session_reaper_cleans_up_expired_sessions() { tokio::time::sleep(Duration::from_millis(100)).await; let response = client - .get(format!("http://{addr}/api/v1/session")) + .get(format!("http://{addr}/gvm/public/v1/session")) .bearer_auth(&token) .send() .await @@ -286,7 +286,7 @@ async fn delete_session_not_found() { let (addr, handle) = spawn_server(adapter.clone(), adapter).await; let response = Client::new() - .delete(format!("http://{addr}/api/v1/session")) + .delete(format!("http://{addr}/gvm/public/v1/session")) .bearer_auth("nonexistent-token") .send() .await diff --git a/crates/gvm-gateway/tests/specialized_targets.rs b/crates/gvm-gateway/tests/specialized_targets.rs index 18d40fb2..b024d9d6 100644 --- a/crates/gvm-gateway/tests/specialized_targets.rs +++ b/crates/gvm-gateway/tests/specialized_targets.rs @@ -34,7 +34,7 @@ async fn created_id(response: reqwest::Response, collection: &str) -> String { .as_str() .unwrap() .to_string(); - assert_eq!(location, format!("/api/v1/{collection}/{id}")); + assert_eq!(location, format!("/gvm/public/v1/{collection}/{id}")); id } @@ -43,12 +43,12 @@ async fn oci_image_target_rest_lifecycle_filter_trash_and_ultimate_delete() { // This contract test exercises every published OCI target operation and // verifies that list/delete query semantics reach the typed backend. let harness = specialized_target_harness(seed_saved_filter).await; - let create = harness.client.post(harness.url("/api/v1/oci-image-targets")).bearer_auth(&harness.token).json(&json!({"name":"OCI Demo","imageReferences":["registry.example/app:1"],"comment":"initial"})).send().await.unwrap(); + let create = harness.client.post(harness.url("/gvm/public/v1/oci-image-targets")).bearer_auth(&harness.token).json(&json!({"name":"OCI Demo","imageReferences":["registry.example/app:1"],"comment":"initial"})).send().await.unwrap(); let id = created_id(create, "oci-image-targets").await; let get = harness .client - .get(harness.url(&format!("/api/v1/oci-image-targets/{id}"))) + .get(harness.url(&format!("/gvm/public/v1/oci-image-targets/{id}"))) .bearer_auth(&harness.token) .send() .await @@ -61,7 +61,7 @@ async fn oci_image_target_rest_lifecycle_filter_trash_and_ultimate_delete() { let update = harness .client - .put(harness.url(&format!("/api/v1/oci-image-targets/{id}"))) + .put(harness.url(&format!("/gvm/public/v1/oci-image-targets/{id}"))) .bearer_auth(&harness.token) .json(&json!({"name":"Updated","imageReferences":["registry.example/app:2"]})) .send() @@ -72,23 +72,22 @@ async fn oci_image_target_rest_lifecycle_filter_trash_and_ultimate_delete() { let clone = harness .client - .post(harness.url(&format!("/api/v1/oci-image-targets/{id}/clone"))) + .post(harness.url(&format!("/gvm/public/v1/oci-image-targets/{id}/clone"))) .bearer_auth(&harness.token) .send() .await .unwrap(); let clone_id = created_id(clone, "oci-image-targets").await; - let list = - harness - .client - .get(harness.url( - "/api/v1/oci-image-targets?filter=name%3DUpdated&page=1&perPage=10&trash=false", - )) - .bearer_auth(&harness.token) - .send() - .await - .unwrap(); + let list = harness + .client + .get(harness.url( + "/gvm/public/v1/oci-image-targets?filter=name%3DUpdated&page=1&perPage=10&trash=false", + )) + .bearer_auth(&harness.token) + .send() + .await + .unwrap(); assert_eq!(list.status(), StatusCode::OK); let list = list.json::().await.unwrap(); assert_eq!(list["pagination"]["perPage"], 10); @@ -111,7 +110,7 @@ async fn oci_image_target_rest_lifecycle_filter_trash_and_ultimate_delete() { let saved = harness .client .get(harness.url(&format!( - "/api/v1/oci-image-targets?filterId={SAVED_FILTER_ID}" + "/gvm/public/v1/oci-image-targets?filterId={SAVED_FILTER_ID}" ))) .bearer_auth(&harness.token) .send() @@ -126,7 +125,7 @@ async fn oci_image_target_rest_lifecycle_filter_trash_and_ultimate_delete() { let trash = harness .client - .delete(harness.url(&format!("/api/v1/oci-image-targets/{clone_id}"))) + .delete(harness.url(&format!("/gvm/public/v1/oci-image-targets/{clone_id}"))) .bearer_auth(&harness.token) .send() .await @@ -134,7 +133,7 @@ async fn oci_image_target_rest_lifecycle_filter_trash_and_ultimate_delete() { assert_eq!(trash.status(), StatusCode::NO_CONTENT); let trash_list = harness .client - .get(harness.url("/api/v1/oci-image-targets?trash=true")) + .get(harness.url("/gvm/public/v1/oci-image-targets?trash=true")) .bearer_auth(&harness.token) .send() .await @@ -148,7 +147,9 @@ async fn oci_image_target_rest_lifecycle_filter_trash_and_ultimate_delete() { let delete = harness .client - .delete(harness.url(&format!("/api/v1/oci-image-targets/{id}?ultimate=true"))) + .delete(harness.url(&format!( + "/gvm/public/v1/oci-image-targets/{id}?ultimate=true" + ))) .bearer_auth(&harness.token) .send() .await @@ -168,12 +169,12 @@ async fn web_application_target_rest_lifecycle_filter_trash_and_ultimate_delete( // Web application targets use a distinct DTO and command family; exercise // its full lifecycle independently to guard against classic-target reuse. let harness = specialized_target_harness(seed_saved_filter).await; - let create = harness.client.post(harness.url("/api/v1/web-application-targets")).bearer_auth(&harness.token).json(&json!({"name":"Web Demo","urls":["https://example.com"],"excludeUrls":["https://example.com/logout"]})).send().await.unwrap(); + let create = harness.client.post(harness.url("/gvm/public/v1/web-application-targets")).bearer_auth(&harness.token).json(&json!({"name":"Web Demo","urls":["https://example.com"],"excludeUrls":["https://example.com/logout"]})).send().await.unwrap(); let id = created_id(create, "web-application-targets").await; let update = harness .client - .put(harness.url(&format!("/api/v1/web-application-targets/{id}"))) + .put(harness.url(&format!("/gvm/public/v1/web-application-targets/{id}"))) .bearer_auth(&harness.token) .json(&json!({"name":"Updated","urls":["https://example.org"]})) .send() @@ -187,7 +188,7 @@ async fn web_application_target_rest_lifecycle_filter_trash_and_ultimate_delete( let get = harness .client - .get(harness.url(&format!("/api/v1/web-application-targets/{id}"))) + .get(harness.url(&format!("/gvm/public/v1/web-application-targets/{id}"))) .bearer_auth(&harness.token) .send() .await @@ -196,7 +197,9 @@ async fn web_application_target_rest_lifecycle_filter_trash_and_ultimate_delete( let clone = harness .client - .post(harness.url(&format!("/api/v1/web-application-targets/{id}/clone"))) + .post(harness.url(&format!( + "/gvm/public/v1/web-application-targets/{id}/clone" + ))) .bearer_auth(&harness.token) .send() .await @@ -205,7 +208,9 @@ async fn web_application_target_rest_lifecycle_filter_trash_and_ultimate_delete( let list = harness .client - .get(harness.url("/api/v1/web-application-targets?filter=name%3DUpdated&trash=false")) + .get( + harness.url("/gvm/public/v1/web-application-targets?filter=name%3DUpdated&trash=false"), + ) .bearer_auth(&harness.token) .send() .await @@ -231,7 +236,7 @@ async fn web_application_target_rest_lifecycle_filter_trash_and_ultimate_delete( let saved = harness .client .get(harness.url(&format!( - "/api/v1/web-application-targets?filterId={SAVED_FILTER_ID}" + "/gvm/public/v1/web-application-targets?filterId={SAVED_FILTER_ID}" ))) .bearer_auth(&harness.token) .send() @@ -247,7 +252,9 @@ async fn web_application_target_rest_lifecycle_filter_trash_and_ultimate_delete( assert_eq!( harness .client - .delete(harness.url(&format!("/api/v1/web-application-targets/{clone_id}"))) + .delete(harness.url(&format!( + "/gvm/public/v1/web-application-targets/{clone_id}" + ))) .bearer_auth(&harness.token) .send() .await @@ -257,7 +264,7 @@ async fn web_application_target_rest_lifecycle_filter_trash_and_ultimate_delete( ); let trash_list = harness .client - .get(harness.url("/api/v1/web-application-targets?trash=true")) + .get(harness.url("/gvm/public/v1/web-application-targets?trash=true")) .bearer_auth(&harness.token) .send() .await @@ -275,7 +282,7 @@ async fn web_application_target_rest_lifecycle_filter_trash_and_ultimate_delete( harness .client .delete(harness.url(&format!( - "/api/v1/web-application-targets/{id}?ultimate=true" + "/gvm/public/v1/web-application-targets/{id}?ultimate=true" ))) .bearer_auth(&harness.token) .send() @@ -302,7 +309,7 @@ async fn web_application_target_update_preserves_replaces_and_rejects_clear_excl let harness = specialized_target_harness(|_| {}).await; let create = harness .client - .post(harness.url("/api/v1/web-application-targets")) + .post(harness.url("/gvm/public/v1/web-application-targets")) .bearer_auth(&harness.token) .json(&json!({ "name": "Exclusion semantics", @@ -316,7 +323,7 @@ async fn web_application_target_update_preserves_replaces_and_rejects_clear_excl let omitted = harness .client - .put(harness.url(&format!("/api/v1/web-application-targets/{id}"))) + .put(harness.url(&format!("/gvm/public/v1/web-application-targets/{id}"))) .bearer_auth(&harness.token) .json(&json!({"name": "Renamed"})) .send() @@ -330,7 +337,7 @@ async fn web_application_target_update_preserves_replaces_and_rejects_clear_excl let replaced = harness .client - .put(harness.url(&format!("/api/v1/web-application-targets/{id}"))) + .put(harness.url(&format!("/gvm/public/v1/web-application-targets/{id}"))) .bearer_auth(&harness.token) .json(&json!({"excludeUrls": ["https://example.com/private"]})) .send() @@ -345,7 +352,7 @@ async fn web_application_target_update_preserves_replaces_and_rejects_clear_excl let commands_before_clear = harness.server.command_history().len(); let clear = harness .client - .put(harness.url(&format!("/api/v1/web-application-targets/{id}"))) + .put(harness.url(&format!("/gvm/public/v1/web-application-targets/{id}"))) .bearer_auth(&harness.token) .json(&json!({"excludeUrls": []})) .send() diff --git a/crates/gvm-gateway/tests/system.rs b/crates/gvm-gateway/tests/system.rs index 794ecbda..aa68f29c 100644 --- a/crates/gvm-gateway/tests/system.rs +++ b/crates/gvm-gateway/tests/system.rs @@ -30,7 +30,7 @@ async fn health_returns_200() { let adapter = StaticGvmdAdapter::ready("22.7"); let (addr, handle) = spawn_server(adapter.clone(), adapter).await; let response = Client::new() - .get(format!("http://{addr}/health")) + .get(format!("http://{addr}/gvm/health")) .send() .await .unwrap(); @@ -49,7 +49,7 @@ async fn ready_returns_200_when_ready() { let adapter = StaticGvmdAdapter::ready("22.7"); let (addr, handle) = spawn_server(adapter.clone(), adapter).await; let response = Client::new() - .get(format!("http://{addr}/ready")) + .get(format!("http://{addr}/gvm/ready")) .send() .await .unwrap(); @@ -68,7 +68,7 @@ async fn ready_returns_503_when_not_ready() { let adapter = StaticGvmdAdapter::not_ready("gvmd unavailable", "22.7"); let (addr, handle) = spawn_server(adapter.clone(), adapter).await; let response = Client::new() - .get(format!("http://{addr}/ready")) + .get(format!("http://{addr}/gvm/ready")) .send() .await .unwrap(); @@ -155,7 +155,7 @@ async fn version_returns_api_and_gmp_version() { let adapter = StaticGvmdAdapter::ready("22.7"); let (addr, handle) = spawn_server(adapter.clone(), adapter).await; let response = Client::new() - .get(format!("http://{addr}/api/v1/version")) + .get(format!("http://{addr}/gvm/public/v1/version")) .send() .await .unwrap(); @@ -185,7 +185,7 @@ async fn timezones_return_backend_catalog_when_supported() { let response = harness .client - .get(harness.url("/api/v1/timezones")) + .get(harness.url("/gvm/public/v1/timezones")) .bearer_auth(&token) .send() .await @@ -220,7 +220,7 @@ async fn timezones_return_501_when_backend_lacks_get_timezones() { let response = harness .client - .get(harness.url("/api/v1/timezones")) + .get(harness.url("/gvm/public/v1/timezones")) .bearer_auth(&token) .send() .await @@ -230,7 +230,10 @@ async fn timezones_return_501_when_backend_lacks_get_timezones() { let problem = response.json::().await.unwrap(); assert_eq!(problem["code"], serde_json::json!("not_implemented")); assert_eq!(problem["status"], serde_json::json!(501)); - assert_eq!(problem["instance"], serde_json::json!("/api/v1/timezones")); + assert_eq!( + problem["instance"], + serde_json::json!("/gvm/public/v1/timezones") + ); harness.shutdown().await; } @@ -273,7 +276,7 @@ async fn https_health_returns_200_and_hsts_in_native_tls_mode() { .danger_accept_invalid_certs(true) .build() .unwrap() - .get(format!("https://localhost:{port}/health")) + .get(format!("https://localhost:{port}/gvm/health")) .send() .await .unwrap(); @@ -330,7 +333,7 @@ async fn native_tls_slow_handshake_does_not_block_later_connections() { .danger_accept_invalid_certs(true) .build() .unwrap() - .get(format!("https://localhost:{port}/health")) + .get(format!("https://localhost:{port}/gvm/health")) .send(); let response = tokio::time::timeout(Duration::from_secs(1), request) .await @@ -413,7 +416,7 @@ async fn credential_store_capability_absence_keeps_following_credentials_route_u // authenticated GMP session for the immediately following credentials list. let client = Client::new(); let store_response = client - .get(format!("http://{addr}/api/v1/credential-stores")) + .get(format!("http://{addr}/gvm/public/v1/credential-stores")) .bearer_auth(&token) .send() .await @@ -423,7 +426,9 @@ async fn credential_store_capability_absence_keeps_following_credentials_route_u assert_eq!(store_problem["code"], serde_json::json!("not_implemented")); let credential_response = client - .get(format!("http://{addr}/api/v1/credentials?perPage=1000")) + .get(format!( + "http://{addr}/gvm/public/v1/credentials?perPage=1000" + )) .bearer_auth(&token) .send() .await @@ -448,7 +453,7 @@ fn spawn_target_request( let addr = harness.addr; tokio::spawn(async move { client - .get(format!("http://{addr}/api/v1/targets")) + .get(format!("http://{addr}/gvm/public/v1/targets")) .bearer_auth(token) .send() .await diff --git a/crates/gvm-gateway/tests/targets.rs b/crates/gvm-gateway/tests/targets.rs index c040835a..41a680e8 100644 --- a/crates/gvm-gateway/tests/targets.rs +++ b/crates/gvm-gateway/tests/targets.rs @@ -221,7 +221,7 @@ async fn create_target() { let json = response.json::().await.unwrap(); let id = json["id"].as_str().unwrap(); assert!(Uuid::parse_str(id).is_ok()); - assert_eq!(location, format!("/api/v1/targets/{id}")); + assert_eq!(location, format!("/gvm/public/v1/targets/{id}")); assert!(harness .server .command_history() @@ -398,7 +398,7 @@ async fn update_target_response_includes_credential_refs() { let response = harness .client .put(format!( - "http://{}/api/v1/targets/{target_id}", + "http://{}/gvm/public/v1/targets/{target_id}", harness.addr )) .bearer_auth(&harness.token) @@ -460,7 +460,7 @@ async fn update_target_accepts_reverse_lookup_flags() { let response = harness .client .put(format!( - "http://{}/api/v1/targets/{target_id}", + "http://{}/gvm/public/v1/targets/{target_id}", harness.addr )) .bearer_auth(&harness.token) @@ -521,7 +521,7 @@ async fn method_not_allowed() { let response = harness .client - .patch(harness.url("/api/v1/targets")) + .patch(harness.url("/gvm/public/v1/targets")) .bearer_auth(&harness.token) .send() .await @@ -559,7 +559,7 @@ async fn target_source_roundtrip_defaults_partial_updates_and_clone() { harness.server.clear_history(); let response = harness .client - .post(harness.url(&format!("/api/v1/targets/{id}/clone"))) + .post(harness.url(&format!("/gvm/public/v1/targets/{id}/clone"))) .bearer_auth(&harness.token) .send() .await diff --git a/crates/gvm-gateway/tests/task_observers.rs b/crates/gvm-gateway/tests/task_observers.rs index 96a93c5b..cf7e2a12 100644 --- a/crates/gvm-gateway/tests/task_observers.rs +++ b/crates/gvm-gateway/tests/task_observers.rs @@ -29,7 +29,7 @@ async fn assert_observer_update( store.create(task); }) .await; - let url = harness.url(&format!("/api/v1/{collection}/{id}")); + let url = harness.url(&format!("/gvm/public/v1/{collection}/{id}")); let response = harness .client .put(&url) diff --git a/docs/README.md b/docs/README.md index cd1c18fc..b8f44c19 100644 --- a/docs/README.md +++ b/docs/README.md @@ -12,7 +12,7 @@ as an equally authoritative description of the running service. reference, migration notes, and executable examples shipped with releases. - [Human-readable REST API reference](user/api-reference.md) — authentication, common semantics, and a complete route-family map for the current REST API. -- [Runtime API documentation](http://127.0.0.1:8080/api/v1/docs) — Redoc served +- [Runtime API documentation](http://127.0.0.1:8080/gvm/public/v1/docs) — Redoc served by a locally running gateway. - [Curated OpenAPI root](../spec/rest-api/openapi.yaml) — the normative, release-aligned REST contract. @@ -57,7 +57,7 @@ current design, but they are not implementation instructions or API contracts. When documents disagree, use this order: 1. executable runtime behavior and contract tests; -2. `spec/rest-api/` and the runtime-generated `/api/v1/openapi.json` document; +2. `spec/rest-api/` and the runtime-generated `/gvm/public/v1/openapi.json` document; 3. `gateway-architecture.md` and accepted decision records; 4. developer and user guides; 5. archived material. diff --git a/docs/development.md b/docs/development.md index d675b732..ecb330e9 100644 --- a/docs/development.md +++ b/docs/development.md @@ -38,7 +38,7 @@ Use the following order when locating or changing behavior: behavior: routes, methods, parameters, schemas, status codes, headers, and semantics. 2. `crates/gvm-gateway-rest/src/router.rs` is the runtime route inventory. - Its generated OpenAPI is served at `/api/v1/openapi.json` and contract-tested + Its generated OpenAPI is served at `/gvm/public/v1/openapi.json` and contract-tested against the curated specification. 3. [`gateway-architecture.md`](gateway-architecture.md) defines component, session, and connection ownership. @@ -148,9 +148,9 @@ client library. Persistent sessions and request-scoped Basic authentication share the same backend execution path: -- `POST /api/v1/session` authenticates with Basic credentials and returns an +- `POST /gvm/public/v1/session` authenticates with Basic credentials and returns an opaque bearer token. -- `GET` and `DELETE /api/v1/session` operate on the current bearer session. +- `GET` and `DELETE /gvm/public/v1/session` operate on the current bearer session. - Protected resource routes also accept Basic credentials for one request; the temporary backend context is removed before the response completes. - One persistent token owns one authenticated gvmd connection. Operations on diff --git a/docs/gmp-rest-translation.md b/docs/gmp-rest-translation.md index b608dce6..002ea730 100644 --- a/docs/gmp-rest-translation.md +++ b/docs/gmp-rest-translation.md @@ -356,14 +356,14 @@ and | REST operation | GMP operation | REST result | | --- | --- | --- | -| `GET /api/v1/targets` | `get_targets` | `200` JSON page with normalized targets and pagination | -| `POST /api/v1/targets` | `create_target` | `201` JSON containing the new ID plus `Location` | -| `GET /api/v1/targets/{id}` | filtered/single `get_targets` | `200` JSON target or `404` Problem Details | -| `PUT /api/v1/targets/{id}` | `modify_target`, then a read-back when needed | `200` JSON representation | -| `DELETE /api/v1/targets/{id}` | `delete_target` with trash/permanent semantics | `204` on success | -| `POST /api/v1/tasks/{id}/start` | `start_task` | `200` JSON action result containing `reportId` | -| `POST /api/v1/reports?taskId={taskId}&inAssets={bool}` | typed `ImportReportRequest` / `import_report` | `201` JSON containing the new report ID plus canonical `Location` | -| `POST /api/v1/reports/{id}/exports` | report retrieval/export operations | `202` plus a pollable job URI | +| `GET /gvm/public/v1/targets` | `get_targets` | `200` JSON page with normalized targets and pagination | +| `POST /gvm/public/v1/targets` | `create_target` | `201` JSON containing the new ID plus `Location` | +| `GET /gvm/public/v1/targets/{id}` | filtered/single `get_targets` | `200` JSON target or `404` Problem Details | +| `PUT /gvm/public/v1/targets/{id}` | `modify_target`, then a read-back when needed | `200` JSON representation | +| `DELETE /gvm/public/v1/targets/{id}` | `delete_target` with trash/permanent semantics | `204` on success | +| `POST /gvm/public/v1/tasks/{id}/start` | `start_task` | `200` JSON action result containing `reportId` | +| `POST /gvm/public/v1/reports?taskId={taskId}&inAssets={bool}` | typed `ImportReportRequest` / `import_report` | `201` JSON containing the new report ID plus canonical `Location` | +| `POST /gvm/public/v1/reports/{id}/exports` | report retrieval/export operations | `202` plus a pollable job URI | The table describes translation intent; the OpenAPI files remain authoritative for exact request fields, responses, and supported operations. @@ -422,10 +422,10 @@ remain bounded and safe. The REST gateway exposes a resource lifecycle for sessions: -- `POST /api/v1/session` authenticates with HTTP Basic credentials and returns +- `POST /gvm/public/v1/session` authenticates with HTTP Basic credentials and returns an opaque bearer token; -- `GET /api/v1/session` inspects the current gateway session; and -- `DELETE /api/v1/session` tears it down. +- `GET /gvm/public/v1/session` inspects the current gateway session; and +- `DELETE /gvm/public/v1/session` tears it down. Unlike GSAD's default per-request gvmd reconnection, a persistent gateway session owns a live authenticated backend client. Requests sharing that session @@ -542,9 +542,9 @@ prevents a harmless-looking REST omission from clearing backend state. ### 7.2 Complete the specialized-task lifecycle -`POST /api/v1/tasks` and task responses already recognize classic, +`POST /gvm/public/v1/tasks` and task responses already recognize classic, agent-group, OCI-image, web-application, and import tasks. `PUT -/api/v1/tasks/{id}`, however, exposes only the classic target, scan-config, and +/gvm/public/v1/tasks/{id}`, however, exposes only the classic target, scan-config, and scanner relationships. GSA and GSAD contain separate save flows for the other task variants, all implemented as variant-specific `modify_task` payloads. @@ -567,7 +567,7 @@ reproducing GSAD's sentinel conventions. GSA can render a report relative to another report by passing `delta_report_id` to `get_reports`. The reviewed GSAD snapshot also exposes the newer `export_delta_scan_report` command. The current -`POST /api/v1/reports/{id}/exports` job request supports report formats, +`POST /gvm/public/v1/reports/{id}/exports` job request supports report formats, report configs, and filters, but it has no comparison-report input. The issue #588 release baseline now provides typed, help-discovery-gated report export lifecycle and delta-export requests. Typed upstream availability alone @@ -674,7 +674,7 @@ Factor their guarantees into a common artifact policy: predictable in-memory handling. Report import is modeled as bounded report collection creation: -`POST /api/v1/reports` accepts an `application/xml` body up to 10 MiB, relates +`POST /gvm/public/v1/reports` accepts an `application/xml` body up to 10 MiB, relates it to an existing import task through `taskId`, and preserves optional `inAssets` omission. The gateway rejects invalid media type, UUID, empty body, and excessive size while treating the XML bytes as opaque. Exact one-report diff --git a/docs/ticket-surface-scope.md b/docs/ticket-surface-scope.md index f15ce6ab..e1535192 100644 --- a/docs/ticket-surface-scope.md +++ b/docs/ticket-surface-scope.md @@ -23,7 +23,7 @@ its existing ticket command and response support for direct GMP consumers. `rust-gvm-api` exposes no GMP ticket support: -- `GET /api/v1/tickets` and `GET /api/v1/tickets/{id}` are not published routes. +- `GET /gvm/public/v1/tickets` and `GET /gvm/public/v1/tickets/{id}` are not published routes. - Ticket-specific contracts, domain types, application ports, outgoing-adapter behavior, and positive gateway tests are not maintained. - `rust-gvm-api` will not add ticket discovery, create, clone, update, or delete diff --git a/docs/user/api-reference.md b/docs/user/api-reference.md index e4216803..91f2ebb0 100644 --- a/docs/user/api-reference.md +++ b/docs/user/api-reference.md @@ -3,7 +3,7 @@ This is the human-readable map of the REST API shipped by `rust-gvm-api` 0.7.0. It explains common behavior and shows every current route family. For exact request and response schemas, use the OpenAPI document shipped with the -same release or the running gateway's `GET /api/v1/openapi.json` endpoint. +same release or the running gateway's `GET /gvm/public/v1/openapi.json` endpoint. The normative contract is [`spec/rest-api`](https://github.com/greenbone-hive/rust-gvm-api/tree/main/spec/rest-api) @@ -13,13 +13,20 @@ alignment. The current contract contains 125 paths and 203 operations. ## Base paths and documentation -- Versioned API: `/api/v1` -- Liveness: `GET /health` -- Readiness: `GET /ready` -- Runtime OpenAPI: `GET /api/v1/openapi.json` -- Browser documentation: `GET /api/v1/docs` +- Versioned API: `/gvm/public/v1` +- Liveness: `GET /gvm/health` +- Readiness: `GET /gvm/ready` +- Runtime OpenAPI: `GET /gvm/public/v1/openapi.json` +- Browser documentation: `GET /gvm/public/v1/docs` -`/health` and `/ready` are intentionally unversioned. The browser documentation +The default API base path is `/gvm/public/`. Liveness and readiness are +unversioned HTTP endpoints implemented by the gateway application, also when +running outside a container. `/gvm/health` reports process liveness; `/gvm/ready` checks +backend readiness and returns `503` during shutdown or when not ready. Container +or orchestration probes can call these endpoints; their service-level paths stay outside +the versioned public API prefix. The former `/api/v1` prefix is no longer served. + +`/gvm/health` and `/gvm/ready` are intentionally unversioned. The browser documentation route is an operational UI and is not itself part of the OpenAPI contract. ## Authentication @@ -29,7 +36,7 @@ The gateway supports two authentication modes: 1. Create a persistent session with Basic credentials: ```http - POST /api/v1/session + POST /gvm/public/v1/session Authorization: Basic ``` @@ -43,7 +50,7 @@ The gateway supports two authentication modes: gateway creates a backend context for that request and removes it before returning. -`GET /api/v1/session` and `DELETE /api/v1/session` operate on an existing +`GET /gvm/public/v1/session` and `DELETE /gvm/public/v1/session` operate on an existing bearer session. Health, readiness, version, OpenAPI, and browser documentation are public. Unless a route is explicitly public, assume that it requires Bearer or request-scoped Basic authentication. @@ -62,7 +69,7 @@ preference name, or family name. Request objects reject unknown fields. Report import is the main non-JSON exception: ```http -POST /api/v1/reports?taskId=&inAssets=true +POST /gvm/public/v1/reports?taskId=&inAssets=true Content-Type: application/xml ``` @@ -123,7 +130,7 @@ Errors use RFC 9457 `application/problem+json`: "title": "Resource Not Found", "status": 404, "detail": "The requested resource was not found.", - "instance": "/api/v1/targets/550e8400-e29b-41d4-a716-446655440000" + "instance": "/gvm/public/v1/targets/550e8400-e29b-41d4-a716-446655440000" } ``` @@ -154,14 +161,14 @@ return `traceparent` and, when present, `tracestate`; `baggage` is not echoed. ## Route map Methods below are the methods currently published for each path. All paths in -the tables are relative to `/api/v1` except `/health` and `/ready`. +the tables are relative to `/gvm/public/v1` except `/gvm/health` and `/gvm/ready`. ### System and sessions | Methods | Path | Purpose | | --- | --- | --- | -| `GET` | `/health` | Unversioned process liveness | -| `GET` | `/ready` | Unversioned backend readiness | +| `GET` | `/gvm/health` | Unversioned process liveness | +| `GET` | `/gvm/ready` | Unversioned backend readiness | | `GET` | `/version` | REST package/API version and backend GMP version | | `GET` | `/timezones` | Backend timezone catalog | | `GET` | `/openapi.json` | Runtime-generated OpenAPI contract | diff --git a/docs/user/examples.md b/docs/user/examples.md index cd7ff227..3d5935f8 100644 --- a/docs/user/examples.md +++ b/docs/user/examples.md @@ -99,7 +99,7 @@ SESSION_JSON="$( -u "${GVM_GATEWAY_USERNAME}:${GVM_GATEWAY_PASSWORD}" \ -H 'Accept: application/json' \ -X POST \ - "${GVM_GATEWAY_BASE_URL}/api/v1/session" + "${GVM_GATEWAY_BASE_URL}/gvm/public/v1/session" )" SESSION_TOKEN="$(printf '%s' "${SESSION_JSON}" | jq -r '.sessionToken')" @@ -117,10 +117,10 @@ Expected fields include: Check that the service is healthy and learn the exposed gateway version: ```bash -curl -fsS "${GVM_GATEWAY_BASE_URL}/ready" | jq +curl -fsS "${GVM_GATEWAY_BASE_URL}/gvm/ready" | jq curl -fsS \ -H "Authorization: Bearer ${SESSION_TOKEN}" \ - "${GVM_GATEWAY_BASE_URL}/api/v1/version" | jq + "${GVM_GATEWAY_BASE_URL}/gvm/public/v1/version" | jq ``` ## 3. Discover supporting resources @@ -131,15 +131,15 @@ targets and tasks: ```bash curl -fsS \ -H "Authorization: Bearer ${SESSION_TOKEN}" \ - "${GVM_GATEWAY_BASE_URL}/api/v1/scanners?perPage=100" | jq '.data[] | {id, name}' + "${GVM_GATEWAY_BASE_URL}/gvm/public/v1/scanners?perPage=100" | jq '.data[] | {id, name}' curl -fsS \ -H "Authorization: Bearer ${SESSION_TOKEN}" \ - "${GVM_GATEWAY_BASE_URL}/api/v1/scan-configs?perPage=100" | jq '.data[] | {id, name}' + "${GVM_GATEWAY_BASE_URL}/gvm/public/v1/scan-configs?perPage=100" | jq '.data[] | {id, name}' curl -fsS \ -H "Authorization: Bearer ${SESSION_TOKEN}" \ - "${GVM_GATEWAY_BASE_URL}/api/v1/port-lists?perPage=100" | jq '.data[] | {id, name}' + "${GVM_GATEWAY_BASE_URL}/gvm/public/v1/port-lists?perPage=100" | jq '.data[] | {id, name}' ``` Use the returned IDs in the later create calls. @@ -162,7 +162,7 @@ TARGET_JSON="$( "aliveTest": "Consider Alive", "portListId": "'"${PORT_LIST_ID}"'" }' \ - "${GVM_GATEWAY_BASE_URL}/api/v1/targets" + "${GVM_GATEWAY_BASE_URL}/gvm/public/v1/targets" )" TARGET_ID="$(printf '%s' "${TARGET_JSON}" | jq -r '.id')" @@ -188,7 +188,7 @@ TASK_JSON="$( "scanConfigId": "'"${SCAN_CONFIG_ID}"'", "scannerId": "'"${SCANNER_ID}"'" }' \ - "${GVM_GATEWAY_BASE_URL}/api/v1/tasks" + "${GVM_GATEWAY_BASE_URL}/gvm/public/v1/tasks" )" TASK_ID="$(printf '%s' "${TASK_JSON}" | jq -r '.id')" @@ -201,14 +201,14 @@ printf '%s\n' "${TASK_JSON}" | jq curl -fsS \ -H "Authorization: Bearer ${SESSION_TOKEN}" \ -X POST \ - "${GVM_GATEWAY_BASE_URL}/api/v1/tasks/${TASK_ID}/start" | jq + "${GVM_GATEWAY_BASE_URL}/gvm/public/v1/tasks/${TASK_ID}/start" | jq curl -fsS \ -H "Authorization: Bearer ${SESSION_TOKEN}" \ - "${GVM_GATEWAY_BASE_URL}/api/v1/tasks/${TASK_ID}" | jq + "${GVM_GATEWAY_BASE_URL}/gvm/public/v1/tasks/${TASK_ID}" | jq ``` -For longer-running automation, poll `GET /api/v1/tasks/{id}` until the task +For longer-running automation, poll `GET /gvm/public/v1/tasks/{id}` until the task reaches a terminal backend status such as `Done`, `Stopped`, or `Error`. ## 7. Find reports for the task @@ -216,7 +216,7 @@ reaches a terminal backend status such as `Done`, `Stopped`, or `Error`. ```bash curl -fsS \ -H "Authorization: Bearer ${SESSION_TOKEN}" \ - "${GVM_GATEWAY_BASE_URL}/api/v1/reports?filter=task_id=${TASK_ID}&perPage=25" | jq '.data[] | {id, reportFormat, task}' + "${GVM_GATEWAY_BASE_URL}/gvm/public/v1/reports?filter=task_id=${TASK_ID}&perPage=25" | jq '.data[] | {id, reportFormat, task}' ``` Pick the report ID you want to inspect or export. @@ -243,7 +243,7 @@ EXPORT_JSON="$( -d '{ "reportFormatId": "'"${PDF_REPORT_FORMAT_ID}"'" }' \ - "${GVM_GATEWAY_BASE_URL}/api/v1/reports/${REPORT_ID}/exports" + "${GVM_GATEWAY_BASE_URL}/gvm/public/v1/reports/${REPORT_ID}/exports" )" JOB_ID="$(printf '%s' "${EXPORT_JSON}" | jq -r '.jobId')" @@ -256,11 +256,11 @@ Poll the job, then download the finished artifact: ```bash curl -fsS \ -H "Authorization: Bearer ${SESSION_TOKEN}" \ - "${GVM_GATEWAY_BASE_URL}/api/v1/jobs/${JOB_ID}" | jq + "${GVM_GATEWAY_BASE_URL}/gvm/public/v1/jobs/${JOB_ID}" | jq curl -fSLo "report-${REPORT_ID}.pdf" \ -H "Authorization: Bearer ${SESSION_TOKEN}" \ - "${GVM_GATEWAY_BASE_URL}/api/v1/jobs/${JOB_ID}/result" + "${GVM_GATEWAY_BASE_URL}/gvm/public/v1/jobs/${JOB_ID}/result" ``` ## 9. Close the session @@ -269,7 +269,7 @@ curl -fSLo "report-${REPORT_ID}.pdf" \ curl -fsS \ -H "Authorization: Bearer ${SESSION_TOKEN}" \ -X DELETE \ - "${GVM_GATEWAY_BASE_URL}/api/v1/session" + "${GVM_GATEWAY_BASE_URL}/gvm/public/v1/session" ``` ## Finding the formal contract diff --git a/docs/user/examples/import-users.sh b/docs/user/examples/import-users.sh index 8cb78574..9e7f96db 100755 --- a/docs/user/examples/import-users.sh +++ b/docs/user/examples/import-users.sh @@ -66,7 +66,7 @@ create_session() { -u "${USERNAME}:${PASSWORD}" \ -H 'Accept: application/json' \ -X POST \ - "${BASE_URL}/api/v1/session" + "${BASE_URL}/gvm/public/v1/session" } delete_session() { @@ -74,7 +74,7 @@ delete_session() { curl -fsS \ -H "Authorization: Bearer ${SESSION_TOKEN}" \ -X DELETE \ - "${BASE_URL}/api/v1/session" >/dev/null || true + "${BASE_URL}/gvm/public/v1/session" >/dev/null || true fi } @@ -171,7 +171,7 @@ fetch_collection() { while (( page <= total_pages )); do page_file="$(printf '%s/%s-page-%05d.json' "${TMP_DIR}" "${resource}" "${page}")" - api_get "/api/v1/${resource}?page=${page}&perPage=${per_page}" > "${page_file}" + api_get "/gvm/public/v1/${resource}?page=${page}&perPage=${per_page}" > "${page_file}" if (( page == 1 )); then total_pages="$(jq -r '.pagination.totalPages // 1' "${page_file}")" @@ -297,14 +297,14 @@ while IFS=$'\t' read -r LOGIN ROLE_NAMES; do authenticationType: "file" }' )" - CREATED_JSON="$(api_post_json '/api/v1/users' "${BODY}")" + CREATED_JSON="$(api_post_json '/gvm/public/v1/users' "${BODY}")" CREATED_ID="$(printf '%s' "${CREATED_JSON}" | jq -er '.id')" created_count=$((created_count + 1)) echo "created user ${LOGIN} (${CREATED_ID}) password=${GENERATED_PASSWORD}" else USER_ID="$(printf '%s' "${EXISTING_USER}" | jq -er '.id')" BODY="$(jq -n --argjson roles "${ROLE_IDS}" '{roles: $roles}')" - api_put_json "/api/v1/users/${USER_ID}" "${BODY}" >/dev/null + api_put_json "/gvm/public/v1/users/${USER_ID}" "${BODY}" >/dev/null updated_count=$((updated_count + 1)) echo "updated user ${LOGIN} (${USER_ID})" fi diff --git a/docs/user/examples/jiracloud/README.md b/docs/user/examples/jiracloud/README.md index e75d7bab..f8662caf 100644 --- a/docs/user/examples/jiracloud/README.md +++ b/docs/user/examples/jiracloud/README.md @@ -29,7 +29,7 @@ Set these groups of values: `JIRA_CLOSED_STATUS_CATEGORIES`, and `JIRA_REOPEN_TRANSITION_NAME`. - GVM report selection: `JIRA_LOOKBACK_HOURS` and `JIRA_MIN_SEVERITY`. -`GVM_GATEWAY_BASE_URL` is the gateway root URL without `/api/v1`, for example: +`GVM_GATEWAY_BASE_URL` is the gateway root URL without `/gvm/public/v1`, for example: ```text GVM_GATEWAY_BASE_URL=http://127.0.0.1:8080 @@ -46,10 +46,10 @@ JIRA_SITE_URL=https://example.atlassian.net The GVM user configured in `.env` must be able to create sessions and read the data being synchronized: -- `POST /api/v1/session` -- `DELETE /api/v1/session` -- `GET /api/v1/reports` -- `GET /api/v1/reports/{id}/results` +- `POST /gvm/public/v1/session` +- `DELETE /gvm/public/v1/session` +- `GET /gvm/public/v1/reports` +- `GET /gvm/public/v1/reports/{id}/results` The script fetches reports visible to that GVM user. It does not bypass GVM permissions. @@ -113,7 +113,7 @@ uv run python -m unittest The script reads reports started in the configured lookback window: ```text -GET /api/v1/reports?filter=scan_start>{cutoff_utc}&perPage=1000 +GET /gvm/public/v1/reports?filter=scan_start>{cutoff_utc}&perPage=1000 ``` It reads all pages, fetches results for each selected report, and keeps only diff --git a/docs/user/examples/jiracloud/SPEC.md b/docs/user/examples/jiracloud/SPEC.md index 6e067b49..33f62eef 100644 --- a/docs/user/examples/jiracloud/SPEC.md +++ b/docs/user/examples/jiracloud/SPEC.md @@ -57,37 +57,37 @@ The `.env` file contains: ## GVM Data Flow -Use the versioned GVM REST API base path `/api/v1`. +Use the versioned GVM REST API base path `/gvm/public/v1`. -1. Create a GVM session with `POST /api/v1/session` using HTTP Basic +1. Create a GVM session with `POST /gvm/public/v1/session` using HTTP Basic credentials. 2. Use the returned `sessionToken` as `Authorization: Bearer ` for all subsequent GVM requests. -3. Fetch reports with `GET /api/v1/reports`. +3. Fetch reports with `GET /gvm/public/v1/reports`. - Select reports whose public `scanStart` is within the configured lookback window. The default is the last 24 hours. - Compute a UTC cutoff timestamp at runtime: `now_utc - lookback`. - Use the report filter `scan_start>{cutoff_utc}`, where `{cutoff_utc}` is an RFC 3339 timestamp, for example `scan_start>2026-07-01T10:00:00Z`. - Request shape: - `GET /api/v1/reports?filter=scan_start>{cutoff_utc}&perPage=1000`. + `GET /gvm/public/v1/reports?filter=scan_start>{cutoff_utc}&perPage=1000`. - Read all pages. - After fetching reports, still check each returned report's `scanStart` client-side and ignore reports outside the configured window. 4. For each selected report, fetch results with - `GET /api/v1/reports/{id}/results`. + `GET /gvm/public/v1/reports/{id}/results`. - Read all pages. - Keep only results with `severity > JIRA_MIN_SEVERITY`. - Default `JIRA_MIN_SEVERITY` to `4.0`, matching the OTOBO example. - Ignore findings with severity less than or equal to `4.0`. -5. Close the GVM session with `DELETE /api/v1/session` when the run finishes. +5. Close the GVM session with `DELETE /gvm/public/v1/session` when the run finishes. -Use `GET /api/v1/reports/{id}/results` as the finding source. Do not use the -global `GET /api/v1/results` endpoint for this example. Do not use -`GET /api/v1/reports/{id}/vulnerabilities`, because the OpenAPI spec allows it +Use `GET /gvm/public/v1/reports/{id}/results` as the finding source. Do not use the +global `GET /gvm/public/v1/results` endpoint for this example. Do not use +`GET /gvm/public/v1/reports/{id}/vulnerabilities`, because the OpenAPI spec allows it to return `501 Not Implemented`. -Do not fetch `GET /api/v1/hosts` in this example. Jira Cloud issue creation does +Do not fetch `GET /gvm/public/v1/hosts` in this example. Jira Cloud issue creation does not need host inventory synchronization when there is no CMDB or Jira Assets integration. diff --git a/docs/user/examples/jiracloud/gateway.py b/docs/user/examples/jiracloud/gateway.py index fb46ec70..53a15921 100644 --- a/docs/user/examples/jiracloud/gateway.py +++ b/docs/user/examples/jiracloud/gateway.py @@ -22,7 +22,7 @@ def create_session(self) -> None: self.url("session"), basic_auth=(self.config.gvm_username, self.config.gvm_password), expected_statuses=(201,), - context="GVM create session POST /api/v1/session", + context="GVM create session POST /gvm/public/v1/session", ) token = response.get("sessionToken") if not isinstance(token, str) or not token: @@ -37,7 +37,7 @@ def close_session(self) -> None: self.url("session"), headers=self.auth_headers(), expected_statuses=(204,), - context="GVM close session DELETE /api/v1/session", + context="GVM close session DELETE /gvm/public/v1/session", ) self.session_token = None @@ -46,7 +46,7 @@ def get_recent_reports(self, now_utc: datetime) -> list[dict[str, Any]]: cutoff_text = format_rfc3339(cutoff) reports = self.get_paginated( "reports", - "GVM GET /api/v1/reports", + "GVM GET /gvm/public/v1/reports", {"filter": f"scan_start>{cutoff_text}"}, ) selected = [] @@ -61,7 +61,7 @@ def get_recent_reports(self, now_utc: datetime) -> list[dict[str, Any]]: def get_report_results(self, report_id: str) -> list[dict[str, Any]]: results = self.get_paginated( f"reports/{parse.quote(report_id, safe='')}/results", - f"GVM GET /api/v1/reports/{report_id}/results", + f"GVM GET /gvm/public/v1/reports/{report_id}/results", ) return [result for result in results if result_severity(result) > self.config.jira_min_severity] @@ -108,7 +108,7 @@ def auth_headers(self) -> dict[str, str]: return {"Authorization": f"Bearer {self.session_token}"} def url(self, path: str, params: dict[str, str] | None = None) -> str: - url = f"{self.config.gvm_gateway_base_url}/api/v1/{path.lstrip('/')}" + url = f"{self.config.gvm_gateway_base_url}/gvm/public/v1/{path.lstrip('/')}" if params: url = f"{url}?{parse.urlencode(params)}" return url diff --git a/docs/user/examples/jiracloud/test_main.py b/docs/user/examples/jiracloud/test_main.py index 90648690..e13172b3 100644 --- a/docs/user/examples/jiracloud/test_main.py +++ b/docs/user/examples/jiracloud/test_main.py @@ -190,8 +190,8 @@ def test_config_load_applies_jira_defaults(self) -> None: def test_config_load_rejects_versioned_urls(self) -> None: """Users configure service roots; the clients append API paths internally.""" - with self.assertRaisesRegex(utils.IntegrationError, "must not include /api/v1"): - utils.Config.load(write_env(self, base_env(GVM_GATEWAY_BASE_URL="http://gvm.example/api/v1"))) + with self.assertRaisesRegex(utils.IntegrationError, "must not include /gvm/public/v1"): + utils.Config.load(write_env(self, base_env(GVM_GATEWAY_BASE_URL="http://gvm.example/gvm/public/v1"))) with self.assertRaisesRegex(utils.IntegrationError, "must not include /rest/api/3"): utils.Config.load(write_env(self, base_env(JIRA_SITE_URL="https://jira.example/rest/api/3"))) diff --git a/docs/user/examples/jiracloud/utils.py b/docs/user/examples/jiracloud/utils.py index 5b2ba6a4..c6bdeae3 100644 --- a/docs/user/examples/jiracloud/utils.py +++ b/docs/user/examples/jiracloud/utils.py @@ -46,8 +46,8 @@ def load(cls, env_path: Path) -> Config: raise IntegrationError(f"Missing required configuration value(s): {joined}. Check {env_path}.") gvm_gateway_base_url = values["GVM_GATEWAY_BASE_URL"].rstrip("/") - if gvm_gateway_base_url.endswith("/api/v1"): - raise IntegrationError("GVM_GATEWAY_BASE_URL must not include /api/v1; use the gateway root URL.") + if gvm_gateway_base_url.endswith("/gvm/public/v1"): + raise IntegrationError("GVM_GATEWAY_BASE_URL must not include /gvm/public/v1; use the gateway root URL.") validate_http_url(gvm_gateway_base_url, "GVM_GATEWAY_BASE_URL") jira_site_url = values["JIRA_SITE_URL"].rstrip("/") diff --git a/docs/user/examples/otobo/README.md b/docs/user/examples/otobo/README.md index a5047134..c9f7b585 100644 --- a/docs/user/examples/otobo/README.md +++ b/docs/user/examples/otobo/README.md @@ -30,24 +30,24 @@ Set these groups of values: - CMDB mapping: class, deployment state, incident state, and config item attribute names. -`GVM_GATEWAY_BASE_URL` is the gateway root URL without `/api/v1`, for example: +`GVM_GATEWAY_BASE_URL` is the gateway root URL without `/gvm/public/v1`, for example: ```text GVM_GATEWAY_BASE_URL=http://127.0.0.1:8080 ``` -The script appends `/api/v1` internally. +The script appends `/gvm/public/v1` internally. ## 2. Prepare GVM Access The GVM user configured in `.env` must be able to create sessions and read the data being synchronized: -- `POST /api/v1/session` -- `DELETE /api/v1/session` -- `GET /api/v1/hosts` -- `GET /api/v1/reports` -- `GET /api/v1/reports/{id}/results` +- `POST /gvm/public/v1/session` +- `DELETE /gvm/public/v1/session` +- `GET /gvm/public/v1/hosts` +- `GET /gvm/public/v1/reports` +- `GET /gvm/public/v1/reports/{id}/results` The script fetches reports visible to that GVM user. It does not bypass GVM permissions. @@ -162,7 +162,7 @@ uv run python -m unittest The script reads reports started in the last 24 hours: ```text -GET /api/v1/reports?filter=scan_start>{cutoff_utc}&perPage=1000 +GET /gvm/public/v1/reports?filter=scan_start>{cutoff_utc}&perPage=1000 ``` It reads all pages, fetches results for each selected report, and keeps only @@ -177,7 +177,7 @@ nvt_oid|result.host|result.port `result.port` is treated as an opaque value. If a severity-eligible result is missing `nvt.oid`, `host`, or `port`, the script stops with an error. -If a finding host is not available in `GET /api/v1/hosts` yet, the ticket is +If a finding host is not available in `GET /gvm/public/v1/hosts` yet, the ticket is created or updated without a CMDB link. A later run adds the link once the host asset appears. diff --git a/docs/user/examples/otobo/SPEC.md b/docs/user/examples/otobo/SPEC.md index d5316246..0c7b8b65 100644 --- a/docs/user/examples/otobo/SPEC.md +++ b/docs/user/examples/otobo/SPEC.md @@ -31,36 +31,36 @@ The `.env` file contains: ## GVM Data Flow -Use the versioned GVM REST API base path `/api/v1`. +Use the versioned GVM REST API base path `/gvm/public/v1`. -1. Create a GVM session with `POST /api/v1/session` using HTTP Basic +1. Create a GVM session with `POST /gvm/public/v1/session` using HTTP Basic credentials. 2. Use the returned `sessionToken` as `Authorization: Bearer ` for all subsequent GVM requests. -3. Fetch discovered hosts/assets with `GET /api/v1/hosts`. +3. Fetch discovered hosts/assets with `GET /gvm/public/v1/hosts`. - Use host `id`, `name`, `hostname`, and `os` for OTOBO CMDB synchronization. - Optionally use host `ip` when the configured OTOBO CMDB class exposes a top-level IP address Dynamic Field. - Read all pages. -4. Fetch reports with `GET /api/v1/reports`. +4. Fetch reports with `GET /gvm/public/v1/reports`. - Select reports whose public `scanStart` is within the last 24 hours. - Compute a UTC cutoff timestamp at runtime: `now_utc - 24 hours`. - Use the report filter `scan_start>{cutoff_utc}`, where `{cutoff_utc}` is an RFC 3339 timestamp, for example `scan_start>2026-07-01T10:00:00Z`. - - Request shape: `GET /api/v1/reports?filter=scan_start>{cutoff_utc}&perPage=1000`. + - Request shape: `GET /gvm/public/v1/reports?filter=scan_start>{cutoff_utc}&perPage=1000`. - Read all pages. - After fetching reports, still check each returned report's `scanStart` client-side and ignore reports outside the 24-hour window. 5. For each selected report, fetch results with - `GET /api/v1/reports/{id}/results`. + `GET /gvm/public/v1/reports/{id}/results`. - Read all pages. - Keep only results with `severity > 4.0`. -6. Close the GVM session with `DELETE /api/v1/session` when the run finishes. +6. Close the GVM session with `DELETE /gvm/public/v1/session` when the run finishes. -Use `GET /api/v1/reports/{id}/results` as the finding source. Do not use the -global `GET /api/v1/results` endpoint for this example. Do not use -`GET /api/v1/reports/{id}/vulnerabilities`, because the OpenAPI spec allows it +Use `GET /gvm/public/v1/reports/{id}/results` as the finding source. Do not use the +global `GET /gvm/public/v1/results` endpoint for this example. Do not use +`GET /gvm/public/v1/reports/{id}/vulnerabilities`, because the OpenAPI spec allows it to return `501 Not Implemented`. ## Finding Aggregation @@ -114,7 +114,7 @@ Use direct per-request credentials in each OTOBO Generic Interface JSON payload. Include the configured OTOBO username and password as `UserLogin` and `Password` fields. Do not create an OTOBO session. -Do not use the GVM REST API `/api/v1/tickets` endpoints for OTOBO ticket +Do not use the GVM REST API `/gvm/public/v1/tickets` endpoints for OTOBO ticket operations. Those endpoints are part of the GVM ticket discovery surface, not the OTOBO Generic Interface. @@ -163,7 +163,7 @@ before running the example. Sync GVM hosts to OTOBO config items before processing findings: 1. Build an external CI key from the Greenbone host UUID returned by - `GET /api/v1/hosts`. + `GET /gvm/public/v1/hosts`. 2. Search for a config item by the configured class and external key attribute. 3. Upsert the config item with `ConfigItem::ConfigItemUpsert`. - If the search found an existing config item, pass its `ConfigItemID` to @@ -176,7 +176,7 @@ Sync GVM hosts to OTOBO config items before processing findings: 5. If a finding cannot be matched to a synchronized config item, still create or update the OTOBO ticket without a CMDB link and print a warning. This can happen while a scan is still completing and report results are visible before - the matching host asset appears in `GET /api/v1/hosts`. + the matching host asset appears in `GET /gvm/public/v1/hosts`. Config item upsert payloads must include the configured: diff --git a/docs/user/examples/otobo/gateway.py b/docs/user/examples/otobo/gateway.py index d86d94ef..b0fc8cbc 100644 --- a/docs/user/examples/otobo/gateway.py +++ b/docs/user/examples/otobo/gateway.py @@ -23,7 +23,7 @@ def create_session(self) -> None: self.url("session"), basic_auth=(self.config.gvm_username, self.config.gvm_password), expected_statuses=(201,), - context="GVM create session POST /api/v1/session", + context="GVM create session POST /gvm/public/v1/session", ) token = response.get("sessionToken") if not isinstance(token, str) or not token: @@ -38,19 +38,19 @@ def close_session(self) -> None: self.url("session"), headers=self.auth_headers(), expected_statuses=(204,), - context="GVM close session DELETE /api/v1/session", + context="GVM close session DELETE /gvm/public/v1/session", ) self.session_token = None def get_hosts(self) -> list[dict[str, Any]]: - return self.get_paginated("hosts", "GVM GET /api/v1/hosts") + return self.get_paginated("hosts", "GVM GET /gvm/public/v1/hosts") def get_recent_reports(self, now_utc: datetime) -> list[dict[str, Any]]: cutoff = now_utc - timedelta(hours=24) cutoff_text = format_rfc3339(cutoff) reports = self.get_paginated( "reports", - "GVM GET /api/v1/reports", + "GVM GET /gvm/public/v1/reports", {"filter": f"scan_start>{cutoff_text}"}, ) selected = [] @@ -65,7 +65,7 @@ def get_recent_reports(self, now_utc: datetime) -> list[dict[str, Any]]: def get_report_results(self, report_id: str) -> list[dict[str, Any]]: results = self.get_paginated( f"reports/{parse.quote(report_id, safe='')}/results", - f"GVM GET /api/v1/reports/{report_id}/results", + f"GVM GET /gvm/public/v1/reports/{report_id}/results", ) return [result for result in results if result_severity(result) > SEVERITY_THRESHOLD] @@ -112,7 +112,7 @@ def auth_headers(self) -> dict[str, str]: return {"Authorization": f"Bearer {self.session_token}"} def url(self, path: str, params: dict[str, str] | None = None) -> str: - url = f"{self.config.gvm_gateway_base_url}/api/v1/{path.lstrip('/')}" + url = f"{self.config.gvm_gateway_base_url}/gvm/public/v1/{path.lstrip('/')}" if params: url = f"{url}?{parse.urlencode(params)}" return url diff --git a/docs/user/examples/otobo/test_main.py b/docs/user/examples/otobo/test_main.py index c156a358..1da0dbbc 100644 --- a/docs/user/examples/otobo/test_main.py +++ b/docs/user/examples/otobo/test_main.py @@ -112,10 +112,10 @@ def test_config_load_trims_closed_states_for_reopen_matching(self) -> None: self.assertEqual(("closed successful", "closed unsuccessful"), config.closed_states) def test_config_load_rejects_gateway_base_url_with_versioned_api_path(self) -> None: - """Gateway env vars match shell examples, so /api/v1 is appended by the script.""" - path = write_env(self, base_env(GVM_GATEWAY_BASE_URL="http://gvm.example/api/v1")) + """Gateway env vars match shell examples, so /gvm/public/v1 is appended by the script.""" + path = write_env(self, base_env(GVM_GATEWAY_BASE_URL="http://gvm.example/gvm/public/v1")) - with self.assertRaisesRegex(utils.IntegrationError, "must not include /api/v1"): + with self.assertRaisesRegex(utils.IntegrationError, "must not include /gvm/public/v1"): utils.Config.load(path) def test_config_load_rejects_non_http_urls(self) -> None: @@ -160,8 +160,8 @@ def test_empty_otobo_http_error_names_url_and_troubleshooting_hint(self) -> None def test_non_empty_http_error_keeps_response_body(self) -> None: """When the server does explain the failure, preserve that detail in the error.""" message = utils.format_http_failure( - "GVM GET /api/v1/hosts page 1", - "http://gvm.example/api/v1/hosts?page=1&perPage=1000", + "GVM GET /gvm/public/v1/hosts page 1", + "http://gvm.example/gvm/public/v1/hosts?page=1&perPage=1000", 502, '{"detail":"backend unavailable"}', ) @@ -174,7 +174,7 @@ def test_request_timeout_is_reported_without_traceback(self) -> None: with mock.patch("requests.request", side_effect=requests.Timeout("timed out")): with self.assertRaisesRegex(utils.IntegrationError, "timed out after 1 seconds"): - client.request_json("GET", "http://gvm.example/api/v1/hosts", context="GVM hosts") + client.request_json("GET", "http://gvm.example/gvm/public/v1/hosts", context="GVM hosts") class GvmClientTests(IsolatedEnvTest): diff --git a/docs/user/examples/otobo/utils.py b/docs/user/examples/otobo/utils.py index 8a47dd20..eb67f8a3 100644 --- a/docs/user/examples/otobo/utils.py +++ b/docs/user/examples/otobo/utils.py @@ -60,8 +60,8 @@ def load(cls, env_path: Path) -> Config: raise IntegrationError(f"Missing required configuration value(s): {joined}. Check {env_path}.") gvm_gateway_base_url = values["GVM_GATEWAY_BASE_URL"].rstrip("/") - if gvm_gateway_base_url.endswith("/api/v1"): - raise IntegrationError("GVM_GATEWAY_BASE_URL must not include /api/v1; use the gateway root URL.") + if gvm_gateway_base_url.endswith("/gvm/public/v1"): + raise IntegrationError("GVM_GATEWAY_BASE_URL must not include /gvm/public/v1; use the gateway root URL.") validate_http_url(gvm_gateway_base_url, "GVM_GATEWAY_BASE_URL") otobo_base_url = values["OTOBO_BASE_URL"].rstrip("/") validate_http_url(otobo_base_url, "OTOBO_BASE_URL") diff --git a/docs/user/examples/scan-target.sh b/docs/user/examples/scan-target.sh index 8fd9973d..47d446aa 100755 --- a/docs/user/examples/scan-target.sh +++ b/docs/user/examples/scan-target.sh @@ -125,7 +125,7 @@ create_session() { -u "${USERNAME}:${PASSWORD}" \ -H 'Accept: application/json' \ -X POST \ - "${BASE_URL}/api/v1/session" + "${BASE_URL}/gvm/public/v1/session" } delete_session() { @@ -133,7 +133,7 @@ delete_session() { curl -fsS \ -H "Authorization: Bearer ${SESSION_TOKEN}" \ -X DELETE \ - "${BASE_URL}/api/v1/session" >/dev/null || true + "${BASE_URL}/gvm/public/v1/session" >/dev/null || true fi } @@ -150,7 +150,7 @@ wait_for_task_done() { local progress while (( $(date +%s) < deadline )); do - task_json="$(api_get "/api/v1/tasks/${task_id}")" + task_json="$(api_get "/gvm/public/v1/tasks/${task_id}")" status="$(printf '%s' "${task_json}" | jq -r '.status')" progress="$(printf '%s' "${task_json}" | jq -r '.progress // "unknown"')" echo "task ${task_id}: status=${status} progress=${progress}" >&2 @@ -186,7 +186,7 @@ fetch_all_report_results() { while (( page <= total_pages )); do page_file="$(printf '%s/results-page-%05d.json' "${RESULTS_TMP_DIR}" "${page}")" - api_get "/api/v1/reports/${report_id}/results?page=${page}&perPage=${per_page}" > "${page_file}" + api_get "/gvm/public/v1/reports/${report_id}/results?page=${page}&perPage=${per_page}" > "${page_file}" if (( page == 1 )); then total_pages="$(jq -r '.pagination.totalPages // 1' "${page_file}")" @@ -222,7 +222,7 @@ wait_for_export_job() { local progress while (( $(date +%s) < deadline )); do - job_json="$(api_get "/api/v1/jobs/${job_id}")" + job_json="$(api_get "/gvm/public/v1/jobs/${job_id}")" status="$(printf '%s' "${job_json}" | jq -r '.status')" progress="$(printf '%s' "${job_json}" | jq -r '.progress.percent // "unknown"')" echo "export job ${job_id}: status=${status} progress=${progress}" >&2 @@ -284,9 +284,9 @@ SESSION_JSON="$(create_session)" SESSION_TOKEN="$(printf '%s' "${SESSION_JSON}" | jq -er '.sessionToken')" GMP_VERSION="$(printf '%s' "${SESSION_JSON}" | jq -r '.gmpVersion')" -SCAN_CONFIGS_JSON="$(api_get '/api/v1/scan-configs?perPage=1000')" -SCANNERS_JSON="$(api_get '/api/v1/scanners?perPage=1000')" -PORT_LISTS_JSON="$(api_get '/api/v1/port-lists?perPage=1000')" +SCAN_CONFIGS_JSON="$(api_get '/gvm/public/v1/scan-configs?perPage=1000')" +SCANNERS_JSON="$(api_get '/gvm/public/v1/scanners?perPage=1000')" +PORT_LISTS_JSON="$(api_get '/gvm/public/v1/port-lists?perPage=1000')" SCAN_CONFIG_ID="${GVM_SCAN_CONFIG_ID:-$(printf '%s' "${SCAN_CONFIGS_JSON}" | select_scan_config_id)}" SCANNER_ID="${GVM_SCANNER_ID:-$(printf '%s' "${SCANNERS_JSON}" | select_scanner_id)}" @@ -308,7 +308,7 @@ TARGET_BODY="$( portListId: $portListId }' )" -TARGET_JSON="$(api_post_json '/api/v1/targets' "${TARGET_BODY}")" +TARGET_JSON="$(api_post_json '/gvm/public/v1/targets' "${TARGET_BODY}")" TARGET_ID="$(printf '%s' "${TARGET_JSON}" | jq -er '.id')" TASK_BODY="$( @@ -324,10 +324,10 @@ TASK_BODY="$( scannerId: $scannerId }' )" -TASK_JSON="$(api_post_json '/api/v1/tasks' "${TASK_BODY}")" +TASK_JSON="$(api_post_json '/gvm/public/v1/tasks' "${TASK_BODY}")" TASK_ID="$(printf '%s' "${TASK_JSON}" | jq -er '.id')" -START_JSON="$(api_post "/api/v1/tasks/${TASK_ID}/start")" +START_JSON="$(api_post "/gvm/public/v1/tasks/${TASK_ID}/start")" REPORT_ID="$(printf '%s' "${START_JSON}" | jq -er '.reportId')" cat < list[str]: return ["OpenSpec is missing its Credentials route inventory"] documented: dict[str, set[str]] = {} for method, path in re.findall( - r"^\| `(GET|POST|PUT|PATCH|DELETE)` \| `/api/v1(/[^`]+)` \|", + r"^\| `(GET|POST|PUT|PATCH|DELETE)` \| `/gvm/public/v1(/[^`]+)` \|", section.group(1), re.MULTILINE, ): diff --git a/scripts/configure-enterprise-agent-owner.py b/scripts/configure-enterprise-agent-owner.py index 74268570..bb021920 100755 --- a/scripts/configure-enterprise-agent-owner.py +++ b/scripts/configure-enterprise-agent-owner.py @@ -66,7 +66,7 @@ def api_request( def admin_id(base_url: str, username: str, password: str) -> str: - status, body = api_request(base_url, "/api/v1/users?page=1&perPage=100", username, password) + status, body = api_request(base_url, "/gvm/public/v1/users?page=1&perPage=100", username, password) if status != 200: raise ConfigurationError(f"user discovery returned HTTP {status}: {body[:512]!r}") document = json.loads(body) @@ -114,7 +114,7 @@ def main() -> int: user_id = admin_id(args.base_url, args.username, args.password) run_compose(args.compose, user_id) status, body = api_request( - args.base_url, "/api/v1/agents/sync", args.username, args.password, method="POST" + args.base_url, "/gvm/public/v1/agents/sync", args.username, args.password, method="POST" ) if status != 204: raise ConfigurationError(f"initial Agent Control sync returned HTTP {status}: {body[:512]!r}") @@ -122,7 +122,7 @@ def main() -> int: deadline = time.monotonic() + args.timeout while time.monotonic() < deadline: status, body = api_request( - args.base_url, "/api/v1/agents?page=1&perPage=1", args.username, args.password + args.base_url, "/gvm/public/v1/agents?page=1&perPage=1", args.username, args.password ) if status == 200 and json.loads(body).get("data"): print( diff --git a/scripts/run-e2e-tests.sh b/scripts/run-e2e-tests.sh index ad98e78d..9cc4a7c6 100755 --- a/scripts/run-e2e-tests.sh +++ b/scripts/run-e2e-tests.sh @@ -150,7 +150,7 @@ wait_for_gateway_ready() { response="$(mktemp)" local status status="$( - curl -sS -o "${response}" -w '%{http_code}' "${BASE_URL}/ready" \ + curl -sS -o "${response}" -w '%{http_code}' "${BASE_URL}/gvm/ready" \ || true )" local body @@ -177,7 +177,7 @@ create_session() { status="$( curl -sS -o "${response}" -w '%{http_code}' \ -u "${USERNAME}:${PASSWORD}" \ - -X POST "${BASE_URL}/api/v1/session" + -X POST "${BASE_URL}/gvm/public/v1/session" )" local body body="$(cat "${response}")" @@ -195,7 +195,7 @@ delete_session() { local token="$1" curl -sS -o /dev/null -X DELETE \ -H "Authorization: Bearer ${token}" \ - "${BASE_URL}/api/v1/session" \ + "${BASE_URL}/gvm/public/v1/session" \ || true } @@ -207,7 +207,7 @@ print_feed_status() { status="$( curl -sS -o "${response}" -w '%{http_code}' \ -H "Authorization: Bearer ${token}" \ - "${BASE_URL}/api/v1/feeds" \ + "${BASE_URL}/gvm/public/v1/feeds" \ || true )" local body @@ -299,10 +299,10 @@ trap 'delete_session "${SESSION_TOKEN}"' EXIT print_feed_status "${SESSION_TOKEN}" RESOURCE_DEADLINE="$(( $(date +%s) + RESOURCE_TIMEOUT_SECS ))" -wait_for_rest_resource "${SESSION_TOKEN}" "scan configs" "scan-configs" "/api/v1/scan-configs" "${RESOURCE_DEADLINE}" -wait_for_rest_resource "${SESSION_TOKEN}" "scanners" "scanners" "/api/v1/scanners" "${RESOURCE_DEADLINE}" -wait_for_rest_resource "${SESSION_TOKEN}" "port lists" "port-lists" "/api/v1/port-lists" "${RESOURCE_DEADLINE}" -wait_for_rest_resource "${SESSION_TOKEN}" "report formats" "report-formats" "/api/v1/report-formats" "${RESOURCE_DEADLINE}" +wait_for_rest_resource "${SESSION_TOKEN}" "scan configs" "scan-configs" "/gvm/public/v1/scan-configs" "${RESOURCE_DEADLINE}" +wait_for_rest_resource "${SESSION_TOKEN}" "scanners" "scanners" "/gvm/public/v1/scanners" "${RESOURCE_DEADLINE}" +wait_for_rest_resource "${SESSION_TOKEN}" "port lists" "port-lists" "/gvm/public/v1/port-lists" "${RESOURCE_DEADLINE}" +wait_for_rest_resource "${SESSION_TOKEN}" "report formats" "report-formats" "/gvm/public/v1/report-formats" "${RESOURCE_DEADLINE}" delete_session "${SESSION_TOKEN}" trap - EXIT diff --git a/scripts/start-appliance-proxy.sh b/scripts/start-appliance-proxy.sh index 003c5b96..b5f40443 100755 --- a/scripts/start-appliance-proxy.sh +++ b/scripts/start-appliance-proxy.sh @@ -140,7 +140,7 @@ Starting gvm-gateway base URL: http://${BIND_ADDR} Version endpoint: - curl -fsS http://${BIND_ADDR}/api/v1/version + curl -fsS http://${BIND_ADDR}/gvm/public/v1/version EOF GVM_GATEWAY_GVMD_ENDPOINT="unix://${LOCAL_SOCKET}" \ diff --git a/spec/rest-api/common.yaml b/spec/rest-api/common.yaml index 5347c908..1424621d 100644 --- a/spec/rest-api/common.yaml +++ b/spec/rest-api/common.yaml @@ -245,7 +245,7 @@ components: format: uri-reference description: URI reference identifying the specific occurrence. examples: - - "/api/v1/targets/550e8400-e29b-41d4-a716-446655440000" + - "/gvm/public/v1/targets/550e8400-e29b-41d4-a716-446655440000" # ─── Pagination ─────────────────────────────────────────── Pagination: diff --git a/spec/rest-api/openapi.yaml b/spec/rest-api/openapi.yaml index 9886f0f6..1529dd76 100644 --- a/spec/rest-api/openapi.yaml +++ b/spec/rest-api/openapi.yaml @@ -18,17 +18,17 @@ info: ## Authentication flow - 1. `POST /api/v1/session` with HTTP Basic credentials. + 1. `POST /gvm/public/v1/session` with HTTP Basic credentials. 2. On success the API returns an opaque `sessionToken`. 3. Include the token on subsequent requests as: `Authorization: Bearer ` - 4. `DELETE /api/v1/session` ends the session. + 4. `DELETE /gvm/public/v1/session` ends the session. Alternatively, send `Authorization: Basic ` directly to a protected operation unless that operation explicitly requires Bearer authentication. The gateway creates a backend execution context for that request and tears it down before returning. `GET` and `DELETE` - `/api/v1/session` and `POST /api/v1/reports/{id}/exports` are bearer-only. + `/gvm/public/v1/session` and `POST /gvm/public/v1/reports/{id}/exports` are bearer-only. Sessions expire after a configurable idle timeout (default 5 min). One active session token maps to one authenticated backend execution @@ -52,7 +52,7 @@ info: identifier: AGPL-3.0-or-later servers: - - url: /api/v1 + - url: /gvm/public/v1 description: Base path for versioned API endpoints security: @@ -388,10 +388,10 @@ paths: $ref: './supporting-resources.yaml#/paths/~1nvts~1{id}' /nvt-families: $ref: './supporting-resources.yaml#/paths/~1nvt-families' - /health: - $ref: './system.yaml#/paths/~1health' - /ready: - $ref: './system.yaml#/paths/~1ready' + /gvm/health: + $ref: './system.yaml#/paths/~1gvm~1health' + /gvm/ready: + $ref: './system.yaml#/paths/~1gvm~1ready' /version: $ref: './system.yaml#/paths/~1version' /timezones: @@ -406,13 +406,13 @@ components: scheme: basic description: | GVM username and password. Used to create a persistent session - (`POST /api/v1/session`) or to authenticate one protected request + (`POST /gvm/public/v1/session`) or to authenticate one protected request with request-scoped backend cleanup, except operations that explicitly require Bearer authentication. bearerAuth: type: http scheme: bearer description: | - Opaque session token returned by `POST /api/v1/session`. + Opaque session token returned by `POST /gvm/public/v1/session`. May be presented on subsequent protected requests instead of Basic credentials. diff --git a/spec/rest-api/openspec.md b/spec/rest-api/openspec.md index 963dc6c5..2bdb0ce0 100644 --- a/spec/rest-api/openspec.md +++ b/spec/rest-api/openspec.md @@ -87,12 +87,15 @@ crates/ ### Base URL ``` -/api/v1 +/gvm/public/v1 ``` +The default API base path is `/gvm/public/`. The application-owned operational +probes remain unversioned at `/gvm/health` and `/gvm/ready`, outside this prefix. + ### Versioning Strategy -URL-based versioning (`/api/v1/`, `/api/v2/`). Major breaking changes increment version. Minor additions are non-breaking. +URL-based versioning (`/gvm/public/v1/`, `/gvm/public/v2/`). Major breaking changes increment version. Minor additions are non-breaking. ### REST Design Constraints @@ -162,45 +165,45 @@ feeds; supporting resources; SecInfo resources; and system endpoints. | Method | Path | Description | |--------|------|-------------| -| `GET` | `/api/v1/targets` | List targets (paginated, filterable) | -| `POST` | `/api/v1/targets` | Create a target (`201 Created` + `Location`) | -| `GET` | `/api/v1/targets/{id}` | Get target by ID | -| `PUT` | `/api/v1/targets/{id}` | Update target | -| `DELETE` | `/api/v1/targets/{id}` | Delete target | +| `GET` | `/gvm/public/v1/targets` | List targets (paginated, filterable) | +| `POST` | `/gvm/public/v1/targets` | Create a target (`201 Created` + `Location`) | +| `GET` | `/gvm/public/v1/targets/{id}` | Get target by ID | +| `PUT` | `/gvm/public/v1/targets/{id}` | Update target | +| `DELETE` | `/gvm/public/v1/targets/{id}` | Delete target | #### Tasks | Method | Path | Description | |--------|------|-------------| -| `GET` | `/api/v1/tasks` | List tasks | -| `POST` | `/api/v1/tasks` | Create task (`201 Created` + `Location`) | -| `GET` | `/api/v1/tasks/{id}` | Get task | -| `PUT` | `/api/v1/tasks/{id}` | Update task | -| `DELETE` | `/api/v1/tasks/{id}` | Delete task | -| `POST` | `/api/v1/tasks/{id}/start` | Start task | -| `POST` | `/api/v1/tasks/{id}/stop` | Stop task | -| `POST` | `/api/v1/tasks/{id}/resume` | Resume task | +| `GET` | `/gvm/public/v1/tasks` | List tasks | +| `POST` | `/gvm/public/v1/tasks` | Create task (`201 Created` + `Location`) | +| `GET` | `/gvm/public/v1/tasks/{id}` | Get task | +| `PUT` | `/gvm/public/v1/tasks/{id}` | Update task | +| `DELETE` | `/gvm/public/v1/tasks/{id}` | Delete task | +| `POST` | `/gvm/public/v1/tasks/{id}/start` | Start task | +| `POST` | `/gvm/public/v1/tasks/{id}/stop` | Stop task | +| `POST` | `/gvm/public/v1/tasks/{id}/resume` | Resume task | #### Reports | Method | Path | Description | |--------|------|-------------| -| `GET` | `/api/v1/reports` | List reports | -| `POST` | `/api/v1/reports?taskId={taskId}&inAssets={bool}` | Import one bounded XML report into an existing import task (`201 Created` + `Location`) | -| `GET` | `/api/v1/reports/{id}` | Get report with an embedded result page | -| `POST` | `/api/v1/reports/{id}/exports` | Start a Bearer-authenticated asynchronous report export job (`202 Accepted` + `Location`) | -| `GET` | `/api/v1/reports/{id}/results` | Get report results (paginated) | -| `GET` | `/api/v1/reports/{id}/vulnerabilities` | Get report vulnerability findings (paginated) | -| `GET` | `/api/v1/reports/{id}/tls-certificates` | Get TLS certificates observed in a report (paginated) | -| `GET` | `/api/v1/reports/{id}/errors` | Get report error findings (paginated) | -| `GET` | `/api/v1/reports/{id}/closed-cves` | Get closed CVE findings for a report (paginated) | -| `DELETE` | `/api/v1/reports/{id}` | Permanently delete report (no trash or permanence selector) | +| `GET` | `/gvm/public/v1/reports` | List reports | +| `POST` | `/gvm/public/v1/reports?taskId={taskId}&inAssets={bool}` | Import one bounded XML report into an existing import task (`201 Created` + `Location`) | +| `GET` | `/gvm/public/v1/reports/{id}` | Get report with an embedded result page | +| `POST` | `/gvm/public/v1/reports/{id}/exports` | Start a Bearer-authenticated asynchronous report export job (`202 Accepted` + `Location`) | +| `GET` | `/gvm/public/v1/reports/{id}/results` | Get report results (paginated) | +| `GET` | `/gvm/public/v1/reports/{id}/vulnerabilities` | Get report vulnerability findings (paginated) | +| `GET` | `/gvm/public/v1/reports/{id}/tls-certificates` | Get TLS certificates observed in a report (paginated) | +| `GET` | `/gvm/public/v1/reports/{id}/errors` | Get report error findings (paginated) | +| `GET` | `/gvm/public/v1/reports/{id}/closed-cves` | Get closed CVE findings for a report (paginated) | +| `DELETE` | `/gvm/public/v1/reports/{id}` | Permanently delete report (no trash or permanence selector) | Report export is intentionally modeled as a job because gvmd may need to materialize the full report and run report-format generation scripts before an -artifact exists. `POST /api/v1/reports/{id}/exports` returns `202 Accepted` with -`Location: /api/v1/jobs/{jobId}`. Clients poll `GET /api/v1/jobs/{jobId}` and -download completed artifacts from `GET /api/v1/jobs/{jobId}/result`. +artifact exists. `POST /gvm/public/v1/reports/{id}/exports` returns `202 Accepted` with +`Location: /gvm/public/v1/jobs/{jobId}`. Clients poll `GET /gvm/public/v1/jobs/{jobId}` and +download completed artifacts from `GET /gvm/public/v1/jobs/{jobId}/result`. Export requests either reference a gvmd report format with `reportFormatId` or select the API JSON export with `format: "json"`. @@ -209,7 +212,7 @@ Report deletion is always permanent in gvmd. The REST endpoint exposes no caller-level permanence choice and rejects the obsolete `ultimate` query parameter with the standard RFC 9457 `400 bad_request` response. -Report import is synchronous collection creation. `POST /api/v1/reports` +Report import is synchronous collection creation. `POST /gvm/public/v1/reports` requires an existing import-task UUID in `taskId`, accepts optional `inAssets` with omission distinct from explicit `false`, and accepts only one `application/xml` report envelope. The gateway treats the XML as opaque bytes; @@ -221,16 +224,16 @@ places report contents in logs, traces, metrics labels, or problem details. | Method | Path | Description | |--------|------|-------------| -| `GET` | `/api/v1/jobs/{id}` | Get asynchronous job status | -| `DELETE` | `/api/v1/jobs/{id}` | Request job cancellation | -| `GET` | `/api/v1/jobs/{id}/result` | Download a completed job artifact | +| `GET` | `/gvm/public/v1/jobs/{id}` | Get asynchronous job status | +| `DELETE` | `/gvm/public/v1/jobs/{id}` | Request job cancellation | +| `GET` | `/gvm/public/v1/jobs/{id}/result` | Download a completed job artifact | #### Results | Method | Path | Description | |--------|------|-------------| -| `GET` | `/api/v1/results` | List results (paginated, filterable) | -| `GET` | `/api/v1/results/{id}` | Get individual result | +| `GET` | `/gvm/public/v1/results` | List results (paginated, filterable) | +| `GET` | `/gvm/public/v1/results/{id}` | Get individual result | Result NVT references may include optional source-shaped `typeMetadata` text. The gateway preserves it without parsing so future gvmd metadata shapes do not @@ -240,17 +243,17 @@ become a lossy or prematurely fixed REST schema. | Method | Path | Description | |--------|------|-------------| -| `GET` | `/api/v1/scan-configs` | List scan configurations | -| `POST` | `/api/v1/scan-configs` | Copy an explicit active scan-config base (`baseScanConfigId`; `201 Created` + `Location`) | -| `GET` | `/api/v1/scan-configs/{id}` | Get scan config | -| `PUT` | `/api/v1/scan-configs/{id}` | Update scan config | -| `DELETE` | `/api/v1/scan-configs/{id}` | Delete scan config | -| `GET` | `/api/v1/scan-configs/{id}/nvts` | List selected NVTs | -| `GET` | `/api/v1/scan-configs/{id}/nvts/{oid}` | Get one selected NVT | -| `GET` | `/api/v1/scan-configs/{id}/preferences` | List scanner preferences | -| `GET`, `PUT` | `/api/v1/scan-configs/{id}/preferences/{name}` | Read or update one scanner preference | -| `PUT` | `/api/v1/scan-configs/{id}/families/{family}/nvts` | Replace one family's NVT selection | -| `PUT` | `/api/v1/scan-configs/{id}/family-selection` | Replace family selection | +| `GET` | `/gvm/public/v1/scan-configs` | List scan configurations | +| `POST` | `/gvm/public/v1/scan-configs` | Copy an explicit active scan-config base (`baseScanConfigId`; `201 Created` + `Location`) | +| `GET` | `/gvm/public/v1/scan-configs/{id}` | Get scan config | +| `PUT` | `/gvm/public/v1/scan-configs/{id}` | Update scan config | +| `DELETE` | `/gvm/public/v1/scan-configs/{id}` | Delete scan config | +| `GET` | `/gvm/public/v1/scan-configs/{id}/nvts` | List selected NVTs | +| `GET` | `/gvm/public/v1/scan-configs/{id}/nvts/{oid}` | Get one selected NVT | +| `GET` | `/gvm/public/v1/scan-configs/{id}/preferences` | List scanner preferences | +| `GET`, `PUT` | `/gvm/public/v1/scan-configs/{id}/preferences/{name}` | Read or update one scanner preference | +| `PUT` | `/gvm/public/v1/scan-configs/{id}/families/{family}/nvts` | Replace one family's NVT selection | +| `PUT` | `/gvm/public/v1/scan-configs/{id}/family-selection` | Replace family selection | Scan-config creation does not select an implicit backend default. The request must name an active scan configuration in `baseScanConfigId`; missing, @@ -265,86 +268,86 @@ Policy creation likewise requires an explicit active policy base in | Method | Path | Description | |--------|------|-------------| -| `GET` | `/api/v1/scanners` | List scanners | -| `GET` | `/api/v1/scanners/{id}` | Get scanner | +| `GET` | `/gvm/public/v1/scanners` | List scanners | +| `GET` | `/gvm/public/v1/scanners/{id}` | Get scanner | #### Alerts | Method | Path | Description | |--------|------|-------------| -| `GET` | `/api/v1/alerts` | List alerts | -| `POST` | `/api/v1/alerts` | Create alert | -| `GET` | `/api/v1/alerts/{id}` | Get alert | -| `PUT` | `/api/v1/alerts/{id}` | Update alert | -| `DELETE` | `/api/v1/alerts/{id}` | Delete alert | +| `GET` | `/gvm/public/v1/alerts` | List alerts | +| `POST` | `/gvm/public/v1/alerts` | Create alert | +| `GET` | `/gvm/public/v1/alerts/{id}` | Get alert | +| `PUT` | `/gvm/public/v1/alerts/{id}` | Update alert | +| `DELETE` | `/gvm/public/v1/alerts/{id}` | Delete alert | #### Schedules | Method | Path | Description | |--------|------|-------------| -| `GET` | `/api/v1/schedules` | List schedules | -| `POST` | `/api/v1/schedules` | Create schedule | -| `GET` | `/api/v1/schedules/{id}` | Get schedule | -| `PUT` | `/api/v1/schedules/{id}` | Update schedule | -| `DELETE` | `/api/v1/schedules/{id}` | Delete schedule | +| `GET` | `/gvm/public/v1/schedules` | List schedules | +| `POST` | `/gvm/public/v1/schedules` | Create schedule | +| `GET` | `/gvm/public/v1/schedules/{id}` | Get schedule | +| `PUT` | `/gvm/public/v1/schedules/{id}` | Update schedule | +| `DELETE` | `/gvm/public/v1/schedules/{id}` | Delete schedule | #### Credentials | Method | Path | Description | |--------|------|-------------| -| `GET` | `/api/v1/credential-stores` | List available credential stores | -| `GET` | `/api/v1/credential-stores/{id}` | Get a credential store without exposing preference values | -| `PUT` | `/api/v1/credential-stores/{id}` | Update credential-store connection settings and write-only preferences | -| `POST` | `/api/v1/credential-stores/{id}/actions/verify` | Verify the credential-store connection | -| `POST` | `/api/v1/credentials/{id}/actions/verify-active-directory` | Verify a saved AD credential without persisting changes | -| `POST` | `/api/v1/active-directory/credential-verifications` | Verify inline AD connection settings without saving a credential | -| `POST` | `/api/v1/active-directory/object-searches` | Read-only bounded AD discovery using a saved credential; no-store, no persistence | -| `GET` | `/api/v1/credentials` | List credentials | -| `POST` | `/api/v1/credentials` | Create credential | -| `GET` | `/api/v1/credentials/{id}` | Get credential | -| `PUT` | `/api/v1/credentials/{id}` | Update credential | -| `DELETE` | `/api/v1/credentials/{id}` | Delete credential | +| `GET` | `/gvm/public/v1/credential-stores` | List available credential stores | +| `GET` | `/gvm/public/v1/credential-stores/{id}` | Get a credential store without exposing preference values | +| `PUT` | `/gvm/public/v1/credential-stores/{id}` | Update credential-store connection settings and write-only preferences | +| `POST` | `/gvm/public/v1/credential-stores/{id}/actions/verify` | Verify the credential-store connection | +| `POST` | `/gvm/public/v1/credentials/{id}/actions/verify-active-directory` | Verify a saved AD credential without persisting changes | +| `POST` | `/gvm/public/v1/active-directory/credential-verifications` | Verify inline AD connection settings without saving a credential | +| `POST` | `/gvm/public/v1/active-directory/object-searches` | Read-only bounded AD discovery using a saved credential; no-store, no persistence | +| `GET` | `/gvm/public/v1/credentials` | List credentials | +| `POST` | `/gvm/public/v1/credentials` | Create credential | +| `GET` | `/gvm/public/v1/credentials/{id}` | Get credential | +| `PUT` | `/gvm/public/v1/credentials/{id}` | Update credential | +| `DELETE` | `/gvm/public/v1/credentials/{id}` | Delete credential | #### Port Lists | Method | Path | Description | |--------|------|-------------| -| `GET` | `/api/v1/port-lists` | List port lists | -| `POST` | `/api/v1/port-lists` | Create port list | -| `GET` | `/api/v1/port-lists/{id}` | Get port list | -| `PUT` | `/api/v1/port-lists/{id}` | Update port list | -| `DELETE` | `/api/v1/port-lists/{id}` | Delete port list | +| `GET` | `/gvm/public/v1/port-lists` | List port lists | +| `POST` | `/gvm/public/v1/port-lists` | Create port list | +| `GET` | `/gvm/public/v1/port-lists/{id}` | Get port list | +| `PUT` | `/gvm/public/v1/port-lists/{id}` | Update port list | +| `DELETE` | `/gvm/public/v1/port-lists/{id}` | Delete port list | #### Identity & Access Control | Method | Path | Description | |--------|------|-------------| -| `GET` | `/api/v1/users` | List users | -| `POST` | `/api/v1/users` | Create user | -| `GET` | `/api/v1/users/{id}` | Get user | -| `PUT` | `/api/v1/users/{id}` | Update user | -| `DELETE` | `/api/v1/users/{id}` | Delete user | -| `GET` | `/api/v1/groups` | List groups | -| `POST` | `/api/v1/groups` | Create group | -| `GET` | `/api/v1/groups/{id}` | Get group | -| `PUT` | `/api/v1/groups/{id}` | Update group | -| `DELETE` | `/api/v1/groups/{id}` | Delete group | -| `GET` | `/api/v1/roles` | List roles | -| `POST` | `/api/v1/roles` | Create role | -| `GET` | `/api/v1/roles/{id}` | Get role | -| `PUT` | `/api/v1/roles/{id}` | Update role | -| `DELETE` | `/api/v1/roles/{id}` | Delete role | -| `GET` | `/api/v1/permissions` | List permission grants | -| `POST` | `/api/v1/permissions` | Create permission grant | -| `GET` | `/api/v1/permissions/{id}` | Get permission grant | -| `PUT` | `/api/v1/permissions/{id}` | Update permission grant | -| `DELETE` | `/api/v1/permissions/{id}` | Delete permission grant | -| `GET` | `/api/v1/user-settings` | List current-user settings | -| `GET` | `/api/v1/user-settings/{id}` | Get one current-user setting | -| `PUT` | `/api/v1/user-settings/{id}` | Update one current-user setting | +| `GET` | `/gvm/public/v1/users` | List users | +| `POST` | `/gvm/public/v1/users` | Create user | +| `GET` | `/gvm/public/v1/users/{id}` | Get user | +| `PUT` | `/gvm/public/v1/users/{id}` | Update user | +| `DELETE` | `/gvm/public/v1/users/{id}` | Delete user | +| `GET` | `/gvm/public/v1/groups` | List groups | +| `POST` | `/gvm/public/v1/groups` | Create group | +| `GET` | `/gvm/public/v1/groups/{id}` | Get group | +| `PUT` | `/gvm/public/v1/groups/{id}` | Update group | +| `DELETE` | `/gvm/public/v1/groups/{id}` | Delete group | +| `GET` | `/gvm/public/v1/roles` | List roles | +| `POST` | `/gvm/public/v1/roles` | Create role | +| `GET` | `/gvm/public/v1/roles/{id}` | Get role | +| `PUT` | `/gvm/public/v1/roles/{id}` | Update role | +| `DELETE` | `/gvm/public/v1/roles/{id}` | Delete role | +| `GET` | `/gvm/public/v1/permissions` | List permission grants | +| `POST` | `/gvm/public/v1/permissions` | Create permission grant | +| `GET` | `/gvm/public/v1/permissions/{id}` | Get permission grant | +| `PUT` | `/gvm/public/v1/permissions/{id}` | Update permission grant | +| `DELETE` | `/gvm/public/v1/permissions/{id}` | Delete permission grant | +| `GET` | `/gvm/public/v1/user-settings` | List current-user settings | +| `GET` | `/gvm/public/v1/user-settings/{id}` | Get one current-user setting | +| `PUT` | `/gvm/public/v1/user-settings/{id}` | Update one current-user setting | User deletion supports only the canonical plain -`DELETE /api/v1/users/{id}` operation. Typed gvmd user deletion has no +`DELETE /gvm/public/v1/users/{id}` operation. Typed gvmd user deletion has no caller-selectable permanence mode, so every supplied `ultimate` query form is rejected with the standard RFC 9457 `400 bad_request` response before backend dispatch. @@ -353,17 +356,17 @@ dispatch. | Method | Path | Description | |--------|------|-------------| -| `POST` | `/api/v1/session` | Authenticate with HTTP Basic credentials and create a session (`201 Created` + `Location`) | -| `GET` | `/api/v1/session` | Inspect current session state | -| `DELETE` | `/api/v1/session` | Close and destroy a session | +| `POST` | `/gvm/public/v1/session` | Authenticate with HTTP Basic credentials and create a session (`201 Created` + `Location`) | +| `GET` | `/gvm/public/v1/session` | Inspect current session state | +| `DELETE` | `/gvm/public/v1/session` | Close and destroy a session | -Protected routes accept either an existing Bearer session token or request-scoped HTTP Basic credentials unless an operation is explicitly classified as Bearer-only. `POST /api/v1/session` remains the persistent-session creation path. `POST /api/v1/reports/{id}/exports` is Bearer-only. +Protected routes accept either an existing Bearer session token or request-scoped HTTP Basic credentials unless an operation is explicitly classified as Bearer-only. `POST /gvm/public/v1/session` remains the persistent-session creation path. `POST /gvm/public/v1/reports/{id}/exports` is Bearer-only. #### Feeds | Method | Path | Description | |--------|------|-------------| -| `GET` | `/api/v1/feeds` | List feed status | +| `GET` | `/gvm/public/v1/feeds` | List feed status | Existing agent support-bundle downloads accept optional `days` and `encryption` query parameters. `encryption` preserves omission independently @@ -375,14 +378,14 @@ it is omitted when absent. | Method | Path | Description | |--------|------|-------------| -| `GET` | `/health` | Liveness probe | -| `GET` | `/ready` | Readiness probe (checks gvmd connectivity) | -| `GET` | `/api/v1/version` | GMP protocol version reported by the proxied gvmd; `apiVersion` is the REST contract and gateway package version | -| `GET` | `/api/v1/timezones` | Authenticated backend-sourced timezone catalog from gvmd; returns `501` on backends that do not support `get_timezones` | -| `GET` | `/api/v1/openapi.json` | OpenAPI 3.1 spec | +| `GET` | `/gvm/health` | Liveness probe | +| `GET` | `/gvm/ready` | Readiness probe (checks gvmd connectivity) | +| `GET` | `/gvm/public/v1/version` | GMP protocol version reported by the proxied gvmd; `apiVersion` is the REST contract and gateway package version | +| `GET` | `/gvm/public/v1/timezones` | Authenticated backend-sourced timezone catalog from gvmd; returns `501` on backends that do not support `get_timezones` | +| `GET` | `/gvm/public/v1/openapi.json` | OpenAPI 3.1 spec | The gateway also serves a browser documentation UI backed by -`/api/v1/openapi.json`. That operational UI is intentionally outside the API +`/gvm/public/v1/openapi.json`. That operational UI is intentionally outside the API contract. ### Request/Response Conventions @@ -390,7 +393,7 @@ contract. #### Pagination ```http -GET /api/v1/targets?page=1&perPage=25&sort=name&order=asc +GET /gvm/public/v1/targets?page=1&perPage=25&sort=name&order=asc ``` Response includes pagination metadata: @@ -417,7 +420,7 @@ values. GMP filter strings exposed as query parameters: ```http -GET /api/v1/results?severity_min=7.0&host=192.168.1.0/24&task_id= +GET /gvm/public/v1/results?severity_min=7.0&host=192.168.1.0/24&task_id= ``` #### Error Responses @@ -431,7 +434,7 @@ RFC 9457 Problem Details: "title": "Not Found", "status": 404, "detail": "Target with ID '550e8400-e29b-41d4-a716-446655440000' not found.", - "instance": "/api/v1/targets/550e8400-e29b-41d4-a716-446655440000" + "instance": "/gvm/public/v1/targets/550e8400-e29b-41d4-a716-446655440000" } ``` @@ -449,28 +452,28 @@ When a create operation returns a canonical resource identifier, the response mu Current required coverage: -- `POST /api/v1/session` → `Location: /api/v1/session` -- `POST /api/v1/targets` → `Location: /api/v1/targets/{id}` -- `POST /api/v1/tasks` → `Location: /api/v1/tasks/{id}` -- `POST /api/v1/reports` → `Location: /api/v1/reports/{id}` -- `POST /api/v1/scan-configs` → `Location: /api/v1/scan-configs/{id}` +- `POST /gvm/public/v1/session` → `Location: /gvm/public/v1/session` +- `POST /gvm/public/v1/targets` → `Location: /gvm/public/v1/targets/{id}` +- `POST /gvm/public/v1/tasks` → `Location: /gvm/public/v1/tasks/{id}` +- `POST /gvm/public/v1/reports` → `Location: /gvm/public/v1/reports/{id}` +- `POST /gvm/public/v1/scan-configs` → `Location: /gvm/public/v1/scan-configs/{id}` ### Authentication & Authorization 1. **Session token flow** — Persistent auth model - - `POST /api/v1/session` with Basic credentials + - `POST /gvm/public/v1/session` with Basic credentials - API returns an opaque session token - Subsequent requests use `Authorization: Bearer ` 2. **Request-scoped Basic auth** — Single-call auth model - Protected resource routes may use `Authorization: Basic ` - - `POST /api/v1/reports/{id}/exports` does not accept request-scoped Basic authentication and requires an existing Bearer session + - `POST /gvm/public/v1/reports/{id}/exports` does not accept request-scoped Basic authentication and requires an existing Bearer session - The gateway authenticates those credentials, creates a backend execution context for exactly one request, then tears it down before returning - Bearer authentication takes precedence whenever the `Authorization` scheme is `Bearer`; malformed Basic credentials fail with `401 Unauthorized` 3. **Session lifecycle controls** - - `GET /api/v1/session` to inspect session state - - `DELETE /api/v1/session` for explicit teardown + - `GET /gvm/public/v1/session` to inspect session state + - `DELETE /gvm/public/v1/session` for explicit teardown - Session creation and use flow through the shared `SessionManager` / gvmd connection-store model. - One active session token maps to one authenticated backend execution context. - Requests that reuse the same session token must serialize against that backend context; queue saturation/timeouts are surfaced as backpressure errors rather than hidden retries. diff --git a/spec/rest-api/planned-gmp-features.md b/spec/rest-api/planned-gmp-features.md index 9ce9664c..f5ae156f 100644 --- a/spec/rest-api/planned-gmp-features.md +++ b/spec/rest-api/planned-gmp-features.md @@ -40,7 +40,7 @@ release's machine-readable ledger remains unchanged until dependency adoption. ### Contract notation -All paths below are **proposals** relative to `/api/v1`, not route registration. +All paths below are **proposals** relative to `/gvm/public/v1`, not route registration. JSON names are explicit REST choices, not automatic serialization of upstream Rust types. Optional response values are omitted, not replaced with null/empty/ zero defaults. A typed `None` stays absent; `Some(0)`, `Some(false)` and diff --git a/spec/rest-api/system.yaml b/spec/rest-api/system.yaml index b8c020cf..a00ef61d 100644 --- a/spec/rest-api/system.yaml +++ b/spec/rest-api/system.yaml @@ -4,7 +4,7 @@ openapi: 3.1.0 paths: - /health: + /gvm/health: servers: - url: / description: Root path for unversioned liveness and readiness probes @@ -24,7 +24,7 @@ paths: "400": $ref: "./common.yaml#/components/responses/BadRequest" - /ready: + /gvm/ready: servers: - url: / description: Root path for unversioned liveness and readiness probes diff --git a/spec/rest-api/test-spec.md b/spec/rest-api/test-spec.md index 9e70af4a..3ae731d9 100644 --- a/spec/rest-api/test-spec.md +++ b/spec/rest-api/test-spec.md @@ -112,129 +112,129 @@ in-process or through a loopback listener. | Test | Request | Expected | |------|---------|----------| -| `health_returns_200` | `GET /health` | 200, `{"status": "ok"}` | -| `ready_healthy` | `GET /ready` (GMP connected) | 200 | -| `ready_unhealthy` | `GET /ready` (GMP disconnected) | 503 | -| `version_returns_info` | `GET /api/v1/version` | 200, includes proxied gvmd GMP version and REST API contract version | -| `timezones_return_backend_catalog` | `GET /api/v1/timezones` (authenticated, GMP 22.8 backend) | 200, backend-sourced timezone list | -| `timezones_return_not_implemented_on_older_backend` | `GET /api/v1/timezones` (authenticated, GMP 22.7 backend) | 501 problem response | +| `health_returns_200` | `GET /gvm/health` | 200, `{"status": "ok"}` | +| `ready_healthy` | `GET /gvm/ready` (GMP connected) | 200 | +| `ready_unhealthy` | `GET /gvm/ready` (GMP disconnected) | 503 | +| `version_returns_info` | `GET /gvm/public/v1/version` | 200, includes proxied gvmd GMP version and REST API contract version | +| `timezones_return_backend_catalog` | `GET /gvm/public/v1/timezones` (authenticated, GMP 22.8 backend) | 200, backend-sourced timezone list | +| `timezones_return_not_implemented_on_older_backend` | `GET /gvm/public/v1/timezones` (authenticated, GMP 22.7 backend) | 501 problem response | ### 3.3 Targets CRUD | Test | Request | Setup | Expected | |------|---------|-------|----------| -| `list_targets_empty` | `GET /api/v1/targets` | No targets | 200, empty `data[]`, pagination | -| `list_targets_paginated` | `GET /api/v1/targets?page=2&perPage=10` | 25 targets | 200, 10 items, correct pagination | -| `create_target` | `POST /api/v1/targets` + body | — | 201, target with ID | -| `create_target_location_header` | `POST /api/v1/targets` + body | — | 201 + `Location: /api/v1/targets/{id}` | -| `create_target_missing_name` | `POST /api/v1/targets` (no name) | — | 400, RFC 9457 | -| `get_target` | `GET /api/v1/targets/{id}` | Target exists | 200, full target | -| `get_target_not_found` | `GET /api/v1/targets/{bad-id}` | — | 404 | -| `update_target` | `PUT /api/v1/targets/{id}` + body | Target exists | 200, updated fields | -| `delete_target` | `DELETE /api/v1/targets/{id}` | Target exists | 204 | -| `delete_target_not_found` | `DELETE /api/v1/targets/{bad-id}` | — | 404 | +| `list_targets_empty` | `GET /gvm/public/v1/targets` | No targets | 200, empty `data[]`, pagination | +| `list_targets_paginated` | `GET /gvm/public/v1/targets?page=2&perPage=10` | 25 targets | 200, 10 items, correct pagination | +| `create_target` | `POST /gvm/public/v1/targets` + body | — | 201, target with ID | +| `create_target_location_header` | `POST /gvm/public/v1/targets` + body | — | 201 + `Location: /gvm/public/v1/targets/{id}` | +| `create_target_missing_name` | `POST /gvm/public/v1/targets` (no name) | — | 400, RFC 9457 | +| `get_target` | `GET /gvm/public/v1/targets/{id}` | Target exists | 200, full target | +| `get_target_not_found` | `GET /gvm/public/v1/targets/{bad-id}` | — | 404 | +| `update_target` | `PUT /gvm/public/v1/targets/{id}` + body | Target exists | 200, updated fields | +| `delete_target` | `DELETE /gvm/public/v1/targets/{id}` | Target exists | 204 | +| `delete_target_not_found` | `DELETE /gvm/public/v1/targets/{bad-id}` | — | 404 | ### 3.4 Tasks Lifecycle | Test | Request | Setup | Expected | |------|---------|-------|----------| -| `create_task` | `POST /api/v1/tasks` | Target + config exist | 201 | -| `create_task_location_header` | `POST /api/v1/tasks` | Target + config exist | 201 + `Location: /api/v1/tasks/{id}` | -| `start_task` | `POST /api/v1/tasks/{id}/start` | Task exists | 200, report_id | -| `stop_running_task` | `POST /api/v1/tasks/{id}/stop` | Task running | 200 | -| `stop_idle_task` | `POST /api/v1/tasks/{id}/stop` | Task not running | 409 | -| `resume_stopped_task` | `POST /api/v1/tasks/{id}/resume` | Task stopped | 200 | +| `create_task` | `POST /gvm/public/v1/tasks` | Target + config exist | 201 | +| `create_task_location_header` | `POST /gvm/public/v1/tasks` | Target + config exist | 201 + `Location: /gvm/public/v1/tasks/{id}` | +| `start_task` | `POST /gvm/public/v1/tasks/{id}/start` | Task exists | 200, report_id | +| `stop_running_task` | `POST /gvm/public/v1/tasks/{id}/stop` | Task running | 200 | +| `stop_idle_task` | `POST /gvm/public/v1/tasks/{id}/stop` | Task not running | 409 | +| `resume_stopped_task` | `POST /gvm/public/v1/tasks/{id}/resume` | Task stopped | 200 | ### 3.5 Reports | Test | Request | Setup | Expected | |------|---------|-------|----------| -| `list_reports` | `GET /api/v1/reports` | Reports exist | 200, summaries | -| `import_report` | `POST /api/v1/reports?taskId={id}` + `application/xml` body | Import task exists | 201 + stable report ID + `Location`; report is readable | +| `list_reports` | `GET /gvm/public/v1/reports` | Reports exist | 200, summaries | +| `import_report` | `POST /gvm/public/v1/reports?taskId={id}` + `application/xml` body | Import task exists | 201 + stable report ID + `Location`; report is readable | | `import_report_in_assets_omitted_and_false` | Two imports with omitted and `false` `inAssets` | Import task exists | Typed request preserves omission versus explicit false | | `import_report_rejects_invalid_metadata` | Missing/invalid `taskId` or invalid `inAssets` | — | 400 RFC 9457 without payload contents | | `import_report_rejects_media_type` | Non-`application/xml` body | — | 415 RFC 9457 | | `import_report_rejects_empty_or_invalid_envelope` | Empty, malformed, or multiple-report body | — | 400 RFC 9457 without payload contents | | `import_report_rejects_oversized_body` | Body greater than 10485760 bytes | — | 413 before an unbounded body buffer | -| `get_report_with_results` | `GET /api/v1/reports/{id}` | Report exists | 200, includes requested result page | -| `get_report_results_paginated` | `GET /api/v1/reports/{id}/results?page=1&perPage=50` | Large report | 200, 50 results | -| `get_report_vulnerabilities_paginated` | `GET /api/v1/reports/{id}/vulnerabilities?page=1&perPage=50` | Report exists | 200, paginated vulnerability findings | -| `get_report_tls_certificates_paginated` | `GET /api/v1/reports/{id}/tls-certificates?page=1&perPage=50` | Report exists | 200, paginated TLS certificate observations | -| `get_report_errors_paginated` | `GET /api/v1/reports/{id}/errors?page=1&perPage=50` | Report exists | 200, paginated report errors | -| `get_report_closed_cves_paginated` | `GET /api/v1/reports/{id}/closed-cves?page=1&perPage=50` | Report exists | 200, paginated closed CVE findings | -| `delete_report_is_permanent` | `DELETE /api/v1/reports/{id}` | Report exists | 204, report permanently removed | -| `delete_report_rejects_obsolete_ultimate` | `DELETE /api/v1/reports/{id}?ultimate=false` | Report exists | 400 `bad_request`, report remains | -| `create_report_export_job_pdf` | `POST /api/v1/reports/{id}/exports` + PDF `reportFormatId` | Report exists + PDF report format exists | 202 + `Location: /api/v1/jobs/{jobId}` | -| `create_report_export_job_csv` | `POST /api/v1/reports/{id}/exports` + CSV `reportFormatId` | Report exists + CSV report format exists | 202 + `Location: /api/v1/jobs/{jobId}` | -| `create_report_export_job_json` | `POST /api/v1/reports/{id}/exports` + `format=json` | Report exists | 202 + `Location: /api/v1/jobs/{jobId}` | -| `create_report_export_job_unknown_format` | `POST /api/v1/reports/{id}/exports` + bad `reportFormatId` | Report exists | 404 | -| `create_report_export_job_rejects_basic_without_side_effects` | `POST /api/v1/reports/{id}/exports` + valid Basic auth | Report exists | 401; no temporary session, accepted job, worker, or cancellation | -| `create_report_export_job_bearer_survives_delayed_execution` | `POST /api/v1/reports/{id}/exports` + valid Bearer auth | Report exists; execution continues asynchronously | 202 + pollable job that completes on the persistent session | -| `get_report_export_job` | `GET /api/v1/jobs/{jobId}` | Export job exists | 200, job status | -| `download_report_export_job_result` | `GET /api/v1/jobs/{jobId}/result` | Export job succeeded | 200, rendered artifact content type | +| `get_report_with_results` | `GET /gvm/public/v1/reports/{id}` | Report exists | 200, includes requested result page | +| `get_report_results_paginated` | `GET /gvm/public/v1/reports/{id}/results?page=1&perPage=50` | Large report | 200, 50 results | +| `get_report_vulnerabilities_paginated` | `GET /gvm/public/v1/reports/{id}/vulnerabilities?page=1&perPage=50` | Report exists | 200, paginated vulnerability findings | +| `get_report_tls_certificates_paginated` | `GET /gvm/public/v1/reports/{id}/tls-certificates?page=1&perPage=50` | Report exists | 200, paginated TLS certificate observations | +| `get_report_errors_paginated` | `GET /gvm/public/v1/reports/{id}/errors?page=1&perPage=50` | Report exists | 200, paginated report errors | +| `get_report_closed_cves_paginated` | `GET /gvm/public/v1/reports/{id}/closed-cves?page=1&perPage=50` | Report exists | 200, paginated closed CVE findings | +| `delete_report_is_permanent` | `DELETE /gvm/public/v1/reports/{id}` | Report exists | 204, report permanently removed | +| `delete_report_rejects_obsolete_ultimate` | `DELETE /gvm/public/v1/reports/{id}?ultimate=false` | Report exists | 400 `bad_request`, report remains | +| `create_report_export_job_pdf` | `POST /gvm/public/v1/reports/{id}/exports` + PDF `reportFormatId` | Report exists + PDF report format exists | 202 + `Location: /gvm/public/v1/jobs/{jobId}` | +| `create_report_export_job_csv` | `POST /gvm/public/v1/reports/{id}/exports` + CSV `reportFormatId` | Report exists + CSV report format exists | 202 + `Location: /gvm/public/v1/jobs/{jobId}` | +| `create_report_export_job_json` | `POST /gvm/public/v1/reports/{id}/exports` + `format=json` | Report exists | 202 + `Location: /gvm/public/v1/jobs/{jobId}` | +| `create_report_export_job_unknown_format` | `POST /gvm/public/v1/reports/{id}/exports` + bad `reportFormatId` | Report exists | 404 | +| `create_report_export_job_rejects_basic_without_side_effects` | `POST /gvm/public/v1/reports/{id}/exports` + valid Basic auth | Report exists | 401; no temporary session, accepted job, worker, or cancellation | +| `create_report_export_job_bearer_survives_delayed_execution` | `POST /gvm/public/v1/reports/{id}/exports` + valid Bearer auth | Report exists; execution continues asynchronously | 202 + pollable job that completes on the persistent session | +| `get_report_export_job` | `GET /gvm/public/v1/jobs/{jobId}` | Export job exists | 200, job status | +| `download_report_export_job_result` | `GET /gvm/public/v1/jobs/{jobId}/result` | Export job succeeded | 200, rendered artifact content type | ### 3.5a Discovery Helpers | Test | Request | Setup | Expected | |------|---------|-------|----------| -| `list_credential_stores` | `GET /api/v1/credential-stores` | Backend exposes credential store catalog | 200, credential store list | -| `get_credential_store` | `GET /api/v1/credential-stores/{id}` | Existing store id | 200, store metadata with no preference values | -| `modify_credential_store` | `PUT /api/v1/credential-stores/{id}` | Bounded connection/preference update | 200, updated metadata; write-only values omitted | -| `verify_credential_store` | `POST /api/v1/credential-stores/{id}/actions/verify` | Existing configured store | 204 | -| `create_store_backed_credential` | `POST /api/v1/credentials` | `cs_*` type with vault and host references | 201; no local secret values mixed into command | -| `modify_store_backed_credential` | `PUT /api/v1/credentials/{id}` | Store reference update | 200; semantic store-backed command used | -| `agent_support_bundle_encryption_tristate` | `GET /api/v1/agents/{id}/support-bundle` with omitted, false, and true `encryption` | Agent exists | Typed request preserves all three states | -| `nvt_discovery_marker_is_optional` | `GET /api/v1/nvts` and `GET /api/v1/nvts/{id}` | Backend returns true, false, or no marker | Response preserves booleans and omits an absent marker | +| `list_credential_stores` | `GET /gvm/public/v1/credential-stores` | Backend exposes credential store catalog | 200, credential store list | +| `get_credential_store` | `GET /gvm/public/v1/credential-stores/{id}` | Existing store id | 200, store metadata with no preference values | +| `modify_credential_store` | `PUT /gvm/public/v1/credential-stores/{id}` | Bounded connection/preference update | 200, updated metadata; write-only values omitted | +| `verify_credential_store` | `POST /gvm/public/v1/credential-stores/{id}/actions/verify` | Existing configured store | 204 | +| `create_store_backed_credential` | `POST /gvm/public/v1/credentials` | `cs_*` type with vault and host references | 201; no local secret values mixed into command | +| `modify_store_backed_credential` | `PUT /gvm/public/v1/credentials/{id}` | Store reference update | 200; semantic store-backed command used | +| `agent_support_bundle_encryption_tristate` | `GET /gvm/public/v1/agents/{id}/support-bundle` with omitted, false, and true `encryption` | Agent exists | Typed request preserves all three states | +| `nvt_discovery_marker_is_optional` | `GET /gvm/public/v1/nvts` and `GET /gvm/public/v1/nvts/{id}` | Backend returns true, false, or no marker | Response preserves booleans and omits an absent marker | ### 3.5b Identity & Access Control | Test | Request | Setup | Expected | |------|---------|-------|----------| -| `list_users_as_admin` | `GET /api/v1/users` | Admin-capable principal | 200, paginated users | -| `list_users_without_admin_scope` | `GET /api/v1/users` | Authenticated non-admin principal | 403 | -| `create_user_as_admin` | `POST /api/v1/users` | Admin-capable principal | 201 + `Location` | -| `get_user_not_found` | `GET /api/v1/users/{bad-id}` | Admin-capable principal | 404 | -| `modify_user_as_admin` | `PUT /api/v1/users/{id}` | Existing user + admin principal | 200 | -| `delete_user_as_admin` | `DELETE /api/v1/users/{id}` | Existing user + admin principal | 204 | -| `delete_user_rejects_unsupported_ultimate_without_dispatch` | `DELETE /api/v1/users/{id}` with `ultimate=true`, `false`, empty, duplicate, encoded-key, or malformed values | Existing user + admin principal | 400 `bad_request`; no user-delete backend command | -| `list_groups_as_admin` | `GET /api/v1/groups` | Admin-capable principal | 200, paginated groups | -| `create_group_as_admin` | `POST /api/v1/groups` | Admin-capable principal | 201 + `Location` | -| `modify_group_as_admin` | `PUT /api/v1/groups/{id}` | Existing group + admin principal | 200 | -| `delete_group_as_admin` | `DELETE /api/v1/groups/{id}` | Existing group + admin principal | 204 | -| `list_roles_as_admin` | `GET /api/v1/roles` | Admin-capable principal | 200, paginated roles | -| `create_role_as_admin` | `POST /api/v1/roles` | Admin-capable principal | 201 + `Location` | -| `modify_role_as_admin` | `PUT /api/v1/roles/{id}` | Existing role + admin principal | 200 | -| `delete_role_as_admin` | `DELETE /api/v1/roles/{id}` | Existing role + admin principal | 204 | -| `list_permissions_as_admin` | `GET /api/v1/permissions` | Admin-capable principal | 200, paginated permissions | -| `create_permission_as_admin` | `POST /api/v1/permissions` | Admin-capable principal | 201 + `Location` | -| `modify_permission_as_admin` | `PUT /api/v1/permissions/{id}` | Existing permission + admin principal | 200 | -| `delete_permission_as_admin` | `DELETE /api/v1/permissions/{id}` | Existing permission + admin principal | 204 | -| `list_user_settings_for_current_user` | `GET /api/v1/user-settings` | Authenticated principal | 200, unpaginated setting list | -| `get_user_setting_for_current_user` | `GET /api/v1/user-settings/{id}` | Setting belongs to caller | 200 | -| `modify_user_setting_for_current_user` | `PUT /api/v1/user-settings/{id}` | Setting belongs to caller | 200 | -| `create_user_setting_not_allowed` | `POST /api/v1/user-settings` | Authenticated principal | 405 | -| `delete_user_setting_not_allowed` | `DELETE /api/v1/user-settings/{id}` | Authenticated principal | 405 | +| `list_users_as_admin` | `GET /gvm/public/v1/users` | Admin-capable principal | 200, paginated users | +| `list_users_without_admin_scope` | `GET /gvm/public/v1/users` | Authenticated non-admin principal | 403 | +| `create_user_as_admin` | `POST /gvm/public/v1/users` | Admin-capable principal | 201 + `Location` | +| `get_user_not_found` | `GET /gvm/public/v1/users/{bad-id}` | Admin-capable principal | 404 | +| `modify_user_as_admin` | `PUT /gvm/public/v1/users/{id}` | Existing user + admin principal | 200 | +| `delete_user_as_admin` | `DELETE /gvm/public/v1/users/{id}` | Existing user + admin principal | 204 | +| `delete_user_rejects_unsupported_ultimate_without_dispatch` | `DELETE /gvm/public/v1/users/{id}` with `ultimate=true`, `false`, empty, duplicate, encoded-key, or malformed values | Existing user + admin principal | 400 `bad_request`; no user-delete backend command | +| `list_groups_as_admin` | `GET /gvm/public/v1/groups` | Admin-capable principal | 200, paginated groups | +| `create_group_as_admin` | `POST /gvm/public/v1/groups` | Admin-capable principal | 201 + `Location` | +| `modify_group_as_admin` | `PUT /gvm/public/v1/groups/{id}` | Existing group + admin principal | 200 | +| `delete_group_as_admin` | `DELETE /gvm/public/v1/groups/{id}` | Existing group + admin principal | 204 | +| `list_roles_as_admin` | `GET /gvm/public/v1/roles` | Admin-capable principal | 200, paginated roles | +| `create_role_as_admin` | `POST /gvm/public/v1/roles` | Admin-capable principal | 201 + `Location` | +| `modify_role_as_admin` | `PUT /gvm/public/v1/roles/{id}` | Existing role + admin principal | 200 | +| `delete_role_as_admin` | `DELETE /gvm/public/v1/roles/{id}` | Existing role + admin principal | 204 | +| `list_permissions_as_admin` | `GET /gvm/public/v1/permissions` | Admin-capable principal | 200, paginated permissions | +| `create_permission_as_admin` | `POST /gvm/public/v1/permissions` | Admin-capable principal | 201 + `Location` | +| `modify_permission_as_admin` | `PUT /gvm/public/v1/permissions/{id}` | Existing permission + admin principal | 200 | +| `delete_permission_as_admin` | `DELETE /gvm/public/v1/permissions/{id}` | Existing permission + admin principal | 204 | +| `list_user_settings_for_current_user` | `GET /gvm/public/v1/user-settings` | Authenticated principal | 200, unpaginated setting list | +| `get_user_setting_for_current_user` | `GET /gvm/public/v1/user-settings/{id}` | Setting belongs to caller | 200 | +| `modify_user_setting_for_current_user` | `PUT /gvm/public/v1/user-settings/{id}` | Setting belongs to caller | 200 | +| `create_user_setting_not_allowed` | `POST /gvm/public/v1/user-settings` | Authenticated principal | 405 | +| `delete_user_setting_not_allowed` | `DELETE /gvm/public/v1/user-settings/{id}` | Authenticated principal | 405 | ### 3.6 Authentication Flow | Test | Request | Expected | |------|---------|----------| -| `create_session_valid_credentials` | `POST /api/v1/session` + valid Basic auth | 201, session token + metadata | -| `create_session_location_header` | `POST /api/v1/session` + valid Basic auth | 201 + `Location: /api/v1/session` | -| `create_session_invalid_credentials` | `POST /api/v1/session` + bad Basic auth | 401 | -| `get_session_valid_token` | `GET /api/v1/session` + `Authorization: Bearer ` | 200, session details | -| `delete_session_valid_token` | `DELETE /api/v1/session` + `Authorization: Bearer ` | 204 | -| `protected_endpoint_no_auth` | `GET /api/v1/targets` (no token) | 401 | -| `protected_endpoint_unknown_token` | `GET /api/v1/targets` + unknown token | 401 | -| `protected_endpoint_valid_auth` | `GET /api/v1/targets` + valid session token | 200 | -| `protected_endpoint_request_scoped_basic_auth` | `GET /api/v1/targets` + valid Basic credentials | 200, backend context cleaned up after response | -| `protected_endpoint_malformed_basic_auth` | `GET /api/v1/targets` + malformed Basic credentials | 401 | +| `create_session_valid_credentials` | `POST /gvm/public/v1/session` + valid Basic auth | 201, session token + metadata | +| `create_session_location_header` | `POST /gvm/public/v1/session` + valid Basic auth | 201 + `Location: /gvm/public/v1/session` | +| `create_session_invalid_credentials` | `POST /gvm/public/v1/session` + bad Basic auth | 401 | +| `get_session_valid_token` | `GET /gvm/public/v1/session` + `Authorization: Bearer ` | 200, session details | +| `delete_session_valid_token` | `DELETE /gvm/public/v1/session` + `Authorization: Bearer ` | 204 | +| `protected_endpoint_no_auth` | `GET /gvm/public/v1/targets` (no token) | 401 | +| `protected_endpoint_unknown_token` | `GET /gvm/public/v1/targets` + unknown token | 401 | +| `protected_endpoint_valid_auth` | `GET /gvm/public/v1/targets` + valid session token | 200 | +| `protected_endpoint_request_scoped_basic_auth` | `GET /gvm/public/v1/targets` + valid Basic credentials | 200, backend context cleaned up after response | +| `protected_endpoint_malformed_basic_auth` | `GET /gvm/public/v1/targets` + malformed Basic credentials | 401 | ### 3.7 OpenAPI Compliance | Test | Scope | |------|-------| -| `openapi_spec_valid` | `GET /api/v1/openapi.json` validates against OpenAPI 3.1 schema | +| `openapi_spec_valid` | `GET /gvm/public/v1/openapi.json` validates against OpenAPI 3.1 schema | | `all_routes_documented` | Every registered route appears in the spec | | `response_matches_schema` | Actual responses validate against declared schemas | | `report_export_job_creation_security_is_bearer_only` | Curated and generated `POST /reports/{id}/exports` operations advertise only `bearerAuth` | @@ -250,8 +250,8 @@ in-process or through a loopback listener. | `create_session_location_header` | Session creation returns `201 Created` + canonical `Location` | | `method_not_allowed` | Unsupported method on a published resource returns `405` | | `not_found_route` | Unknown route returns `404` | -| `removed_ticket_collection_not_found` | Authenticated `GET /api/v1/tickets` returns the standard unknown-route `404` problem response | -| `removed_ticket_item_not_found` | Authenticated `GET /api/v1/tickets/{validUuid}` returns the standard unknown-route `404` problem response | +| `removed_ticket_collection_not_found` | Authenticated `GET /gvm/public/v1/tickets` returns the standard unknown-route `404` problem response | +| `removed_ticket_item_not_found` | Authenticated `GET /gvm/public/v1/tickets/{validUuid}` returns the standard unknown-route `404` problem response | | `stop_idle_task` | Illegal action transition returns `409` | | `content_type_problem_json` | Problem responses use `application/problem+json` | | `generated_openapi_endpoint_exposes_implemented_contract` | Generated OpenAPI stays aligned with curated path/method/response/header contract | @@ -269,8 +269,8 @@ in-process or through a loopback listener. | `security_headers_present` | API success and problem responses include baseline security headers | | `browser_docs_use_bundled_redoc_with_same_origin_csp` | Documentation UI outside the API contract serves the repository-bundled Redoc asset with same-origin-only script and contract loading | | `audit_log_redacts_session_token` | Audit/log capture contains safe session IDs but no raw tokens or passwords | -| `method_not_allowed` | `PATCH /api/v1/targets` → 405 | -| `not_found_route` | `GET /api/v1/nonexistent` → 404 | +| `method_not_allowed` | `PATCH /gvm/public/v1/targets` → 405 | +| `not_found_route` | `GET /gvm/public/v1/nonexistent` → 404 | ## 4. E2E Tests (Compose stack via Podman or Docker) diff --git a/tests/e2e/src/harness/polling.rs b/tests/e2e/src/harness/polling.rs index e404c221..d6937c9a 100644 --- a/tests/e2e/src/harness/polling.rs +++ b/tests/e2e/src/harness/polling.rs @@ -16,16 +16,19 @@ impl E2eHarness { while Instant::now() < deadline { let response = self .client - .get(self.endpoint("/ready")) + .get(self.endpoint("/gvm/ready")) .send() .await - .context("query /ready")?; + .context("query /gvm/ready")?; let status = response.status(); - let body = response.text().await.context("read /ready response body")?; + let body = response + .text() + .await + .context("read /gvm/ready response body")?; if status == StatusCode::OK { let readiness: ReadinessResponse = - serde_json::from_str(&body).context("parse /ready success body")?; + serde_json::from_str(&body).context("parse /gvm/ready success body")?; if readiness.status == "ready" { eprintln!("gateway ready: {body}"); return Ok(()); diff --git a/tests/e2e/src/harness/resources/auth.rs b/tests/e2e/src/harness/resources/auth.rs index f6217a2a..14ec87fc 100644 --- a/tests/e2e/src/harness/resources/auth.rs +++ b/tests/e2e/src/harness/resources/auth.rs @@ -7,7 +7,7 @@ impl E2eHarness { pub async fn create_session(&self) -> Result { let request = self .client - .post(self.endpoint("/api/v1/session")) + .post(self.endpoint("/gvm/public/v1/session")) .basic_auth(&self.config.username, Some(&self.config.password)); self.send_json(request, StatusCode::CREATED, "create REST session") .await @@ -16,7 +16,7 @@ impl E2eHarness { pub async fn create_session_with_location(&self) -> Result { let response = self .client - .post(self.endpoint("/api/v1/session")) + .post(self.endpoint("/gvm/public/v1/session")) .basic_auth(&self.config.username, Some(&self.config.password)) .send() .await @@ -55,7 +55,7 @@ impl E2eHarness { username: &str, password: &str, ) -> Result { - self.request(Method::POST, "/api/v1/session") + self.request(Method::POST, "/gvm/public/v1/session") .basic_auth(username, Some(password)) .send() .await @@ -63,7 +63,7 @@ impl E2eHarness { } pub async fn create_session_with_malformed_basic(&self) -> Result { - self.request(Method::POST, "/api/v1/session") + self.request(Method::POST, "/gvm/public/v1/session") .header(header::AUTHORIZATION, "Basic bm9fY29sb24=") .send() .await @@ -72,7 +72,7 @@ impl E2eHarness { pub async fn get_session(&self, token: &str) -> Result { self.send_json( - self.authed(Method::GET, "/api/v1/session", token), + self.authed(Method::GET, "/gvm/public/v1/session", token), StatusCode::OK, "get REST session", ) @@ -80,21 +80,21 @@ impl E2eHarness { } pub async fn get_session_response(&self, token: &str) -> Result { - self.authed(Method::GET, "/api/v1/session", token) + self.authed(Method::GET, "/gvm/public/v1/session", token) .send() .await .context("get REST session response") } pub async fn get_targets_without_auth(&self) -> Result { - self.request(Method::GET, "/api/v1/targets") + self.request(Method::GET, "/gvm/public/v1/targets") .send() .await .context("list targets without auth") } pub async fn get_targets_with_bearer(&self, token: &str) -> Result { - self.request(Method::GET, "/api/v1/targets") + self.request(Method::GET, "/gvm/public/v1/targets") .bearer_auth(token) .send() .await @@ -106,7 +106,7 @@ impl E2eHarness { username: &str, password: &str, ) -> Result { - self.request(Method::GET, "/api/v1/targets") + self.request(Method::GET, "/gvm/public/v1/targets") .basic_auth(username, Some(password)) .send() .await @@ -114,14 +114,14 @@ impl E2eHarness { } pub async fn get_users_without_auth(&self) -> Result { - self.request(Method::GET, "/api/v1/users") + self.request(Method::GET, "/gvm/public/v1/users") .send() .await .context("list users without auth") } pub async fn get_users_with_bearer(&self, token: &str) -> Result { - self.request(Method::GET, "/api/v1/users") + self.request(Method::GET, "/gvm/public/v1/users") .bearer_auth(token) .send() .await @@ -130,7 +130,7 @@ impl E2eHarness { pub async fn delete_session(&self, token: &str) -> Result<()> { self.send_empty( - self.authed(Method::DELETE, "/api/v1/session", token), + self.authed(Method::DELETE, "/gvm/public/v1/session", token), StatusCode::NO_CONTENT, "delete session", ) diff --git a/tests/e2e/src/harness/resources/automation.rs b/tests/e2e/src/harness/resources/automation.rs index 80b7cfad..0ab59d20 100644 --- a/tests/e2e/src/harness/resources/automation.rs +++ b/tests/e2e/src/harness/resources/automation.rs @@ -6,7 +6,7 @@ use super::super::*; impl E2eHarness { pub async fn list_schedules(&self, token: &str) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/schedules?perPage=1000", token), + self.authed(Method::GET, "/gvm/public/v1/schedules?perPage=1000", token), StatusCode::OK, "list schedules", ) @@ -27,7 +27,7 @@ impl E2eHarness { "timezone": timezone, }); self.send_created_json( - self.authed(Method::POST, "/api/v1/schedules", token) + self.authed(Method::POST, "/gvm/public/v1/schedules", token) .json(&body), "create schedule", ) @@ -38,7 +38,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/schedules/{schedule_id}"), + &format!("/gvm/public/v1/schedules/{schedule_id}"), token, ), StatusCode::OK, @@ -65,7 +65,7 @@ impl E2eHarness { self.send_json( self.authed( Method::PUT, - &format!("/api/v1/schedules/{schedule_id}"), + &format!("/gvm/public/v1/schedules/{schedule_id}"), token, ) .json(&body), @@ -79,7 +79,7 @@ impl E2eHarness { self.send_empty( self.authed( Method::DELETE, - &format!("/api/v1/schedules/{schedule_id}"), + &format!("/gvm/public/v1/schedules/{schedule_id}"), token, ), StatusCode::NO_CONTENT, @@ -90,7 +90,7 @@ impl E2eHarness { pub async fn list_alerts(&self, token: &str) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/alerts?perPage=1000", token), + self.authed(Method::GET, "/gvm/public/v1/alerts?perPage=1000", token), StatusCode::OK, "list alerts", ) @@ -106,7 +106,7 @@ impl E2eHarness { "method": "syslog", }); self.send_created_json( - self.authed(Method::POST, "/api/v1/alerts", token) + self.authed(Method::POST, "/gvm/public/v1/alerts", token) .json(&body), "create alert", ) @@ -115,7 +115,11 @@ impl E2eHarness { pub async fn get_alert(&self, token: &str, alert_id: &str) -> Result { self.send_json( - self.authed(Method::GET, &format!("/api/v1/alerts/{alert_id}"), token), + self.authed( + Method::GET, + &format!("/gvm/public/v1/alerts/{alert_id}"), + token, + ), StatusCode::OK, "get alert", ) @@ -124,7 +128,11 @@ impl E2eHarness { pub async fn delete_alert(&self, token: &str, alert_id: &str) -> Result<()> { self.send_empty( - self.authed(Method::DELETE, &format!("/api/v1/alerts/{alert_id}"), token), + self.authed( + Method::DELETE, + &format!("/gvm/public/v1/alerts/{alert_id}"), + token, + ), StatusCode::NO_CONTENT, "delete alert", ) diff --git a/tests/e2e/src/harness/resources/discovery.rs b/tests/e2e/src/harness/resources/discovery.rs index cc130374..0dd21d90 100644 --- a/tests/e2e/src/harness/resources/discovery.rs +++ b/tests/e2e/src/harness/resources/discovery.rs @@ -13,7 +13,7 @@ impl E2eHarness { "comment": "created by compose-backed report import E2E coverage", }); self.send_created_json( - self.authed(Method::POST, "/api/v1/tasks", token) + self.authed(Method::POST, "/gvm/public/v1/tasks", token) .json(&body), "create report import task", ) @@ -23,7 +23,11 @@ impl E2eHarness { pub async fn list_scan_configs(&self, token: &str) -> Result> { let response: ListResponse = self .send_json( - self.authed(Method::GET, "/api/v1/scan-configs?perPage=1000", token), + self.authed( + Method::GET, + "/gvm/public/v1/scan-configs?perPage=1000", + token, + ), StatusCode::OK, "list scan configs", ) @@ -35,7 +39,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/scan-configs/{scan_config_id}"), + &format!("/gvm/public/v1/scan-configs/{scan_config_id}"), token, ), StatusCode::OK, @@ -57,7 +61,7 @@ impl E2eHarness { "baseScanConfigId": base_scan_config_id, }); self.send_created_json( - self.authed(Method::POST, "/api/v1/scan-configs", token) + self.authed(Method::POST, "/gvm/public/v1/scan-configs", token) .json(&body), "create scan config", ) @@ -76,7 +80,7 @@ impl E2eHarness { self.send_json( self.authed( Method::PUT, - &format!("/api/v1/scan-configs/{scan_config_id}"), + &format!("/gvm/public/v1/scan-configs/{scan_config_id}"), token, ) .json(&body), @@ -90,7 +94,7 @@ impl E2eHarness { self.send_empty( self.authed( Method::DELETE, - &format!("/api/v1/scan-configs/{scan_config_id}"), + &format!("/gvm/public/v1/scan-configs/{scan_config_id}"), token, ), StatusCode::NO_CONTENT, @@ -102,7 +106,7 @@ impl E2eHarness { pub async fn list_scanners(&self, token: &str) -> Result> { let response: ListResponse = self .send_json( - self.authed(Method::GET, "/api/v1/scanners", token), + self.authed(Method::GET, "/gvm/public/v1/scanners", token), StatusCode::OK, "list scanners", ) @@ -114,7 +118,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/scanners/{scanner_id}"), + &format!("/gvm/public/v1/scanners/{scanner_id}"), token, ), StatusCode::OK, @@ -137,7 +141,7 @@ impl E2eHarness { }); let created: ResourceCreated = self .send_json( - self.authed(Method::POST, "/api/v1/targets", token) + self.authed(Method::POST, "/gvm/public/v1/targets", token) .json(&body), StatusCode::CREATED, "create target", @@ -148,7 +152,7 @@ impl E2eHarness { pub async fn list_targets(&self, token: &str) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/targets?perPage=1000", token), + self.authed(Method::GET, "/gvm/public/v1/targets?perPage=1000", token), StatusCode::OK, "list targets", ) @@ -157,7 +161,11 @@ impl E2eHarness { pub async fn get_target(&self, token: &str, target_id: &str) -> Result { self.send_json( - self.authed(Method::GET, &format!("/api/v1/targets/{target_id}"), token), + self.authed( + Method::GET, + &format!("/gvm/public/v1/targets/{target_id}"), + token, + ), StatusCode::OK, "get target", ) @@ -174,8 +182,12 @@ impl E2eHarness { "name": name, }); self.send_json( - self.authed(Method::PUT, &format!("/api/v1/targets/{target_id}"), token) - .json(&body), + self.authed( + Method::PUT, + &format!("/gvm/public/v1/targets/{target_id}"), + token, + ) + .json(&body), StatusCode::OK, "update target", ) @@ -186,7 +198,7 @@ impl E2eHarness { self.send_empty( self.authed( Method::DELETE, - &format!("/api/v1/targets/{target_id}"), + &format!("/gvm/public/v1/targets/{target_id}"), token, ), StatusCode::NO_CONTENT, @@ -211,7 +223,7 @@ impl E2eHarness { }); let created: ResourceCreated = self .send_json( - self.authed(Method::POST, "/api/v1/tasks", token) + self.authed(Method::POST, "/gvm/public/v1/tasks", token) .json(&body), StatusCode::CREATED, "create task", @@ -222,7 +234,7 @@ impl E2eHarness { pub async fn list_tasks(&self, token: &str) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/tasks?perPage=1000", token), + self.authed(Method::GET, "/gvm/public/v1/tasks?perPage=1000", token), StatusCode::OK, "list tasks", ) @@ -234,7 +246,7 @@ impl E2eHarness { .send_json( self.authed( Method::POST, - &format!("/api/v1/tasks/{task_id}/start"), + &format!("/gvm/public/v1/tasks/{task_id}/start"), token, ), StatusCode::OK, @@ -253,7 +265,7 @@ impl E2eHarness { ) -> Result { self.authed( Method::POST, - &format!("/api/v1/tasks/{task_id}/start"), + &format!("/gvm/public/v1/tasks/{task_id}/start"), token, ) .send() @@ -266,8 +278,12 @@ impl E2eHarness { "name": name, }); self.send_json( - self.authed(Method::PUT, &format!("/api/v1/tasks/{task_id}"), token) - .json(&body), + self.authed( + Method::PUT, + &format!("/gvm/public/v1/tasks/{task_id}"), + token, + ) + .json(&body), StatusCode::OK, "update task", ) @@ -281,7 +297,7 @@ impl E2eHarness { ) -> Result { self.authed( Method::POST, - &format!("/api/v1/tasks/{task_id}/stop"), + &format!("/gvm/public/v1/tasks/{task_id}/stop"), token, ) .send() @@ -293,7 +309,7 @@ impl E2eHarness { self.send_empty( self.authed( Method::POST, - &format!("/api/v1/tasks/{task_id}/stop"), + &format!("/gvm/public/v1/tasks/{task_id}/stop"), token, ), StatusCode::OK, @@ -309,7 +325,7 @@ impl E2eHarness { ) -> Result { self.authed( Method::POST, - &format!("/api/v1/tasks/{task_id}/resume"), + &format!("/gvm/public/v1/tasks/{task_id}/resume"), token, ) .send() @@ -319,7 +335,11 @@ impl E2eHarness { pub async fn delete_task(&self, token: &str, task_id: &str) -> Result<()> { self.send_empty( - self.authed(Method::DELETE, &format!("/api/v1/tasks/{task_id}"), token), + self.authed( + Method::DELETE, + &format!("/gvm/public/v1/tasks/{task_id}"), + token, + ), StatusCode::NO_CONTENT, "delete task", ) @@ -345,7 +365,7 @@ impl E2eHarness { }); let created: ResourceCreated = self .send_json( - self.authed(Method::POST, "/api/v1/audits", token) + self.authed(Method::POST, "/gvm/public/v1/audits", token) .json(&body), StatusCode::CREATED, "create audit", @@ -356,7 +376,11 @@ impl E2eHarness { pub async fn get_audit(&self, token: &str, audit_id: &str) -> Result { self.send_json( - self.authed(Method::GET, &format!("/api/v1/audits/{audit_id}"), token), + self.authed( + Method::GET, + &format!("/gvm/public/v1/audits/{audit_id}"), + token, + ), StatusCode::OK, "get audit", ) @@ -368,7 +392,7 @@ impl E2eHarness { .send_json( self.authed( Method::POST, - &format!("/api/v1/audits/{audit_id}/start"), + &format!("/gvm/public/v1/audits/{audit_id}/start"), token, ), StatusCode::OK, @@ -475,7 +499,11 @@ impl E2eHarness { pub async fn delete_audit(&self, token: &str, audit_id: &str) -> Result<()> { self.send_empty( - self.authed(Method::DELETE, &format!("/api/v1/audits/{audit_id}"), token), + self.authed( + Method::DELETE, + &format!("/gvm/public/v1/audits/{audit_id}"), + token, + ), StatusCode::NO_CONTENT, "delete audit", ) @@ -484,7 +512,11 @@ impl E2eHarness { pub async fn get_task(&self, token: &str, task_id: &str) -> Result { self.send_json( - self.authed(Method::GET, &format!("/api/v1/tasks/{task_id}"), token), + self.authed( + Method::GET, + &format!("/gvm/public/v1/tasks/{task_id}"), + token, + ), StatusCode::OK, "get task", ) @@ -500,7 +532,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/results?page={page}&perPage={per_page}"), + &format!("/gvm/public/v1/results?page={page}&perPage={per_page}"), token, ), StatusCode::OK, @@ -511,7 +543,11 @@ impl E2eHarness { pub async fn get_result(&self, token: &str, result_id: &str) -> Result { self.send_json( - self.authed(Method::GET, &format!("/api/v1/results/{result_id}"), token), + self.authed( + Method::GET, + &format!("/gvm/public/v1/results/{result_id}"), + token, + ), StatusCode::OK, "get result", ) @@ -522,7 +558,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/reports/{report_id}/results"), + &format!("/gvm/public/v1/reports/{report_id}/results"), token, ), StatusCode::OK, @@ -541,7 +577,9 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/reports/{report_id}/results?page={page}&perPage={per_page}"), + &format!( + "/gvm/public/v1/reports/{report_id}/results?page={page}&perPage={per_page}" + ), token, ), StatusCode::OK, diff --git a/tests/e2e/src/harness/resources/identity.rs b/tests/e2e/src/harness/resources/identity.rs index 5b0df08d..ebf82753 100644 --- a/tests/e2e/src/harness/resources/identity.rs +++ b/tests/e2e/src/harness/resources/identity.rs @@ -6,7 +6,7 @@ use super::super::*; impl E2eHarness { pub async fn list_users(&self, token: &str) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/users?perPage=1000", token), + self.authed(Method::GET, "/gvm/public/v1/users?perPage=1000", token), StatusCode::OK, "list users", ) @@ -15,7 +15,11 @@ impl E2eHarness { pub async fn get_user(&self, token: &str, user_id: &str) -> Result { self.send_json( - self.authed(Method::GET, &format!("/api/v1/users/{user_id}"), token), + self.authed( + Method::GET, + &format!("/gvm/public/v1/users/{user_id}"), + token, + ), StatusCode::OK, "get user", ) @@ -24,7 +28,7 @@ impl E2eHarness { pub async fn list_groups(&self, token: &str) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/groups?perPage=1000", token), + self.authed(Method::GET, "/gvm/public/v1/groups?perPage=1000", token), StatusCode::OK, "list groups", ) @@ -38,7 +42,7 @@ impl E2eHarness { "users": [], }); self.send_created_json( - self.authed(Method::POST, "/api/v1/groups", token) + self.authed(Method::POST, "/gvm/public/v1/groups", token) .json(&body), "create group", ) @@ -47,7 +51,11 @@ impl E2eHarness { pub async fn get_group(&self, token: &str, group_id: &str) -> Result { self.send_json( - self.authed(Method::GET, &format!("/api/v1/groups/{group_id}"), token), + self.authed( + Method::GET, + &format!("/gvm/public/v1/groups/{group_id}"), + token, + ), StatusCode::OK, "get group", ) @@ -56,7 +64,11 @@ impl E2eHarness { pub async fn delete_group(&self, token: &str, group_id: &str) -> Result<()> { self.send_empty( - self.authed(Method::DELETE, &format!("/api/v1/groups/{group_id}"), token), + self.authed( + Method::DELETE, + &format!("/gvm/public/v1/groups/{group_id}"), + token, + ), StatusCode::NO_CONTENT, "delete group", ) @@ -65,7 +77,7 @@ impl E2eHarness { pub async fn list_roles(&self, token: &str) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/roles?perPage=1000", token), + self.authed(Method::GET, "/gvm/public/v1/roles?perPage=1000", token), StatusCode::OK, "list roles", ) @@ -74,7 +86,11 @@ impl E2eHarness { pub async fn get_role(&self, token: &str, role_id: &str) -> Result { self.send_json( - self.authed(Method::GET, &format!("/api/v1/roles/{role_id}"), token), + self.authed( + Method::GET, + &format!("/gvm/public/v1/roles/{role_id}"), + token, + ), StatusCode::OK, "get role", ) @@ -83,7 +99,11 @@ impl E2eHarness { pub async fn list_permissions(&self, token: &str) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/permissions?perPage=1000", token), + self.authed( + Method::GET, + "/gvm/public/v1/permissions?perPage=1000", + token, + ), StatusCode::OK, "list permissions", ) @@ -94,7 +114,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/permissions/{permission_id}"), + &format!("/gvm/public/v1/permissions/{permission_id}"), token, ), StatusCode::OK, @@ -108,7 +128,7 @@ impl E2eHarness { token: &str, ) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/user-settings", token), + self.authed(Method::GET, "/gvm/public/v1/user-settings", token), StatusCode::OK, "list user settings", ) @@ -119,7 +139,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/user-settings/{setting_id}"), + &format!("/gvm/public/v1/user-settings/{setting_id}"), token, ), StatusCode::OK, @@ -140,7 +160,7 @@ impl E2eHarness { self.send_json( self.authed( Method::PUT, - &format!("/api/v1/user-settings/{setting_id}"), + &format!("/gvm/public/v1/user-settings/{setting_id}"), token, ) .json(&body), diff --git a/tests/e2e/src/harness/resources/live_mutations.rs b/tests/e2e/src/harness/resources/live_mutations.rs index 16699ced..e2481503 100644 --- a/tests/e2e/src/harness/resources/live_mutations.rs +++ b/tests/e2e/src/harness/resources/live_mutations.rs @@ -20,7 +20,14 @@ impl E2eHarness { } let request = self.authed_path_segments_with_query( Method::GET, - &["api", "v1", "scan-configs", scan_config_id, "nvts"], + &[ + "gvm", + "public", + "v1", + "scan-configs", + scan_config_id, + "nvts", + ], &query, token, )?; @@ -50,7 +57,7 @@ impl E2eHarness { .finish(); let response: ListResponse = self .send_json( - self.authed(Method::GET, &format!("/api/v1/nvts?{query}"), token), + self.authed(Method::GET, &format!("/gvm/public/v1/nvts?{query}"), token), StatusCode::OK, "list feed NVTs for selected family", ) @@ -71,7 +78,7 @@ impl E2eHarness { self.send_empty( self.authed_path_segments_with_query( Method::DELETE, - &["api", "v1", "scan-configs", scan_config_id], + &["gvm", "public", "v1", "scan-configs", scan_config_id], &[("ultimate", "true")], token, )?, @@ -87,7 +94,14 @@ impl E2eHarness { scan_config_id: &str, nvt_oid: Option<&str>, ) -> Result> { - let segments = &["api", "v1", "scan-configs", scan_config_id, "preferences"]; + let segments = &[ + "gvm", + "public", + "v1", + "scan-configs", + scan_config_id, + "preferences", + ]; let request = match nvt_oid { Some(nvt_oid) => self.authed_path_segments_with_query( Method::GET, @@ -113,7 +127,8 @@ impl E2eHarness { self.authed_path_segments( Method::PUT, &[ - "api", + "gvm", + "public", "v1", "scan-configs", scan_config_id, @@ -139,7 +154,8 @@ impl E2eHarness { self.authed_path_segments( Method::PUT, &[ - "api", + "gvm", + "public", "v1", "scan-configs", scan_config_id, @@ -168,7 +184,8 @@ impl E2eHarness { self.authed_path_segments( Method::PUT, &[ - "api", + "gvm", + "public", "v1", "scan-configs", scan_config_id, @@ -205,7 +222,13 @@ impl E2eHarness { self.send_json( self.authed_path_segments( Method::GET, - &["api", "v1", "credential-stores", credential_store_id], + &[ + "gvm", + "public", + "v1", + "credential-stores", + credential_store_id, + ], token, )?, StatusCode::OK, @@ -223,7 +246,13 @@ impl E2eHarness { self.send_json( self.authed_path_segments( Method::PUT, - &["api", "v1", "credential-stores", credential_store_id], + &[ + "gvm", + "public", + "v1", + "credential-stores", + credential_store_id, + ], token, )? .json(&json!({ "comment": comment })), @@ -242,7 +271,8 @@ impl E2eHarness { self.authed_path_segments( Method::POST, &[ - "api", + "gvm", + "public", "v1", "credential-stores", credential_store_id, @@ -263,7 +293,7 @@ impl E2eHarness { request: &StoreBackedCredentialRequest, ) -> Result { let response = self - .authed(Method::POST, "/api/v1/credentials", token) + .authed(Method::POST, "/gvm/public/v1/credentials", token) .json(request) .send() .await @@ -303,7 +333,7 @@ impl E2eHarness { self.send_empty( self.authed_path_segments_with_query( Method::DELETE, - &["api", "v1", "credentials", credential_id], + &["gvm", "public", "v1", "credentials", credential_id], &[("ultimate", "true")], token, )?, @@ -324,7 +354,7 @@ impl E2eHarness { "get credential store", self.authed_path_segments( Method::GET, - &["api", "v1", "credential-stores", valid_uuid], + &["gvm", "public", "v1", "credential-stores", valid_uuid], token, )?, ), @@ -332,7 +362,7 @@ impl E2eHarness { "update credential store", self.authed_path_segments( Method::PUT, - &["api", "v1", "credential-stores", valid_uuid], + &["gvm", "public", "v1", "credential-stores", valid_uuid], token, )? .json(&json!({})), @@ -342,7 +372,8 @@ impl E2eHarness { self.authed_path_segments( Method::POST, &[ - "api", + "gvm", + "public", "v1", "credential-stores", valid_uuid, @@ -354,7 +385,7 @@ impl E2eHarness { ), ( "create store-backed credential", - self.authed(Method::POST, "/api/v1/credentials", token) + self.authed(Method::POST, "/gvm/public/v1/credentials", token) .json(request), ), ]; diff --git a/tests/e2e/src/harness/resources/reports.rs b/tests/e2e/src/harness/resources/reports.rs index 1e31c783..5b97b3b2 100644 --- a/tests/e2e/src/harness/resources/reports.rs +++ b/tests/e2e/src/harness/resources/reports.rs @@ -11,7 +11,7 @@ impl E2eHarness { in_assets: Option, report_xml: &[u8], ) -> Result { - let mut path = format!("/api/v1/reports?taskId={task_id}"); + let mut path = format!("/gvm/public/v1/reports?taskId={task_id}"); if let Some(in_assets) = in_assets { path.push_str(&format!("&inAssets={in_assets}")); } @@ -36,7 +36,7 @@ impl E2eHarness { self.authed( Method::GET, &format!( - "/api/v1/reports/{report_id}/{subresource}?page={page}&perPage={per_page}" + "/gvm/public/v1/reports/{report_id}/{subresource}?page={page}&perPage={per_page}" ), token, ), @@ -57,7 +57,7 @@ impl E2eHarness { self.authed( Method::GET, &format!( - "/api/v1/reports/{report_id}/operating-systems?page={page}&perPage={per_page}" + "/gvm/public/v1/reports/{report_id}/operating-systems?page={page}&perPage={per_page}" ), token, ), @@ -71,7 +71,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/reports/{report_id}?perPage=1000"), + &format!("/gvm/public/v1/reports/{report_id}?perPage=1000"), token, ), StatusCode::OK, @@ -82,7 +82,7 @@ impl E2eHarness { pub async fn list_reports(&self, token: &str) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/reports?perPage=1000", token), + self.authed(Method::GET, "/gvm/public/v1/reports?perPage=1000", token), StatusCode::OK, "list reports", ) @@ -97,7 +97,7 @@ impl E2eHarness { self.send_json( self.authed( Method::POST, - &format!("/api/v1/reports/{report_id}/exports"), + &format!("/gvm/public/v1/reports/{report_id}/exports"), token, ) .json(&serde_json::json!({ "format": "json" })), @@ -116,7 +116,7 @@ impl E2eHarness { self.send_json( self.authed( Method::POST, - &format!("/api/v1/reports/{report_id}/exports"), + &format!("/gvm/public/v1/reports/{report_id}/exports"), token, ) .json(&serde_json::json!({ "reportFormatId": report_format_id })), @@ -128,7 +128,7 @@ impl E2eHarness { pub async fn get_job(&self, token: &str, job_id: &str) -> Result { self.send_json( - self.authed(Method::GET, &format!("/api/v1/jobs/{job_id}"), token), + self.authed(Method::GET, &format!("/gvm/public/v1/jobs/{job_id}"), token), StatusCode::OK, "get job", ) @@ -141,7 +141,11 @@ impl E2eHarness { job_id: &str, ) -> Result { self.send_json( - self.authed(Method::GET, &format!("/api/v1/jobs/{job_id}/result"), token), + self.authed( + Method::GET, + &format!("/gvm/public/v1/jobs/{job_id}/result"), + token, + ), StatusCode::OK, "download JSON report export", ) @@ -153,10 +157,14 @@ impl E2eHarness { token: &str, job_id: &str, ) -> Result { - self.authed(Method::GET, &format!("/api/v1/jobs/{job_id}/result"), token) - .send() - .await - .context("download report export") + self.authed( + Method::GET, + &format!("/gvm/public/v1/jobs/{job_id}/result"), + token, + ) + .send() + .await + .context("download report export") } pub async fn get_report_tls_certificates_page( @@ -170,7 +178,7 @@ impl E2eHarness { self.authed( Method::GET, &format!( - "/api/v1/reports/{report_id}/tls-certificates?page={page}&perPage={per_page}" + "/gvm/public/v1/reports/{report_id}/tls-certificates?page={page}&perPage={per_page}" ), token, ), @@ -190,7 +198,9 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/reports/{report_id}/errors?page={page}&perPage={per_page}"), + &format!( + "/gvm/public/v1/reports/{report_id}/errors?page={page}&perPage={per_page}" + ), token, ), StatusCode::OK, @@ -209,7 +219,9 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/reports/{report_id}/closed-cves?page={page}&perPage={per_page}"), + &format!( + "/gvm/public/v1/reports/{report_id}/closed-cves?page={page}&perPage={per_page}" + ), token, ), StatusCode::OK, @@ -229,7 +241,7 @@ impl E2eHarness { self.authed( Method::GET, &format!( - "/api/v1/reports/{report_id}/vulnerabilities?page={page}&perPage={per_page}" + "/gvm/public/v1/reports/{report_id}/vulnerabilities?page={page}&perPage={per_page}" ), token, ), @@ -250,7 +262,7 @@ impl E2eHarness { .authed( Method::GET, &format!( - "/api/v1/reports/{report_id}/vulnerabilities?page={page}&perPage={per_page}" + "/gvm/public/v1/reports/{report_id}/vulnerabilities?page={page}&perPage={per_page}" ), token, ) @@ -274,7 +286,7 @@ impl E2eHarness { let response = self .authed( Method::GET, - &format!("/api/v1/reports/{report_id}/vulnerabilities?page=1&perPage=1"), + &format!("/gvm/public/v1/reports/{report_id}/vulnerabilities?page=1&perPage=1"), token, ) .send() diff --git a/tests/e2e/src/harness/resources/supporting.rs b/tests/e2e/src/harness/resources/supporting.rs index 34ac7b06..96ced06b 100644 --- a/tests/e2e/src/harness/resources/supporting.rs +++ b/tests/e2e/src/harness/resources/supporting.rs @@ -7,7 +7,7 @@ impl E2eHarness { pub async fn list_port_lists(&self, token: &str) -> Result> { let response: ListResponse = self .send_json( - self.authed(Method::GET, "/api/v1/port-lists", token), + self.authed(Method::GET, "/gvm/public/v1/port-lists", token), StatusCode::OK, "list port lists", ) @@ -27,7 +27,7 @@ impl E2eHarness { "portRange": port_range, }); self.send_created_json( - self.authed(Method::POST, "/api/v1/port-lists", token) + self.authed(Method::POST, "/gvm/public/v1/port-lists", token) .json(&body), "create port list", ) @@ -38,7 +38,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/port-lists/{port_list_id}"), + &format!("/gvm/public/v1/port-lists/{port_list_id}"), token, ), StatusCode::OK, @@ -59,7 +59,7 @@ impl E2eHarness { self.send_json( self.authed( Method::PUT, - &format!("/api/v1/port-lists/{port_list_id}"), + &format!("/gvm/public/v1/port-lists/{port_list_id}"), token, ) .json(&body), @@ -73,7 +73,7 @@ impl E2eHarness { self.send_empty( self.authed( Method::DELETE, - &format!("/api/v1/port-lists/{port_list_id}"), + &format!("/gvm/public/v1/port-lists/{port_list_id}"), token, ), StatusCode::NO_CONTENT, @@ -84,8 +84,8 @@ impl E2eHarness { pub async fn list_feeds(&self, token: &str, feed_type: Option<&str>) -> Result { let path = feed_type.map_or_else( - || "/api/v1/feeds".to_string(), - |feed_type| format!("/api/v1/feeds?type={feed_type}"), + || "/gvm/public/v1/feeds".to_string(), + |feed_type| format!("/gvm/public/v1/feeds?type={feed_type}"), ); self.send_json( self.authed(Method::GET, &path, token), @@ -97,7 +97,7 @@ impl E2eHarness { pub async fn list_hosts(&self, token: &str) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/hosts?perPage=1000", token), + self.authed(Method::GET, "/gvm/public/v1/hosts?perPage=1000", token), StatusCode::OK, "list hosts", ) @@ -112,7 +112,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/assets?type={asset_type}&perPage=1000"), + &format!("/gvm/public/v1/assets?type={asset_type}&perPage=1000"), token, ), StatusCode::OK, @@ -130,7 +130,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/assets/{asset_id}?type={asset_type}"), + &format!("/gvm/public/v1/assets/{asset_id}?type={asset_type}"), token, ), StatusCode::OK, @@ -141,7 +141,7 @@ impl E2eHarness { pub async fn list_generic_configs(&self, token: &str) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/configs?perPage=1000", token), + self.authed(Method::GET, "/gvm/public/v1/configs?perPage=1000", token), StatusCode::OK, "list generic configs", ) @@ -150,7 +150,11 @@ impl E2eHarness { pub async fn get_generic_config(&self, token: &str, config_id: &str) -> Result { self.send_json( - self.authed(Method::GET, &format!("/api/v1/configs/{config_id}"), token), + self.authed( + Method::GET, + &format!("/gvm/public/v1/configs/{config_id}"), + token, + ), StatusCode::OK, "get generic config", ) @@ -162,7 +166,11 @@ impl E2eHarness { token: &str, ) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/operating-systems?perPage=1000", token), + self.authed( + Method::GET, + "/gvm/public/v1/operating-systems?perPage=1000", + token, + ), StatusCode::OK, "list operating systems", ) @@ -177,7 +185,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/operating-systems/{operating_system_id}"), + &format!("/gvm/public/v1/operating-systems/{operating_system_id}"), token, ), StatusCode::OK, @@ -195,7 +203,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/hosts?page={page}&perPage={per_page}"), + &format!("/gvm/public/v1/hosts?page={page}&perPage={per_page}"), token, ), StatusCode::OK, @@ -206,7 +214,11 @@ impl E2eHarness { pub async fn get_host(&self, token: &str, host_id: &str) -> Result { self.send_json( - self.authed(Method::GET, &format!("/api/v1/hosts/{host_id}"), token), + self.authed( + Method::GET, + &format!("/gvm/public/v1/hosts/{host_id}"), + token, + ), StatusCode::OK, "get host", ) @@ -215,7 +227,11 @@ impl E2eHarness { pub async fn list_report_formats(&self, token: &str) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/report-formats?perPage=1000", token), + self.authed( + Method::GET, + "/gvm/public/v1/report-formats?perPage=1000", + token, + ), StatusCode::OK, "list report formats", ) @@ -224,7 +240,7 @@ impl E2eHarness { pub async fn list_cves(&self, token: &str) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/cves?perPage=1000", token), + self.authed(Method::GET, "/gvm/public/v1/cves?perPage=1000", token), StatusCode::OK, "list cves", ) @@ -233,7 +249,7 @@ impl E2eHarness { pub async fn get_cve(&self, token: &str, cve_id: &str) -> Result { self.send_json( - self.authed(Method::GET, &format!("/api/v1/cves/{cve_id}"), token), + self.authed(Method::GET, &format!("/gvm/public/v1/cves/{cve_id}"), token), StatusCode::OK, "get cve", ) @@ -242,7 +258,7 @@ impl E2eHarness { pub async fn list_cpes(&self, token: &str) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/cpes?perPage=1000", token), + self.authed(Method::GET, "/gvm/public/v1/cpes?perPage=1000", token), StatusCode::OK, "list cpes", ) @@ -251,7 +267,7 @@ impl E2eHarness { pub async fn get_cpe(&self, token: &str, cpe_id: &str) -> Result { self.send_json( - self.authed(Method::GET, &format!("/api/v1/cpes/{cpe_id}"), token), + self.authed(Method::GET, &format!("/gvm/public/v1/cpes/{cpe_id}"), token), StatusCode::OK, "get cpe", ) @@ -265,7 +281,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - "/api/v1/cert-bund-advisories?perPage=1000", + "/gvm/public/v1/cert-bund-advisories?perPage=1000", token, ), StatusCode::OK, @@ -282,7 +298,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/cert-bund-advisories/{advisory_id}"), + &format!("/gvm/public/v1/cert-bund-advisories/{advisory_id}"), token, ), StatusCode::OK, @@ -298,7 +314,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - "/api/v1/dfn-cert-advisories?perPage=1000", + "/gvm/public/v1/dfn-cert-advisories?perPage=1000", token, ), StatusCode::OK, @@ -315,7 +331,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/dfn-cert-advisories/{advisory_id}"), + &format!("/gvm/public/v1/dfn-cert-advisories/{advisory_id}"), token, ), StatusCode::OK, @@ -332,7 +348,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/report-formats/{report_format_id}"), + &format!("/gvm/public/v1/report-formats/{report_format_id}"), token, ), StatusCode::OK, @@ -343,7 +359,7 @@ impl E2eHarness { pub async fn list_filters(&self, token: &str) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/filters?perPage=1000", token), + self.authed(Method::GET, "/gvm/public/v1/filters?perPage=1000", token), StatusCode::OK, "list filters", ) @@ -352,7 +368,11 @@ impl E2eHarness { pub async fn get_filter(&self, token: &str, filter_id: &str) -> Result { self.send_json( - self.authed(Method::GET, &format!("/api/v1/filters/{filter_id}"), token), + self.authed( + Method::GET, + &format!("/gvm/public/v1/filters/{filter_id}"), + token, + ), StatusCode::OK, "get filter", ) @@ -361,7 +381,7 @@ impl E2eHarness { pub async fn list_tags(&self, token: &str) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/tags?perPage=1000", token), + self.authed(Method::GET, "/gvm/public/v1/tags?perPage=1000", token), StatusCode::OK, "list tags", ) @@ -370,7 +390,7 @@ impl E2eHarness { pub async fn get_tag(&self, token: &str, tag_id: &str) -> Result { self.send_json( - self.authed(Method::GET, &format!("/api/v1/tags/{tag_id}"), token), + self.authed(Method::GET, &format!("/gvm/public/v1/tags/{tag_id}"), token), StatusCode::OK, "get tag", ) @@ -379,7 +399,7 @@ impl E2eHarness { pub async fn list_notes(&self, token: &str) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/notes?perPage=1000", token), + self.authed(Method::GET, "/gvm/public/v1/notes?perPage=1000", token), StatusCode::OK, "list notes", ) @@ -394,7 +414,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/notes?perPage=1000&filter={filter}"), + &format!("/gvm/public/v1/notes?perPage=1000&filter={filter}"), token, ), StatusCode::OK, @@ -405,7 +425,11 @@ impl E2eHarness { pub async fn get_note(&self, token: &str, note_id: &str) -> Result { self.send_json( - self.authed(Method::GET, &format!("/api/v1/notes/{note_id}"), token), + self.authed( + Method::GET, + &format!("/gvm/public/v1/notes/{note_id}"), + token, + ), StatusCode::OK, "get note", ) @@ -429,7 +453,7 @@ impl E2eHarness { "orphan": false, }); self.send_created_json( - self.authed(Method::POST, "/api/v1/notes", token) + self.authed(Method::POST, "/gvm/public/v1/notes", token) .json(&body), "create note", ) @@ -448,8 +472,12 @@ impl E2eHarness { "active": active, }); self.send_json( - self.authed(Method::PUT, &format!("/api/v1/notes/{note_id}"), token) - .json(&body), + self.authed( + Method::PUT, + &format!("/gvm/public/v1/notes/{note_id}"), + token, + ) + .json(&body), StatusCode::OK, "update note", ) @@ -460,7 +488,7 @@ impl E2eHarness { self.send_empty( self.authed( Method::DELETE, - &format!("/api/v1/notes/{note_id}?ultimate={ultimate}"), + &format!("/gvm/public/v1/notes/{note_id}?ultimate={ultimate}"), token, ), StatusCode::NO_CONTENT, @@ -471,7 +499,7 @@ impl E2eHarness { pub async fn list_overrides(&self, token: &str) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/overrides?perPage=1000", token), + self.authed(Method::GET, "/gvm/public/v1/overrides?perPage=1000", token), StatusCode::OK, "list overrides", ) @@ -486,7 +514,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/overrides?perPage=1000&filter={filter}"), + &format!("/gvm/public/v1/overrides?perPage=1000&filter={filter}"), token, ), StatusCode::OK, @@ -499,7 +527,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/overrides/{override_id}"), + &format!("/gvm/public/v1/overrides/{override_id}"), token, ), StatusCode::OK, @@ -526,7 +554,7 @@ impl E2eHarness { "active": true, }); self.send_created_json( - self.authed(Method::POST, "/api/v1/overrides", token) + self.authed(Method::POST, "/gvm/public/v1/overrides", token) .json(&body), "create override", ) @@ -549,7 +577,7 @@ impl E2eHarness { self.send_json( self.authed( Method::PUT, - &format!("/api/v1/overrides/{override_id}"), + &format!("/gvm/public/v1/overrides/{override_id}"), token, ) .json(&body), @@ -568,7 +596,7 @@ impl E2eHarness { self.send_empty( self.authed( Method::DELETE, - &format!("/api/v1/overrides/{override_id}?ultimate={ultimate}"), + &format!("/gvm/public/v1/overrides/{override_id}?ultimate={ultimate}"), token, ), StatusCode::NO_CONTENT, @@ -579,7 +607,7 @@ impl E2eHarness { pub async fn list_nvts(&self, token: &str) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/nvts?perPage=1000", token), + self.authed(Method::GET, "/gvm/public/v1/nvts?perPage=1000", token), StatusCode::OK, "list nvts", ) @@ -603,7 +631,7 @@ impl E2eHarness { .append_pair("sortField", "name") .finish(); self.send_json( - self.authed(Method::GET, &format!("/api/v1/nvts?{query}"), token), + self.authed(Method::GET, &format!("/gvm/public/v1/nvts?{query}"), token), StatusCode::OK, "list nvts with typed options", ) @@ -619,7 +647,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/nvts?page={page}&perPage={per_page}"), + &format!("/gvm/public/v1/nvts?page={page}&perPage={per_page}"), token, ), StatusCode::OK, @@ -630,7 +658,7 @@ impl E2eHarness { pub async fn get_nvt(&self, token: &str, oid: &str) -> Result { self.send_json( - self.authed(Method::GET, &format!("/api/v1/nvts/{oid}"), token), + self.authed(Method::GET, &format!("/gvm/public/v1/nvts/{oid}"), token), StatusCode::OK, "get nvt", ) @@ -639,7 +667,11 @@ impl E2eHarness { pub async fn list_nvt_families(&self, token: &str) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/nvt-families?perPage=1000", token), + self.authed( + Method::GET, + "/gvm/public/v1/nvt-families?perPage=1000", + token, + ), StatusCode::OK, "list nvt families", ) @@ -651,7 +683,7 @@ impl E2eHarness { token: &str, ) -> Result>> { let response = self - .authed(Method::GET, "/api/v1/credential-stores", token) + .authed(Method::GET, "/gvm/public/v1/credential-stores", token) .send() .await .context("list credential stores")?; @@ -697,7 +729,11 @@ impl E2eHarness { pub async fn list_credentials(&self, token: &str) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/credentials?perPage=1000", token), + self.authed( + Method::GET, + "/gvm/public/v1/credentials?perPage=1000", + token, + ), StatusCode::OK, "list credentials", ) @@ -719,7 +755,7 @@ impl E2eHarness { "password": password, }); self.send_created_json( - self.authed(Method::POST, "/api/v1/credentials", token) + self.authed(Method::POST, "/gvm/public/v1/credentials", token) .json(&body), "create credential", ) @@ -730,7 +766,7 @@ impl E2eHarness { self.send_json( self.authed( Method::GET, - &format!("/api/v1/credentials/{credential_id}"), + &format!("/gvm/public/v1/credentials/{credential_id}"), token, ), StatusCode::OK, @@ -743,7 +779,7 @@ impl E2eHarness { self.send_empty( self.authed( Method::DELETE, - &format!("/api/v1/credentials/{credential_id}"), + &format!("/gvm/public/v1/credentials/{credential_id}"), token, ), StatusCode::NO_CONTENT, diff --git a/tests/e2e/src/harness/resources/system.rs b/tests/e2e/src/harness/resources/system.rs index 5eca9596..28b5a151 100644 --- a/tests/e2e/src/harness/resources/system.rs +++ b/tests/e2e/src/harness/resources/system.rs @@ -6,7 +6,7 @@ use super::super::*; impl E2eHarness { pub async fn get_health(&self) -> Result { self.send_json( - self.request(Method::GET, "/health"), + self.request(Method::GET, "/gvm/health"), StatusCode::OK, "get gateway health", ) @@ -15,7 +15,7 @@ impl E2eHarness { pub async fn get_readiness(&self) -> Result { self.send_json( - self.request(Method::GET, "/ready"), + self.request(Method::GET, "/gvm/ready"), StatusCode::OK, "get gateway readiness", ) @@ -24,7 +24,7 @@ impl E2eHarness { pub async fn get_version(&self) -> Result { self.send_json( - self.request(Method::GET, "/api/v1/version"), + self.request(Method::GET, "/gvm/public/v1/version"), StatusCode::OK, "get gateway version", ) @@ -36,7 +36,7 @@ impl E2eHarness { token: &str, ) -> Result> { self.send_json( - self.authed(Method::GET, "/api/v1/timezones", token), + self.authed(Method::GET, "/gvm/public/v1/timezones", token), StatusCode::OK, "get backend timezones", ) diff --git a/tests/e2e/tests/rest_auth.rs b/tests/e2e/tests/rest_auth.rs index 75a40b8d..748409d7 100644 --- a/tests/e2e/tests/rest_auth.rs +++ b/tests/e2e/tests/rest_auth.rs @@ -87,7 +87,7 @@ async fn rest_session_lifecycle_exposes_location_and_session_details() -> Result let created = harness.create_session_with_location().await?; assert!( - created.location.ends_with("/api/v1/session"), + created.location.ends_with("/gvm/public/v1/session"), "session Location {} did not point at the current-session resource", created.location ); diff --git a/tests/e2e/tests/rest_automation_resources.rs b/tests/e2e/tests/rest_automation_resources.rs index 7b0f5742..e6e039c2 100644 --- a/tests/e2e/tests/rest_automation_resources.rs +++ b/tests/e2e/tests/rest_automation_resources.rs @@ -34,7 +34,7 @@ async fn rest_automation_schedule_lifecycle_creates_reads_lists_and_deletes() -> SCHEDULE_TIMEZONE, ) .await?; - assert_created_location(&created, "/api/v1/schedules"); + assert_created_location(&created, "/gvm/public/v1/schedules"); schedule_id = Some(created.id.clone()); let schedule = harness.get_schedule(&session.token, &created.id).await?; @@ -81,7 +81,7 @@ async fn rest_automation_alert_lifecycle_creates_reads_lists_and_deletes() -> Re .create_alert(&session.token, &alert_name) .await .context("create alert for lifecycle coverage")?; - assert_created_location(&created, "/api/v1/alerts"); + assert_created_location(&created, "/gvm/public/v1/alerts"); alert_id = Some(created.id.clone()); let alert = harness.get_alert(&session.token, &created.id).await?; diff --git a/tests/e2e/tests/rest_compliance_audit.rs b/tests/e2e/tests/rest_compliance_audit.rs index 84ca00d0..34a7b6bb 100644 --- a/tests/e2e/tests/rest_compliance_audit.rs +++ b/tests/e2e/tests/rest_compliance_audit.rs @@ -43,7 +43,7 @@ async fn rest_compliance_runs_audit_lifecycle_and_keeps_usage_scoped() -> Result let fetched_policy = get_policy(&harness, &session.token, &policy.id).await?; assert_eq!( fetched_policy.id, policy.id, - "GET /api/v1/policies/{{id}} should return the requested policy" + "GET /gvm/public/v1/policies/{{id}} should return the requested policy" ); assert_eq!( fetched_policy.usage_type.as_deref(), @@ -99,7 +99,7 @@ async fn rest_compliance_runs_audit_lifecycle_and_keeps_usage_scoped() -> Result let fetched_audit = get_audit(&harness, &session.token, &audit.id).await?; assert_eq!( fetched_audit.id, audit.id, - "GET /api/v1/audits/{{id}} should return the created audit" + "GET /gvm/public/v1/audits/{{id}} should return the created audit" ); let audits_after = list_audits(&harness, &session.token).await?; assert!( @@ -190,12 +190,16 @@ async fn best_effort_cleanup( async fn list_policies(harness: &E2eHarness, token: &str) -> Result> { let response = harness - .request(Method::GET, "/api/v1/policies") + .request(Method::GET, "/gvm/public/v1/policies") .bearer_auth(token) .send() .await .context("list policies request failed")?; - assert_eq!(response.status(), StatusCode::OK, "GET /api/v1/policies"); + assert_eq!( + response.status(), + StatusCode::OK, + "GET /gvm/public/v1/policies" + ); response .json::>() .await @@ -204,7 +208,7 @@ async fn list_policies(harness: &E2eHarness, token: &str) -> Result Result { let response = harness - .request(Method::GET, &format!("/api/v1/policies/{id}")) + .request(Method::GET, &format!("/gvm/public/v1/policies/{id}")) .bearer_auth(token) .send() .await @@ -212,19 +216,23 @@ async fn get_policy(harness: &E2eHarness, token: &str, id: &str) -> Result().await.context("decode policy") } async fn list_audits(harness: &E2eHarness, token: &str) -> Result> { let response = harness - .request(Method::GET, "/api/v1/audits") + .request(Method::GET, "/gvm/public/v1/audits") .bearer_auth(token) .send() .await .context("list audits request failed")?; - assert_eq!(response.status(), StatusCode::OK, "GET /api/v1/audits"); + assert_eq!( + response.status(), + StatusCode::OK, + "GET /gvm/public/v1/audits" + ); response .json::>() .await @@ -233,7 +241,7 @@ async fn list_audits(harness: &E2eHarness, token: &str) -> Result Result { let response = harness - .request(Method::GET, &format!("/api/v1/audits/{id}")) + .request(Method::GET, &format!("/gvm/public/v1/audits/{id}")) .bearer_auth(token) .send() .await @@ -241,7 +249,7 @@ async fn get_audit(harness: &E2eHarness, token: &str, id: &str) -> Result assert_eq!( response.status(), StatusCode::OK, - "GET /api/v1/audits/{{id}}" + "GET /gvm/public/v1/audits/{{id}}" ); response.json::().await.context("decode audit") } diff --git a/tests/e2e/tests/rest_cross_cutting.rs b/tests/e2e/tests/rest_cross_cutting.rs index c399f37c..cf224d02 100644 --- a/tests/e2e/tests/rest_cross_cutting.rs +++ b/tests/e2e/tests/rest_cross_cutting.rs @@ -22,7 +22,7 @@ async fn rest_cross_cutting_headers_are_present_on_success_and_problem_responses let run = async { let success = harness - .request(Method::GET, "/api/v1/targets") + .request(Method::GET, "/gvm/public/v1/targets") .bearer_auth(&session.token) .header("traceparent", TRACEPARENT) .header("tracestate", TRACESTATE) @@ -36,7 +36,7 @@ async fn rest_cross_cutting_headers_are_present_on_success_and_problem_responses assert_trace_headers(success.headers(), "success response"); let problem = harness - .request(Method::GET, "/api/v1/targets") + .request(Method::GET, "/gvm/public/v1/targets") .header("traceparent", TRACEPARENT) .header("tracestate", TRACESTATE) .header("baggage", "user_id=123") diff --git a/tests/e2e/tests/rest_discovery_scan.rs b/tests/e2e/tests/rest_discovery_scan.rs index 8dc4ca47..7c1f74bf 100644 --- a/tests/e2e/tests/rest_discovery_scan.rs +++ b/tests/e2e/tests/rest_discovery_scan.rs @@ -668,7 +668,7 @@ async fn assert_json_report_export_job( let completed_job = harness .wait_for_job_succeeded(token, &created_job.id) .await?; - let expected_location = format!("/api/v1/jobs/{}/result", created_job.id); + let expected_location = format!("/gvm/public/v1/jobs/{}/result", created_job.id); assert_eq!( completed_job.result_location.as_deref(), Some(expected_location.as_str()), diff --git a/tests/e2e/tests/rest_enterprise_agent_control.rs b/tests/e2e/tests/rest_enterprise_agent_control.rs index e46ba371..05d8b312 100644 --- a/tests/e2e/tests/rest_enterprise_agent_control.rs +++ b/tests/e2e/tests/rest_enterprise_agent_control.rs @@ -41,7 +41,7 @@ async fn rest_enterprise_agent_control_lifecycle_is_repeatable_and_fail_closed() let agents = get_json( &harness, Method::GET, - "/api/v1/agents?page=1&perPage=1", + "/gvm/public/v1/agents?page=1&perPage=1", token, StatusCode::OK, ) @@ -61,7 +61,7 @@ async fn rest_enterprise_agent_control_lifecycle_is_repeatable_and_fail_closed() let original = get_json( &harness, Method::GET, - &format!("/api/v1/agents/{agent_id}"), + &format!("/gvm/public/v1/agents/{agent_id}"), token, StatusCode::OK, ) @@ -89,7 +89,7 @@ async fn rest_enterprise_agent_control_lifecycle_is_repeatable_and_fail_closed() let updated = send_json( &harness, Method::PUT, - &format!("/api/v1/agents/{agent_id}"), + &format!("/gvm/public/v1/agents/{agent_id}"), token, &mutation, StatusCode::OK, @@ -99,7 +99,7 @@ async fn rest_enterprise_agent_control_lifecycle_is_repeatable_and_fail_closed() let read_back = get_json( &harness, Method::GET, - &format!("/api/v1/agents/{agent_id}"), + &format!("/gvm/public/v1/agents/{agent_id}"), token, StatusCode::OK, ) @@ -118,7 +118,7 @@ async fn rest_enterprise_agent_control_lifecycle_is_repeatable_and_fail_closed() .request( Method::PUT, &format!( - "/api/v1/agent-control-scan-configs/{AGENT_CONTROLLER_SCANNER_ID}" + "/gvm/public/v1/agent-control-scan-configs/{AGENT_CONTROLLER_SCANNER_ID}" ), ) .bearer_auth(token) @@ -132,7 +132,7 @@ async fn rest_enterprise_agent_control_lifecycle_is_repeatable_and_fail_closed() assert_empty( harness - .request(Method::POST, "/api/v1/agents/sync") + .request(Method::POST, "/gvm/public/v1/agents/sync") .bearer_auth(token) .send() .await?, @@ -143,7 +143,7 @@ async fn rest_enterprise_agent_control_lifecycle_is_repeatable_and_fail_closed() let synchronized = get_json( &harness, Method::GET, - &format!("/api/v1/agents/{agent_id}"), + &format!("/gvm/public/v1/agents/{agent_id}"), token, StatusCode::OK, ) @@ -167,7 +167,7 @@ async fn rest_enterprise_agent_control_lifecycle_is_repeatable_and_fail_closed() let support = harness .request( Method::GET, - &format!("/api/v1/agents/{agent_id}/support-bundle?days=1&encryption=false"), + &format!("/gvm/public/v1/agents/{agent_id}/support-bundle?days=1&encryption=false"), ) .bearer_auth(token) .send() @@ -195,7 +195,7 @@ async fn rest_enterprise_agent_control_lifecycle_is_repeatable_and_fail_closed() &harness, Method::GET, &format!( - "/api/v1/scanners/{AGENT_CONTROLLER_SCANNER_ID}/agent-installer-instruction?originUrl=https%3A%2F%2Fmanager.example&language=en" + "/gvm/public/v1/scanners/{AGENT_CONTROLLER_SCANNER_ID}/agent-installer-instruction?originUrl=https%3A%2F%2Fmanager.example&language=en" ), token, StatusCode::OK, @@ -211,7 +211,7 @@ async fn rest_enterprise_agent_control_lifecycle_is_repeatable_and_fail_closed() let created = send_json_with_location( &harness, Method::POST, - "/api/v1/agent-groups", + "/gvm/public/v1/agent-groups", token, &json!({ "name": group_name, @@ -220,7 +220,7 @@ async fn rest_enterprise_agent_control_lifecycle_is_repeatable_and_fail_closed() "agentIds": [agent_id] }), StatusCode::CREATED, - "/api/v1/agent-groups/", + "/gvm/public/v1/agent-groups/", ) .await?; let created_group_id = required_string(&created, "id")?.to_string(); @@ -229,7 +229,7 @@ async fn rest_enterprise_agent_control_lifecycle_is_repeatable_and_fail_closed() let modified_group = send_json( &harness, Method::PUT, - &format!("/api/v1/agent-groups/{created_group_id}"), + &format!("/gvm/public/v1/agent-groups/{created_group_id}"), token, &json!({ "name": modified_group_name, @@ -244,7 +244,7 @@ async fn rest_enterprise_agent_control_lifecycle_is_repeatable_and_fail_closed() let listed_groups = get_json( &harness, Method::GET, - "/api/v1/agent-groups?page=1&perPage=100", + "/gvm/public/v1/agent-groups?page=1&perPage=100", token, StatusCode::OK, ) @@ -256,11 +256,11 @@ async fn rest_enterprise_agent_control_lifecycle_is_repeatable_and_fail_closed() let cloned = send_json_with_location( &harness, Method::POST, - &format!("/api/v1/agent-groups/{created_group_id}/clone"), + &format!("/gvm/public/v1/agent-groups/{created_group_id}/clone"), token, &Value::Null, StatusCode::CREATED, - "/api/v1/agent-groups/", + "/gvm/public/v1/agent-groups/", ) .await?; clone_id = Some(required_string(&cloned, "id")?.to_string()); @@ -268,7 +268,7 @@ async fn rest_enterprise_agent_control_lifecycle_is_repeatable_and_fail_closed() let task = send_json_with_location( &harness, Method::POST, - "/api/v1/tasks", + "/gvm/public/v1/tasks", token, &json!({ "name": harness.unique_name("issue-680-agent-backed-scan"), @@ -278,14 +278,14 @@ async fn rest_enterprise_agent_control_lifecycle_is_repeatable_and_fail_closed() "scannerId": AGENT_CONTROLLER_SCANNER_ID }), StatusCode::CREATED, - "/api/v1/tasks/", + "/gvm/public/v1/tasks/", ) .await?; task_id = Some(required_string(&task, "id")?.to_string()); let task_read = get_json( &harness, Method::GET, - &format!("/api/v1/tasks/{}", task_id.as_deref().unwrap_or_default()), + &format!("/gvm/public/v1/tasks/{}", task_id.as_deref().unwrap_or_default()), token, StatusCode::OK, ) @@ -296,7 +296,7 @@ async fn rest_enterprise_agent_control_lifecycle_is_repeatable_and_fail_closed() &harness, Method::POST, &format!( - "/api/v1/tasks/{}/start", + "/gvm/public/v1/tasks/{}/start", task_id.as_deref().unwrap_or_default() ), token, @@ -335,7 +335,7 @@ async fn rest_enterprise_agent_control_lifecycle_is_repeatable_and_fail_closed() ); let report_path = format!( - "/api/v1/reports/{}?page=1&perPage=100", + "/gvm/public/v1/reports/{}?page=1&perPage=100", report_id.as_deref().unwrap_or_default() ); let report = get_json(&harness, Method::GET, &report_path, token, StatusCode::OK).await?; @@ -351,7 +351,7 @@ async fn rest_enterprise_agent_control_lifecycle_is_repeatable_and_fail_closed() ); let results_path = format!( - "/api/v1/reports/{}/results?page=1&perPage=100", + "/gvm/public/v1/reports/{}/results?page=1&perPage=100", report_id.as_deref().unwrap_or_default() ); let results = get_json( @@ -396,11 +396,22 @@ async fn rest_enterprise_agent_control_lifecycle_is_repeatable_and_fail_closed() // Reverse mutation order is intentional: report -> task -> clone -> group -> agent -> session. let report_cleanup = delete_report(&harness, token, report_id.as_deref()).await; - let task_cleanup = delete_resource(&harness, token, "/api/v1/tasks", task_id.as_deref()).await; - let clone_cleanup = - delete_resource(&harness, token, "/api/v1/agent-groups", clone_id.as_deref()).await; - let group_cleanup = - delete_resource(&harness, token, "/api/v1/agent-groups", group_id.as_deref()).await; + let task_cleanup = + delete_resource(&harness, token, "/gvm/public/v1/tasks", task_id.as_deref()).await; + let clone_cleanup = delete_resource( + &harness, + token, + "/gvm/public/v1/agent-groups", + clone_id.as_deref(), + ) + .await; + let group_cleanup = delete_resource( + &harness, + token, + "/gvm/public/v1/agent-groups", + group_id.as_deref(), + ) + .await; let agent_cleanup = match agent_restore { Some((agent_id, restoration)) => { restore_agent(&harness, token, &agent_id, &restoration).await @@ -437,7 +448,7 @@ async fn rest_enterprise_agent_control_lifecycle_is_repeatable_and_fail_closed() async fn assert_route_auth_and_input_failures(harness: &E2eHarness) -> Result<()> { assert_eq!( harness - .request(Method::GET, "/api/v1/agents") + .request(Method::GET, "/gvm/public/v1/agents") .send() .await? .status(), @@ -445,7 +456,7 @@ async fn assert_route_auth_and_input_failures(harness: &E2eHarness) -> Result<() "agents must reject missing authentication before backend access" ); let invalid = harness - .request(Method::GET, "/api/v1/agents?page=0") + .request(Method::GET, "/gvm/public/v1/agents?page=0") .basic_auth(&harness.config.username, Some(&harness.config.password)) .send() .await?; @@ -457,7 +468,7 @@ async fn assert_route_auth_and_input_failures(harness: &E2eHarness) -> Result<() let unmatched = harness .request( Method::GET, - "/api/v1/agents/00000000-0000-0000-0000-000000000000", + "/gvm/public/v1/agents/00000000-0000-0000-0000-000000000000", ) .basic_auth(&harness.config.username, Some(&harness.config.password)) .send() @@ -527,7 +538,7 @@ async fn assert_agent_control_failure_contracts( for (scenario, allowed) in expectations { select_proxy_scenario(harness, &control_url, &control_token, scenario).await?; let response = harness - .request(Method::PUT, &format!("/api/v1/agents/{agent_id}")) + .request(Method::PUT, &format!("/gvm/public/v1/agents/{agent_id}")) .bearer_auth(token) .json(no_op_update) .send() @@ -557,7 +568,7 @@ async fn assert_agent_control_failure_contracts( let after_failure = get_json( harness, Method::GET, - &format!("/api/v1/agents/{agent_id}"), + &format!("/gvm/public/v1/agents/{agent_id}"), token, StatusCode::OK, ) @@ -758,7 +769,7 @@ async fn restore_agent( send_json( harness, Method::PUT, - &format!("/api/v1/agents/{id}"), + &format!("/gvm/public/v1/agents/{id}"), token, restoration, StatusCode::OK, @@ -788,7 +799,7 @@ async fn delete_resource( async fn delete_report(harness: &E2eHarness, token: &str, id: Option<&str>) -> Result<()> { let Some(id) = id else { return Ok(()) }; - let path = format!("/api/v1/reports/{id}"); + let path = format!("/gvm/public/v1/reports/{id}"); let response = harness .request(Method::DELETE, &path) .bearer_auth(token) diff --git a/tests/e2e/tests/rest_identity_admin.rs b/tests/e2e/tests/rest_identity_admin.rs index ae9d988a..c5c8eeae 100644 --- a/tests/e2e/tests/rest_identity_admin.rs +++ b/tests/e2e/tests/rest_identity_admin.rs @@ -112,7 +112,7 @@ async fn rest_identity_group_lifecycle_creates_reads_lists_and_deletes() -> Resu .create_group(&session.token, &group_name) .await .context("create group for identity lifecycle coverage")?; - assert_created_location(&created, "/api/v1/groups"); + assert_created_location(&created, "/gvm/public/v1/groups"); group_id = Some(created.id.clone()); let group = harness.get_group(&session.token, &created.id).await?; diff --git a/tests/e2e/tests/rest_live_mutations.rs b/tests/e2e/tests/rest_live_mutations.rs index 647ae7ad..d76f4e59 100644 --- a/tests/e2e/tests/rest_live_mutations.rs +++ b/tests/e2e/tests/rest_live_mutations.rs @@ -33,7 +33,7 @@ async fn rest_scan_config_live_mutations_replace_read_back_restore_and_delete() ) .await?; scan_config_id = Some(created.id.clone()); - require_created_location(&created, "/api/v1/scan-configs")?; + require_created_location(&created, "/gvm/public/v1/scan-configs")?; let copied = harness.get_scan_config(&session.token, &created.id).await?; ensure!(copied.name == name, "copied scan-config name drifted"); @@ -227,7 +227,7 @@ async fn rest_credential_store_live_mutations_follow_capability_matrix() -> Resu .create_store_backed_credential(&session.token, &request) .await?; credential_id = Some(created.id.clone()); - require_created_location(&created, "/api/v1/credentials")?; + require_created_location(&created, "/gvm/public/v1/credentials")?; let credential = harness .get_credential(&session.token, &created.id) .await?; diff --git a/tests/e2e/tests/rest_negative_contract.rs b/tests/e2e/tests/rest_negative_contract.rs index e3006b4e..d05fb6ea 100644 --- a/tests/e2e/tests/rest_negative_contract.rs +++ b/tests/e2e/tests/rest_negative_contract.rs @@ -16,7 +16,7 @@ async fn rest_negative_contract_returns_problem_responses() -> Result<()> { let run = async { let unknown_route = harness - .request(Method::GET, "/api/v1/does-not-exist") + .request(Method::GET, "/gvm/public/v1/does-not-exist") .bearer_auth(&session.token) .send() .await @@ -26,8 +26,8 @@ async fn rest_negative_contract_returns_problem_responses() -> Result<()> { // Ticket support is intentionally unpublished: authenticated requests // to both former shapes must use the same unknown-route 404 contract. for path in [ - "/api/v1/tickets", - "/api/v1/tickets/123e4567-e89b-12d3-a456-426614174000", + "/gvm/public/v1/tickets", + "/gvm/public/v1/tickets/123e4567-e89b-12d3-a456-426614174000", ] { let removed_ticket_route = harness .request(Method::GET, path) @@ -44,7 +44,7 @@ async fn rest_negative_contract_returns_problem_responses() -> Result<()> { } let method_not_allowed = harness - .request(Method::PATCH, "/api/v1/targets") + .request(Method::PATCH, "/gvm/public/v1/targets") .bearer_auth(&session.token) .send() .await @@ -57,7 +57,7 @@ async fn rest_negative_contract_returns_problem_responses() -> Result<()> { .await?; let report_formats_patch = harness - .request(Method::PATCH, "/api/v1/report-formats") + .request(Method::PATCH, "/gvm/public/v1/report-formats") .bearer_auth(&session.token) .send() .await @@ -70,7 +70,7 @@ async fn rest_negative_contract_returns_problem_responses() -> Result<()> { .await?; let hosts_patch = harness - .request(Method::PATCH, "/api/v1/hosts") + .request(Method::PATCH, "/gvm/public/v1/hosts") .bearer_auth(&session.token) .send() .await @@ -83,7 +83,7 @@ async fn rest_negative_contract_returns_problem_responses() -> Result<()> { .await?; let notes_patch = harness - .request(Method::PATCH, "/api/v1/notes") + .request(Method::PATCH, "/gvm/public/v1/notes") .bearer_auth(&session.token) .send() .await @@ -96,7 +96,7 @@ async fn rest_negative_contract_returns_problem_responses() -> Result<()> { .await?; let overrides_patch = harness - .request(Method::PATCH, "/api/v1/overrides") + .request(Method::PATCH, "/gvm/public/v1/overrides") .bearer_auth(&session.token) .send() .await @@ -109,7 +109,7 @@ async fn rest_negative_contract_returns_problem_responses() -> Result<()> { .await?; let nvts_post = harness - .request(Method::POST, "/api/v1/nvts") + .request(Method::POST, "/gvm/public/v1/nvts") .bearer_auth(&session.token) .send() .await @@ -122,7 +122,7 @@ async fn rest_negative_contract_returns_problem_responses() -> Result<()> { .await?; let nvt_families_post = harness - .request(Method::POST, "/api/v1/nvt-families") + .request(Method::POST, "/gvm/public/v1/nvt-families") .bearer_auth(&session.token) .send() .await @@ -135,7 +135,7 @@ async fn rest_negative_contract_returns_problem_responses() -> Result<()> { .await?; let invalid_uuid = harness - .request(Method::GET, "/api/v1/targets/not-a-uuid") + .request(Method::GET, "/gvm/public/v1/targets/not-a-uuid") .bearer_auth(&session.token) .send() .await @@ -143,7 +143,7 @@ async fn rest_negative_contract_returns_problem_responses() -> Result<()> { assert_problem_response(invalid_uuid, StatusCode::BAD_REQUEST, "invalid UUID").await?; let malformed_json = harness - .request(Method::POST, "/api/v1/targets") + .request(Method::POST, "/gvm/public/v1/targets") .bearer_auth(&session.token) .header(CONTENT_TYPE, "application/json") .body("{") @@ -153,7 +153,10 @@ async fn rest_negative_contract_returns_problem_responses() -> Result<()> { assert_problem_response(malformed_json, StatusCode::BAD_REQUEST, "malformed JSON").await?; let missing_target = harness - .request(Method::GET, &format!("/api/v1/targets/{MISSING_UUID}")) + .request( + Method::GET, + &format!("/gvm/public/v1/targets/{MISSING_UUID}"), + ) .bearer_auth(&session.token) .send() .await diff --git a/tests/e2e/tests/rest_report_import.rs b/tests/e2e/tests/rest_report_import.rs index 1a6e21c5..2e33b4a2 100644 --- a/tests/e2e/tests/rest_report_import.rs +++ b/tests/e2e/tests/rest_report_import.rs @@ -25,13 +25,16 @@ async fn rest_report_import_lifecycle_creates_reads_and_cleans_up() -> Result<() &harness.unique_name("nightly-report-import"), ) .await?; - assert_eq!(task.location, format!("/api/v1/tasks/{}", task.id)); + assert_eq!(task.location, format!("/gvm/public/v1/tasks/{}", task.id)); let report_xml = br#"Compose imported reportissue 570 lifecycle"#; let report = harness .import_report(&session.token, &task.id, Some(false), report_xml) .await?; - assert_eq!(report.location, format!("/api/v1/reports/{}", report.id)); + assert_eq!( + report.location, + format!("/gvm/public/v1/reports/{}", report.id) + ); let readback = harness.get_report(&session.token, &report.id).await?; assert_eq!(readback.id, report.id); diff --git a/tests/e2e/tests/rest_supporting_resources.rs b/tests/e2e/tests/rest_supporting_resources.rs index 399af223..9ea60b2f 100644 --- a/tests/e2e/tests/rest_supporting_resources.rs +++ b/tests/e2e/tests/rest_supporting_resources.rs @@ -193,7 +193,7 @@ async fn rest_supporting_triage_resource_lifecycle_mutates_notes_and_overrides() "created by compose-backed note triage coverage", ) .await?; - assert_created_location(&created_note, "/api/v1/notes"); + assert_created_location(&created_note, "/gvm/public/v1/notes"); note_id = Some(created_note.id.clone()); let created_note_resource = harness.get_note(&session.token, &created_note.id).await?; @@ -239,7 +239,7 @@ async fn rest_supporting_triage_resource_lifecycle_mutates_notes_and_overrides() "0.0", ) .await?; - assert_created_location(&created_override, "/api/v1/overrides"); + assert_created_location(&created_override, "/gvm/public/v1/overrides"); override_id = Some(created_override.id.clone()); let created_override_resource = harness @@ -336,7 +336,7 @@ async fn rest_supporting_scan_config_lifecycle_copies_updates_and_deletes() -> R &base_config.id, ) .await?; - assert_created_location(&created, "/api/v1/scan-configs"); + assert_created_location(&created, "/gvm/public/v1/scan-configs"); scan_config_id = Some(created.id.clone()); let scan_config = harness.get_scan_config(&session.token, &created.id).await?; @@ -390,7 +390,7 @@ async fn rest_supporting_port_list_lifecycle_creates_reads_lists_and_deletes() - let created = harness .create_port_list(&session.token, &port_list_name, "T:1") .await?; - assert_created_location(&created, "/api/v1/port-lists"); + assert_created_location(&created, "/gvm/public/v1/port-lists"); port_list_id = Some(created.id.clone()); let port_list = harness.get_port_list(&session.token, &created.id).await?; @@ -439,7 +439,7 @@ async fn rest_supporting_credential_lifecycle_creates_reads_lists_and_deletes() "nightly-password", ) .await?; - assert_created_location(&created, "/api/v1/credentials"); + assert_created_location(&created, "/gvm/public/v1/credentials"); credential_id = Some(created.id.clone()); let credential = harness.get_credential(&session.token, &created.id).await?; diff --git a/tests/test_docs_inventory.py b/tests/test_docs_inventory.py index a6feb150..b254afc8 100644 --- a/tests/test_docs_inventory.py +++ b/tests/test_docs_inventory.py @@ -25,7 +25,9 @@ def check(self, documented: list[str], implemented: list[str]) -> list[str]: root = Path(temporary) directory = root / "spec/rest-api" directory.mkdir(parents=True) - rows = "\n".join(f"| `POST` | `/api/v1{path}` | Operation |" for path in documented) + rows = "\n".join( + f"| `POST` | `/gvm/public/v1{path}` | Operation |" for path in documented + ) (directory / "openspec.md").write_text(f"#### Credentials\n{rows}\n#### Next\n") with patch.object(CHECK_DOCS, "REPOSITORY_ROOT", root), patch.object( CHECK_DOCS, "curated_routes", return_value={path: {"POST"} for path in implemented}