Skip to content
Snippets Groups Projects
Commit d2bfcb01 authored by Timo Kösters's avatar Timo Kösters
Browse files

Merge branch 'error-leak-fix' into 'next'

sanitise potentially sensitive errors

See merge request famedly/conduit!523
parents 08f0f17f 83805c66
No related branches found
No related tags found
No related merge requests found
......@@ -927,7 +927,7 @@ pub async fn send_transaction_message_route(
Ok(send_transaction_message::v1::Response {
pdus: resolved_map
.into_iter()
.map(|(e, r)| (e, r.map_err(|e| e.to_string())))
.map(|(e, r)| (e, r.map_err(|e| e.sanitized_error())))
.collect(),
})
}
......
......@@ -138,6 +138,28 @@ pub fn to_response(&self) -> RumaResponse<UiaaResponse> {
status_code,
}))
}
/// Sanitizes public-facing errors that can leak sensitive information.
pub fn sanitized_error(&self) -> String {
let db_error = String::from("Database or I/O error occurred.");
match self {
#[cfg(feature = "sled")]
Self::SledError { .. } => db_error,
#[cfg(feature = "sqlite")]
Self::SqliteError { .. } => db_error,
#[cfg(feature = "persy")]
Self::PersyError { .. } => db_error,
#[cfg(feature = "heed")]
Self::HeedError => db_error,
#[cfg(feature = "rocksdb")]
Self::RocksDbError { .. } => db_error,
Self::IoError { .. } => db_error,
Self::BadConfig { .. } => db_error,
Self::BadDatabase { .. } => db_error,
_ => self.to_string(),
}
}
}
#[cfg(feature = "persy")]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment