class

Triki

Inherits Reference / Object

Standalone Crystal library for the selective rewriting (obfuscation/anonymization) of SQL dumps to protect user privacy.

Supports MySQL, PostgreSQL, and SQL Server dump formats. Parse mysqldump outputs when using the -c option, which includes column names in the INSERT statements.

Constants

DEFAULT_INTEGER_RANGE = 0..1000
DEFAULT_STRING_LENGTH = 30
DIGIT_CHARS = "1234567890"
SENSIBLE_CHARS = USERNAME_CHARS + "+-=[{]}/?|!@#$%^&*()`~"
USERNAME_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_" + DIGIT_CHARS
VERSION = "0.3.4"

Constructors

new(configuration = ConfigHash.new)

Creates a new Triki obfuscator with the given configuration.

The configuration is a hash mapping table names to either:

  • :truncate — remove all rows
  • :keep — pass through unchanged
  • A Hash(String, ConfigColumn) — per-column obfuscation rules
Source

Instance methods

config
Source
config=(config : ConfigHash)
Source
database_type
Source
database_type=(database_type : Symbol)
Source
fail_on_unspecified_columns=(fail_on_unspecified_columns : Bool)
Source
fail_on_unspecified_columns?
Source
globally_kept_columns
Source
globally_kept_columns=(globally_kept_columns : Array(String))
Source
obfuscate(input_io : IO, output_io : IO) : Nil

Reads an input stream and writes an obfuscated output stream.

input_io — SQL dump to process (e.g. STDIN or File). output_io — destination for the rewritten dump (e.g. STDOUT or File).

Source
scaffold(input_io : IO, output_io : IO) : Nil

Reads an input stream and writes a configuration scaffold to the output stream.

The scaffold lists every table and column found in the dump with placeholder :keep rules, making it easy to build an obfuscation config.

Source

Nested types