piiremover

package
v0.2.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

README


title: PII Remover Plugin

Removes or masks Personally Identifiable Information (PII) from query results.

Type

  • Interceptor

Description

Scans and removes/masks PII data from query results based on field patterns and custom detection rules.

Configuration

Below is an example of different regex rules, you dont need to use them all, just pick that you need or add a new one by yourself.

pii_remover:
  fields:                    # Fields to check for PII
    - "*.email"
    - "users.phone"          #users is column that could have json or child property: phone
    - "*.credit_card"        
  replacement: "[REDACTED]"  # Replacement text for PII values
  detection_rules:          # Custom regex patterns for PII detection    
    credit_card: |
        "\d{4}-\d{4}-\d{4}-\d{4}"
    phone: |
        "\+?\d{10,12}"
    ssn: |
        "^\d{3}-\d{2}-\d{4}$"
    us_address: |
        "^(?:\d{1,5})\s[A-Za-z0-9\s\.,]{5,}(?:Avenue|Ave|Street|St|Road|Rd|Boulevard|Blvd|Lane|Ln|Drive|Dr|Way|Court|Ct|Circle|Cir|Trail|Trl)[\s,]*(?:[A-Za-z\s]{2,})?[,\s]+(?:A[KLRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|P[AR]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY])[,\s]+\d{5}(?:-\d{4})?$"
    email: |
        "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b"
    ipv4: |
        "\b(?:\d{1,3}\.){3}\d{1,3}\b"
    ipv6: |
        "\b(?:[A-Fa-f0-9]{1,4}:){7}[A-Fa-f0-9]{1,4}\b"
    iban: |
        "\b[A-Z]{2}\d{2}[A-Z0-9]{11,30}\b"
    swift: |
        "\b[A-Z]{6}[A-Z0-9]{2}([A-Z0-9]{3})?\b"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(config Config) (plugins.Interceptor, error)

Types

type Config

type Config struct {
	// Fields specifies which fields should be checked for PII
	// Can use wildcards, e.g., "user.*" or "*_email"
	Fields []string `yaml:"fields"`

	// Replacement is the string to use instead of PII values
	// Default: "[REDACTED]"
	Replacement string `yaml:"replacement"`

	// DetectionRules defines custom regex patterns for PII detection
	DetectionRules map[string]string `yaml:"detection_rules"`
}

Config represents PII removal configuration

func (Config) Doc

func (c Config) Doc() string

func (Config) Tag

func (c Config) Tag() string

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

func (*Plugin) Doc

func (p *Plugin) Doc() string

func (*Plugin) Process

func (p *Plugin) Process(data map[string]any, context map[string][]string) (processed map[string]any, skipped bool)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL