Module pii_masking

Module pii_masking 

Source
Expand description

§PII Masking Service

Production-ready PII (Personally Identifiable Information) masking stage for the adaptive pipeline. This service provides one-way data anonymization, useful for:

  • Privacy Protection: Removing sensitive data before storage or transmission
  • Compliance: Meeting GDPR, CCPA, HIPAA requirements
  • Testing: Creating safe test data from production datasets
  • Logging: Sanitizing logs before external processing

§Architecture

This implementation demonstrates the complete pattern for creating pipeline stages:

  • Config Struct: PiiMaskingConfig with typed parameters
  • FromParameters: Type-safe extraction from HashMap
  • Service Struct: PiiMaskingService implements StageService
  • Position: PreBinary (must mask before compression/encryption)
  • Reversibility: Non-reversible (Forward masks, Reverse returns error)

§Usage

use adaptive_pipeline::infrastructure::services::PiiMaskingService;
use adaptive_pipeline_domain::services::StageService;

let service = PiiMaskingService::new();
// Used automatically by pipeline when configured with StageType::Transform

§Configuration Parameters

  • patterns (optional): Comma-separated list of PII patterns to mask

    • "email" - Email addresses (user@example.com → @.com)
    • "ssn" - Social Security Numbers (123-45-6789 → --***)
    • "phone" - Phone numbers (555-123-4567 → --****)
    • "credit_card" - Credit card numbers (1234-5678-9012-3456 → ---)
    • "all" - All supported patterns (default)
  • mask_char (optional): Character to use for masking

    • Default: "*"
    • Example: "#", "X"
  • preserve_format (optional): Whether to preserve format separators

    • "true" - Keep separators like @ and - (default)
    • "false" - Mask everything including separators

§Performance Characteristics

  • Throughput: ~200 MB/s for typical mixed content
  • Overhead: Minimal, regex-based pattern matching
  • Memory: Constant overhead, no buffering required
  • Latency: Single-pass algorithm with compiled regex patterns

Structs§

PiiMaskingConfig
Configuration for PII masking operations.
PiiMaskingService
Production PII masking service.

Enums§

PiiPattern
PII pattern types that can be masked.