Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion crates/gvm-gateway-app/src/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
6 changes: 3 additions & 3 deletions crates/gvm-gateway-gvmd/src/conversions_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions crates/gvm-gateway-gvmd/tests/architecture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
4 changes: 2 additions & 2 deletions crates/gvm-gateway-gvmd/tests/gvmd_adapter_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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();
Expand Down
12 changes: 9 additions & 3 deletions crates/gvm-gateway-rest/src/active_directory_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
30 changes: 15 additions & 15 deletions crates/gvm-gateway-rest/src/agents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1264,7 +1264,7 @@ fn support_bundle_response<T>(mut response: TransformResponse<T>) -> 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::<AgentListResponse>(
op.input::<Query<AgentListQueryParams>>(),
Expand All @@ -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::<AgentResponse>(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::<ModifyAgentRequest, AgentResponse>(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")
Expand All @@ -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<'_> {
Expand Down Expand Up @@ -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<'_> {
Expand Down Expand Up @@ -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::<AgentGroupListResponse>(
op.input::<Query<AgentGroupListQueryParams>>(),
Expand All @@ -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::<CreateAgentGroupRequest>(
op,
Expand All @@ -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::<AgentGroupResponse>(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::<ModifyAgentGroupRequest, AgentGroupResponse>(
op,
Expand All @@ -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,
Expand All @@ -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")
Expand Down
26 changes: 13 additions & 13 deletions crates/gvm-gateway-rest/src/auth_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,52 +22,52 @@ 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<RestRouteAuthPolicy> {
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);
}

if *method == Method::POST && is_report_export_job_collection(path) {
return Some(RestRouteAuthPolicy::BearerOnly);
}

if path.starts_with("/api/v1/") {
if path.starts_with("/gvm/public/v1/") {
return Some(RestRouteAuthPolicy::Protected);
}

None
}

fn is_report_export_job_collection(path: &str) -> 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('/'))
}

/// 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}"),
}
}

Expand Down
Loading
Loading