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

Mark database fields as sensitive so they dont show up in logs #4720

Merged
merged 9 commits into from
May 17, 2024

Conversation

Nutomic
Copy link
Member

@Nutomic Nutomic commented May 15, 2024

No description provided.

#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize, Default)]
#[cfg_attr(feature = "full", derive(DieselNewType))]
#[serde(transparent)]
pub struct SensitiveString(String);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generic here was completely unnecessary as it was only used for strings. Also a few of the impls were unused so I removed them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine.

Copy link
Member

@dessalines dessalines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why it was previously in api_common, rather than the DB crate, but nothing looked missing in the diff.

#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize, Default)]
#[cfg_attr(feature = "full", derive(DieselNewType))]
#[serde(transparent)]
pub struct SensitiveString(String);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine.

@dessalines
Copy link
Member

Clippy is failing, probably missing an into_inner()

crates/apub/src/objects/community.rs Outdated Show resolved Hide resolved
crates/apub/src/objects/instance.rs Outdated Show resolved Hide resolved
crates/apub/src/objects/person.rs Outdated Show resolved Hide resolved
dessalines and others added 4 commits May 16, 2024 16:42
Co-authored-by: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com>
Co-authored-by: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com>
Co-authored-by: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com>
@dessalines dessalines enabled auto-merge (squash) May 16, 2024 20:43
@SleeplessOne1917
Copy link
Member

Looks like I made a mistake with my clippy fix suggestions. It turns out the SensitiveString type isn't being imported in the files I commented on:

error[E0433]: failed to resolve: use of undeclared type `SensitiveString`
   --> crates/apub/src/objects/person.rs:203:34
    |
203 |     self.private_key.clone().map(SensitiveString::into_inner)
    |                                  ^^^^^^^^^^^^^^^ use of undeclared type `SensitiveString`
    |
help: consider importing this struct
    |
1   + use lemmy_db_schema::sensitive::SensitiveString;
    |

@dessalines
Copy link
Member

No probs, I'll get.

@dessalines dessalines merged commit 99aac07 into main May 17, 2024
2 checks passed
@SleeplessOne1917 SleeplessOne1917 deleted the db-fields-sensitive branch May 17, 2024 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants