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
5 changes: 1 addition & 4 deletions modules/exploit-intelligence/src/runner/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ async fn upload_sbom(

let response = classify_response_error(label, request.send().await)
.await
.map_err(|e| {
tracing::warn!(error = %e, label, "EI upload failed");
AnalysisError::from(e)
})?;
.map_err(AnalysisError::from)?;

Ok(response)
}
Expand Down
21 changes: 3 additions & 18 deletions modules/exploit-intelligence/src/runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,6 @@ pub(crate) enum EiRequestError {
Permanent(anyhow::Error),
}

impl EiRequestError {
/// User-facing error message suitable for storing in the database.
/// Transient errors get a generic message; rejected errors surface
/// the EI response so users can fix their input.
pub(crate) fn user_message(&self) -> String {
match self {
Self::Transient(_) => "analysis service temporarily unavailable".to_string(),
Self::Rejected(msg) => msg.clone(),
Self::Permanent(_) => "internal analysis error".to_string(),
}
}
}

/// Error from a single analysis tick, classified for retry decisions.
#[derive(Debug, thiserror::Error)]
pub(crate) enum AnalysisError {
Expand Down Expand Up @@ -74,12 +61,10 @@ impl From<crate::Error> for AnalysisError {

impl From<EiRequestError> for AnalysisError {
fn from(e: EiRequestError) -> Self {
let msg = e.user_message();
match e {
EiRequestError::Transient(_) => Self::Retryable(anyhow::anyhow!("{msg}")),
EiRequestError::Rejected(_) | EiRequestError::Permanent(_) => {
Self::Permanent(anyhow::anyhow!("{msg}"))
}
EiRequestError::Transient(detail) => Self::Retryable(anyhow::anyhow!("{detail}")),
EiRequestError::Rejected(detail) => Self::Permanent(anyhow::anyhow!("{detail}")),
EiRequestError::Permanent(err) => Self::Permanent(err),
}
}
}
Expand Down
Loading