-
Notifications
You must be signed in to change notification settings - Fork 0
fix(security): remove email from adapter logs for GDPR data minimization #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <AssemblyName>Compendium.Adapters.Shared</AssemblyName> | ||
| <RootNamespace>Compendium.Adapters.Shared</RootNamespace> | ||
| <PackageId>Compendium.Adapters.Shared</PackageId> | ||
| <Description>Shared utilities for Compendium adapters: PII masking helpers, logging conventions.</Description> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| // ----------------------------------------------------------------------- | ||
| // <copyright file="PiiMasking.cs" company="Sassy Solutions"> | ||
| // Copyright (c) 2026 Sassy Solutions. Licensed under the MIT License. | ||
| // See LICENSE in the project root for license information. | ||
| // </copyright> | ||
| // ----------------------------------------------------------------------- | ||
|
|
||
| namespace Compendium.Adapters.Shared.Logging; | ||
|
|
||
| /// <summary> | ||
| /// PII masking helpers for log statements. Use sparingly — prefer non-PII identifiers | ||
| /// (subscriber_id, customer_id, activity_id) over masked PII per GDPR data-minimization. | ||
| /// </summary> | ||
| public static class PiiMasking | ||
| { | ||
| /// <summary> | ||
| /// Masks an email for logging: "john.doe@acme.com" → "j***@acme.com". | ||
| /// Returns "<empty>" or "<null>" for non-values. | ||
| /// Use only when subscriber_id/customer_id is unavailable AND email correlation is required for debugging. | ||
| /// </summary> | ||
| /// <param name="email">The email to mask.</param> | ||
| /// <returns>Masked email, or a placeholder for empty/invalid input.</returns> | ||
| public static string MaskEmail(string? email) | ||
| { | ||
| if (string.IsNullOrWhiteSpace(email)) return "<empty>"; | ||
| var atIndex = email.IndexOf('@'); | ||
| if (atIndex <= 0) return "***"; | ||
| return $"{email[0]}***{email[atIndex..]}"; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,7 +136,7 @@ public async Task<Result<IdentityUser>> GetUserByEmailAsync( | |
|
|
||
| // POM-170: debug logs also flow into centralised log stores, so use the | ||
| // short hash here as well. | ||
| _logger.LogDebug("Getting user by email (hash {EmailHashPrefix})", HashPrefix(email)); | ||
| _logger.LogDebug("Getting user by email (hash {HashPrefix})", HashPrefix(email)); | ||
|
||
|
|
||
| var searchRequest = new ZitadelUserSearchRequest | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The XML docs say this returns "" or "" for non-values, but the implementation returns "" for both null and whitespace, and returns "***" for invalid formats (no '@'). Please align the docs with the actual behavior, or update the implementation to distinguish null vs empty (and document the invalid-email case).