nixys / nxs-data-anonymizer

A tool for anonymizing PostgreSQL and MySQL databases' dump
Apache License 2.0
233 stars 10 forks source link

how to change the default string for a type #40

Closed steverweber closed 3 months ago

steverweber commented 3 months ago

Trying to change the default string "randomized string data" to something shorter "hidden".

The following is what i tried... but no luck. Perhaps the documents could use a hint in the example? or I just have the wrong idea on how to change it.

Thanks!

security:
  policy:
    tables: skip
    columns: randomize
  exceptions:
    tables:
      - public.occurance_occurance
    columns:
      - id
      - student_id
      - faculty
  defaults:
    columns:
      password:
        value: "{{- randAlphaNum 50 | nospace | lower -}}"
    types:
      - regex: "(?i)^char\\((\\d+)\\)|^char "
        rule:
          type: character
          value: hidden
      - regex: "(?i)^text "
        rule:
          type: text
          value: hidden
AndreiMuvila commented 3 months ago

Hello. Replace the "types" block with the following, this should solve your problem.

    types:
      - regex: "(?i)^character"
        rule:
          type: template
          value: hidden
      - regex: "(?i)^text"
        rule:
          type: template
          value: hidden
steverweber commented 3 months ago

success thanks! /resolved

included a little trick if anyone comes searching for some way to use a hash to hide data using sha256sum yet keep data struct.

security:
  policy:
    tables: skip
    columns: randomize
  exceptions:
    tables:
      - public.occurance
    columns:
      - id
      - date_created
      - student_id
      - illness_severity
      - illness_start
      - illness_end
  defaults:
    types:
      - { "rule": { "type": "template", "value": "hidden" }, "regex": "(?i)^character" }
      - { "rule": { "type": "template", "value": "hidden" }, "regex": "(?i)^text" }
filters:
  public.occurance:
    columns:
      student_id:
        # salted hash on ID so records are still groupable
        value: "{{- cat \"saltsecret123123123\" .Values.student_id | sha256sum -}}"