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

#2130 in Procedural macros

Download history 311/week @ 2024-09-25 286/week @ 2024-10-02 100/week @ 2024-10-09 122/week @ 2024-10-16 90/week @ 2024-10-23 71/week @ 2024-10-30 82/week @ 2024-11-06 282/week @ 2024-11-13 170/week @ 2024-11-20 185/week @ 2024-11-27 151/week @ 2024-12-04 135/week @ 2024-12-11 128/week @ 2024-12-18 79/week @ 2024-12-25 52/week @ 2025-01-01 168/week @ 2025-01-08

452 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

~225–680KB
~16K SLoC