Skip to content

add the ability for users to select & create custom PII attribute rules for source data going to target #62

@MaximumTrainer

Description

@MaximumTrainer

Role: You are a Senior Software Architect and Kotlin Specialist.

Project Context: We are working on the OpenDataMask repository. The current objective is to evolve the tool from fixed masking logic to a dynamic, configuration-driven system for PII protection.

The Goal: Build a feature that allows users to select and create custom PII attribute rules for source data attributes as they transition to a target destination.

Functional Requirements:

PII Rule Definition: Implement a PIIMaskingRule interface. Each rule should have a unique ID and a mask(input: Any?): Any? function.

Rule Library: Provide a set of default implementations:

RedactRule (e.g., replaces everything with [REDACTED]).

PartialMaskRule (e.g., shows last 4 digits of a CC or first letter of an email).

HashRule (e.g., SHA-256 with an optional salt).

RegexRule (allows users to define a custom regex and a replacement string).

Mapping Configuration: Create a mechanism (JSON/YAML/DSL) to map source_attribute_name to a specific rule_id.

Example Mapping: {"source": "email", "target": "masked_email", "rule": "partial_email_mask"}.

Custom Customer Rules: Allow for "Customer-defined" rules that can be injected at runtime. These might be complex rules specific to a business case (e.g., "If the user is in the EU, use Rule A; otherwise, use Rule B").

Transformation Engine: Integrate this mapping into the core data flow. As the tool reads from the source, it should lookup the mapping and apply the corresponding rule before writing to the target.

Technical Requirements:

Language: Idiomatic Kotlin (use Sealed Classes for rule types and Coroutines for performance if applicable).

Extensibility: Use a RuleRegistry pattern so new "Customer PII Rules" can be added without modifying the core engine.

Blackbox Integrity: Maintain the "blackbox" nature by ensuring the engine can handle unknown attributes gracefully (e.g., a default "PassThrough" rule).

Please Provide:

The core Kotlin interfaces and classes for this architecture.

A sample JSON configuration file demonstrating a mapping for a Customer dataset (Name, Email, SSN, and TransactionAmount).

A code example showing how a user would register a "Custom Rule" for a specific business logic.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions