events: Don't include sensitive data in Debug-format of to-device events

This commit is contained in:
Kévin Commaille 2022-11-06 14:05:50 +01:00 committed by Kévin Commaille
parent f364b41844
commit 5158dbf2eb
3 changed files with 21 additions and 3 deletions

View File

@ -4,6 +4,8 @@ Bug fixes:
* HTML-relevant characters (`<`, `>`, etc) in plaintext replies are now escaped
during creation of the rich reply
* Don't include sensitive information in `Debug`-format of types from the `events::key`
and `events::secret` modules
Breaking changes:

View File

@ -2,7 +2,7 @@
//!
//! [`m.key.verification.start`]: https://spec.matrix.org/v1.4/client-server-api/#mkeyverificationstart
use std::collections::BTreeMap;
use std::{collections::BTreeMap, fmt};
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize};
@ -109,7 +109,7 @@ pub struct _CustomContent {
}
/// The payload of an `m.key.verification.start` event using the `m.sas.v1` method.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[derive(Clone, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[serde(rename = "m.reciprocate.v1", tag = "method")]
pub struct ReciprocateV1Content {
@ -126,6 +126,12 @@ impl ReciprocateV1Content {
}
}
impl fmt::Debug for ReciprocateV1Content {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ReciprocateV1Content").finish_non_exhaustive()
}
}
/// The payload of an `m.key.verification.start` event using the `m.sas.v1` method.
///
/// To create an instance of this type, first create a `SasV1ContentInit` and convert it via

View File

@ -2,6 +2,8 @@
//!
//! [`m.secret.send`]: https://spec.matrix.org/v1.4/client-server-api/#msecretsend
use std::fmt;
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize};
@ -13,7 +15,7 @@ use crate::OwnedTransactionId;
/// `m.secret.request` event.
///
/// It must be encrypted as an `m.room.encrypted` event, then sent as a to-device event.
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[derive(Clone, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.secret.send", kind = ToDevice)]
pub struct ToDeviceSecretSendEventContent {
@ -30,3 +32,11 @@ impl ToDeviceSecretSendEventContent {
Self { request_id, secret }
}
}
impl fmt::Debug for ToDeviceSecretSendEventContent {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ToDeviceSecretSendEventContent")
.field("request_id", &self.request_id)
.finish_non_exhaustive()
}
}