In enterprise software delivery (especially banking, healthcare, and global SaaS), Personally Identifiable Information (PII) protection is a non-negotiable security requirement:
- Plaintext Logging: Developers casually logging raw phone numbers or national IDs, leaking PII to centralized Elasticsearch/Datadog clusters;
- Unredacted UI Responses: Unprivileged support operators viewing unmasked customer credit card numbers.
BitzOrcas.Modern includes an embedded IDataMasker engine and [Masked] contract attributes: Dynamically masking sensitive values during JSON serialization, logging, and audit persistence.
Data Masking Lifecycle and PII Defense
Step 1: Declaring Masked Fields on Contracts
Annotate sensitive fields with [Masked]:
using BitzOrcas.Application.Abstractions.Security;
namespace BitzOrcas.Identity.Contracts.Dtos;
public sealed record UserProfileDto{ public string UserId { get; init; } = string.Empty; public string FullName { get; init; } = string.Empty;
// Phone masking: preserves first 3 and last 4 digits (e.g. 138****5678) [Masked(MaskType.PhoneNumber)] public string PhoneNumber { get; init; } = string.Empty;
// Email masking: preserves prefix and domain (e.g. a***z@corp.com) [Masked(MaskType.Email)] public string Email { get; init; } = string.Empty;}Step 2: Sanitizing Audit Entries via IDataMasker
using BitzOrcas.Application.Abstractions.Security;
public static class AuditLoggingExtensions{ public static string ToSafeLogString(this string rawPhone, IDataMasker masker) { // 1. In-memory masking with minimal heap allocation var masked = masker.MaskPhoneNumber(rawPhone);
// 2. Return sanitized string safe for centralized logging return masked; }}Summary
IDataMasker fortifies platform privacy:
- Declarative Attributes: Clean, readable property annotations;
- Zero PII Leaks: Sanitized logs, traces, and external APIs by default;
- Audit-Ready Compliance: Meets strict GDPR and financial security audits out of the box.