Skip to content

Commit

Permalink
Add: possibility to provide a scan config with an Scan ID
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnicola committed Jul 18, 2024
1 parent 1f35dc1 commit 32c1770
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions rust/openvasd/src/controller/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,12 @@ where
match crate::request::json_request::<models::Scan, _>(&ctx.response, req).await
{
Ok(mut scan) => {
if !scan.scan_id.is_empty() {
return Ok(ctx
.response
.bad_request("field scan_id is not allowed to be set."));
}
let id = uuid::Uuid::new_v4().to_string();
let id = if scan.scan_id.is_empty() {
uuid::Uuid::new_v4().to_string()
} else {
scan.scan_id.clone()
};

let resp = ctx.response.created(&id);
scan.scan_id.clone_from(&id);
ctx.scheduler.insert_scan(scan).await?;
Expand Down
2 changes: 1 addition & 1 deletion rust/openvasd/src/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ mod tests {
};
let ctx = Arc::new(Context::default());
let resp = post_scan(&scan, Arc::clone(&ctx)).await;
assert_eq!(resp.status(), hyper::http::StatusCode::BAD_REQUEST);
assert_eq!(resp.status(), hyper::http::StatusCode::CREATED);
}

#[tokio::test]
Expand Down

0 comments on commit 32c1770

Please sign in to comment.