Show HN: Detect and mask PII, payment data and secrets in logs for Go github.com...

@show

Show HN: Detect and mask PII, payment data and secrets in logs for Go github.com · 2 points · 1 comments · HN thread

TL;DR embargo is a Go library (v0.17.0, standard-library-only root module) that masks secrets and personal data such as API keys, card numbers, emails and IPs at the point where a program writes logs, errors, HTTP access logs and traces. It offers a Secret type that always prints [REDACTED], an slog handler, MaskJSON, adapters for zap, zerolog, logrus, gRPC, OpenTelemetry and Sentry, and an embargotest package that fails CI tests when fake canaries leak. The README reports benchmarks and leak-test results against several other Go masking libraries.

  • Secret values print as [REDACTED] through fmt, encoding/json, encoding/xml, text/template and logger output, and Reveal() returns the raw value.
  • embargo.NewSlogHandler wraps any slog handler; the README example masks email and password fields while keeping request_id.
  • 39 built-in detectors, 19 on by default; country-specific ones such as My Number or US routing numbers are opt-in via WithMoreKinds or WithAll.
  • embargotest.Guard can be added to a package's TestMain to fail tests when a fake secret or detected value appears in stdout, stderr, slog output or child processes.
  • The README claims its default scanner is 2.07 to 4.22 times faster than pii-shield's default policy, and reports a 99.4% test coverage and 89.18% mutation score, though these are the author's own measurements.
  • The command-line tool masks log files or piped input line by line and can print per-kind counts without printing matched values.

Discussion The thread is very small: one comment, from a user asking whether the library relies on pattern matching or machine learning. There is no substantive discussion of the project's design, benchmarks or security claims, and the mood is neutral and curious.

  • Asks whether detection is pattern-based or ML-based (most): The only comment asks how embargo finds PII, distinguishing regex or rule-based scanning from machine learning. The README answers this indirectly: detectors validate values with formats and checksums such as Luhn, and there is no ML mentioned.
  • Pseudonymization with reversible tokens is an alternative (a few): The same commenter shares their own earlier project that pseudonymized PII with cryptography so it could be reversed later, linking a blog post on blind pseudonymization. This differs from embargo's approach, which masks values irreversibly.

Links from the comments

#golang #logging #pii #secrets #privacy #opensource