#sensitive #derive-debug #debugging #macro-derive #fields #secret #marked

macro securefmt

Drop-in replacement for the Debug derive macro that hides fields marked as sensitive

6 releases

0.1.5 Sep 14, 2024
0.1.4 May 7, 2021
0.1.2 Apr 25, 2021
0.1.1 Mar 21, 2021

#1920 in Procedural macros

Download history 526/week @ 2024-07-29 366/week @ 2024-08-05 283/week @ 2024-08-12 503/week @ 2024-08-19 430/week @ 2024-08-26 207/week @ 2024-09-02 492/week @ 2024-09-09 274/week @ 2024-09-16 321/week @ 2024-09-23 305/week @ 2024-09-30 157/week @ 2024-10-07 86/week @ 2024-10-14 111/week @ 2024-10-21 92/week @ 2024-10-28 60/week @ 2024-11-04 152/week @ 2024-11-11

416 downloads per month
Used in camo-url

BSD-3-Clause

28KB
660 lines

securefmt

Build Status Latest Version Docs

Drop-in replacement for the Debug derive macro that hides fields marked as sensitive.

Example

The following code snippet

#[derive(Debug)]
struct SensitiveData {
    id: u8,
    #[sensitive]
    secret: u8
}

fn main() {
    println!("{:?}", SensitiveData { id: 1, secret: 42 })
}

will print:

SensitiveData { id: 1, secret: <redacted> }

If the [debug_mode] feature is active, the same code will print:

WARN - WARNING: securefmt debug_mode feature is active. Sensitive data may be leaked. It is strongly recommended to disable debug_mode in production releases.
SensitiveData { id: 1, secret: 42 }

Dependencies

~245–700KB
~16K SLoC