

GitHub - ssrathi/go-scrub: A scrubbing utility to hide sensitive fields from a s...
source link: https://github.com/ssrathi/go-scrub
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

go-scrub
A scrubbing utility in Golang to hide sensitive fields from a struct prior to logging.
Since the scrubbing utility function needs to work on any Golang struct where its fields and members are known only at runtime, we can leverage "reflect", a powerful package from the Golang standard library, to scrub sensitive fields at any level of a deeply nested structure recursively.
Installation
go install github.com/ssrathi/go-scrub@latest
Usage
import "github.com/ssrathi/go-scrub" // Have a struct with some sensitive fields. type testScrub struct { Username string Password string Codes []string } // Create a struct with some sensitive data. T := testScrub{ Username: "administrator", Password: "my_secret_passphrase", Codes: []string{"pass1", "pass2", "pass3"}, } // Create a set of field names to scrub (default is 'password'). fieldsToScrub := map[string]bool{ "password": true, "codes": true, } // Call the util API to get a JSON formatted string with scrubbed field values. out := scrub.Scrub(&T, fieldsToScrub) // Log the scrubbed string without worrying about prying eyes! log.Println(out) OUTPUT: {"Username":"administrator","Password":"********","Codes":["********","********","********"]}
Contributing
Contributions are most welcome! Please create a new issue and link your PR to it.
Recommend
-
6
Scrubbing URL fragments from Sentry crash reports Scrubbing URL fragments from Sentry crash reports e2ee typescript web...
-
4
Some accused in Capitol riot reportedly tried to scrub info from their phones and social media The AP reports dozens of the January 6th defendants tried to erase images, videos, a...
-
5
Media Bar lets you scrub your music or podcasts by swiping on your status barBringing additional functionalities on our devices through third-party apps is something Android enthusiasts have been doing for a while. Power users are al...
-
7
Netflix now lets you scrub your Continue Watching carousel clean, right on your TV By Daniel Allen Published 4 hours ago ...
-
7
How to scrub sensitive photo metadata using ExifTool Protect your privacy while retaining image settings 22 Jan...
-
9
Ukrainians Are Scrubbing Open-Source Maps To Keep Intel From Russia's Army 7145 members Technology The latest news,...
-
7
Get Speidel’s soft silicone Scrub Band for Apple Watch for just $6
-
5
GoogleWhy Google Is Scrubbing Personal Info From Search Results (if You Ask Nicely)Google's public search liaison explained in...
-
3
Scrubbing sensitive data at 180MiB/sec/coreRedacting sensitive data from traces with static analysis and JSON tokenization.06/08/239 Min Read"RING RING RING! RING...
-
5
XFS online filesystem scrubbing and repair This article brought to you by LWN subscribersSubscribers to LWN.net made this article — and everything that surrounds it...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK