#sensitive #derive-debug #debugging #macro-derive #replace #fields #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

#1636 in Procedural macros

Download history 201/week @ 2024-06-28 334/week @ 2024-07-05 750/week @ 2024-07-12 536/week @ 2024-07-19 477/week @ 2024-07-26 417/week @ 2024-08-02 286/week @ 2024-08-09 437/week @ 2024-08-16 406/week @ 2024-08-23 310/week @ 2024-08-30 343/week @ 2024-09-06 399/week @ 2024-09-13 290/week @ 2024-09-20 334/week @ 2024-09-27 190/week @ 2024-10-04 78/week @ 2024-10-11

937 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

~270–720KB
~17K SLoC