feat(observability): mask pii in structured logs - #255
Merged
Conversation
Add a shared fincore-observability module with a pure, ReDoS-safe PiiMasker (emails, bearer tokens, 13+ digit runs -> [REDACTED]) and a Boot StructuredLoggingJsonMembersCustomizer that applies it to string members of the logstash JSON output while leaving correlation_id, trace_id and span_id intact. Wired into ledger, payments and decision via a one-line logging.structured.json.customizer registration, so the existing structured-log shape is preserved. Closes #247
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds best-effort PII masking to the structured logs across all three services (E-07, #247).
What
libs/fincore-observabilitywith:PiiMasker- a pure, ReDoS-safe masker (emails, bearer tokens, 13+ digit runs ->[REDACTED]). All three regexes use single bounded quantifiers (no catastrophic backtracking). The 13+ digit rule masks PAN/account/long-id runs (including 20+) but never a UUID's fixed 12-digit node group.PiiMaskingMembersCustomizer- a BootStructuredLoggingJsonMembersCustomizerthat applies the masker to string members of the logstash JSON, skippingcorrelation_id/trace_id/span_id.logging.structured.json.customizerline each, so the existing structured-log JSON shape is preserved (nologback-spring.xml, consistent with F-07.2 Correlation-id and MDC logging parity for payments and decision #246).Why this hook
The services emit JSON via Boot-native
StructuredLogEncoder("logstash"), not the net.logstash encoder. The Boot 3.5.15StructuredLoggingJsonMembersCustomizer+JsonWriter.ValueProcessorAPI (verified against the jar) lets us rewrite member values in-place without reconstructing the appender, keeping the JSON contract intact.Verification
correlation_id/trace_id/span_idsurvive byte-for-byte and the JSON shape holds) - all green locally (no Docker needed).Gate chain
git log main..HEADis empty) and its two advisory test gaps were adopted.Closes #247