Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Hide sensitive information from fmt::Debug for: #630

Merged
merged 3 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions src/types/api/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ impl fmt::Debug for AuthRequest {
.field("password", &"<SENSITIVE>")
.field("gdpr_consent", gdpr_consent)
.finish(),
Self::LoginWithToken { token } => f
Self::LoginWithToken { token: _ } => f
.debug_struct("LoginWithToken")
.field("token", token)
.field("token", &"<SENSITIVE>")
.finish(),
}
}
Expand Down
13 changes: 12 additions & 1 deletion src/types/api/response.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use core::fmt;

use crate::types::{
addon::Descriptor,
library::LibraryItem,
Expand Down Expand Up @@ -31,13 +33,22 @@ pub struct CollectionResponse {
pub last_modified: DateTime<Utc>,
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Serialize, Deserialize)]
pub struct AuthResponse {
#[serde(rename = "authKey")]
pub key: AuthKey,
pub user: User,
}

impl fmt::Debug for AuthResponse {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("AuthResponse")
.field("key", &"<SENSITIVE>")
.field("user", &self.user)
.finish()
}
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DataExportResponse {
Expand Down
13 changes: 12 additions & 1 deletion src/types/profile/user.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use core::fmt;

#[cfg(test)]
use chrono::offset::TimeZone;
use chrono::serde::ts_seconds;
Expand All @@ -8,7 +10,7 @@ use serde::{Deserialize, Serialize};
use serde_with::{serde_as, DefaultOnError, DefaultOnNull, DurationSeconds, NoneAsEmptyString};

#[serde_as]
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(test, derive(Derivative))]
#[cfg_attr(test, derivative(Default))]
pub struct TraktInfo {
Expand All @@ -21,6 +23,15 @@ pub struct TraktInfo {
#[cfg_attr(test, derivative(Default(value = r#"String::from("token")"#)))]
pub access_token: String,
}
impl fmt::Debug for TraktInfo {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("TraktInfo")
.field("created_at", &self.created_at)
.field("expires_in", &self.expires_in)
.field("access_token", &"<SENSITIVE>")
.finish()
}
}

#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
#[cfg_attr(test, derive(Default))]
Expand Down