class Triki

Overview

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.

Defined in:

triki.cr
triki/base.cr
triki/config_applicator.cr
triki/config_parser.cr
triki/config_scaffold_generator.cr
triki/english_dictionary.cr
triki/faker.cr
triki/insert_statement_parser.cr
triki/mysql.cr
triki/postgres.cr
triki/sql_server.cr
triki/version.cr

Constant Summary

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

Constructors

Instance Method Summary

Constructor Detail

def self.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

[View source]

Instance Method Detail

def config : ConfigHash #

[View source]
def config=(config : ConfigHash) #

[View source]
def database_type : Symbol #

[View source]
def database_type=(database_type : Symbol) #

[View source]
def fail_on_unspecified_columns=(fail_on_unspecified_columns : Bool) #

[View source]
def fail_on_unspecified_columns? : Bool #

[View source]
def globally_kept_columns : Array(String) #

[View source]
def globally_kept_columns=(globally_kept_columns : Array(String)) #

[View source]
def 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).


[View source]
def 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.


[View source]