feat(onboarding): enable opt-in scans from the wizard success step (#181)
This commit was merged in pull request #181.
This commit is contained in:
@@ -78,8 +78,16 @@ pub fn validate_artifact_ref(kind: &str, source_ref: &str) -> Option<String> {
|
||||
.then(|| "Enter a git URL — https://…, ssh://…, or git@host:path".to_string())
|
||||
}
|
||||
"live_url" => {
|
||||
let ok = (s.starts_with("https://") || s.starts_with("http://")) && no_space;
|
||||
(!ok).then(|| "Enter an http(s) URL, e.g. https://app.example.com".to_string())
|
||||
// http(s) for web/DAST targets; modbus:// and opc.tcp:// for ICS
|
||||
// devices probed by the ICS probe (e.g. modbus://plc:502).
|
||||
let ok = (s.starts_with("https://")
|
||||
|| s.starts_with("http://")
|
||||
|| s.starts_with("modbus://")
|
||||
|| s.starts_with("opc.tcp://"))
|
||||
&& no_space;
|
||||
(!ok).then(|| {
|
||||
"Enter a URL — https://app.example.com, or modbus://host:502 for a PLC".to_string()
|
||||
})
|
||||
}
|
||||
"container_image" => {
|
||||
(!no_space).then(|| "Enter an image ref, e.g. registry/name:tag".to_string())
|
||||
@@ -196,6 +204,28 @@ pub async fn update_target(
|
||||
.map_err(|e| ServerFnError::new(e.to_string()))
|
||||
}
|
||||
|
||||
/// Enable specific opt-in scans on a target by setting `scan_config.enabled_scans`.
|
||||
/// `scans` are serde scan-type names (lowercase, no underscores — e.g. `icsprobe`).
|
||||
#[server]
|
||||
pub async fn enable_target_scans(
|
||||
id: String,
|
||||
scans: Vec<String>,
|
||||
) -> Result<TargetResponse, ServerFnError> {
|
||||
let body = serde_json::json!({ "scan_config": { "enabled_scans": scans } });
|
||||
let resp = super::agent_client::agent_request(
|
||||
reqwest::Method::PATCH,
|
||||
&format!("/api/v1/targets/{id}"),
|
||||
)
|
||||
.await?
|
||||
.json(&body)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| ServerFnError::new(e.to_string()))?;
|
||||
resp.json()
|
||||
.await
|
||||
.map_err(|e| ServerFnError::new(e.to_string()))
|
||||
}
|
||||
|
||||
/// Run kind-based classification on a target.
|
||||
#[server]
|
||||
pub async fn detect_target(id: String) -> Result<TargetResponse, ServerFnError> {
|
||||
|
||||
Reference in New Issue
Block a user