josacar / triki

Mysql, PostgreSQL and SQL dump obfuscator aka anonimizer
MIT License
38 stars 4 forks source link

Is it possible to load generated scaffold snippet to obfuscator.cr? #6

Closed smirninini closed 2 years ago

smirninini commented 2 years ago
  1. Scaffolder generates table names as symbol. Is it so necessary and not wrong?

obfuscator_scaffold_snippet.cr

  :public.users => {
    "email"                                   => :keep,   # scaffold
    "phone"                                   => :keep,   # scaffold
  },

Readme says The output will be a series of configuration statements of the form:

 "table_name" => {
    "column1_name" => :keep   # scaffold
    "column2_name" => :keep   # scaffold
    ... etc.
  1. Is it possible load result of snippet to obfuscator like this?

obfuscator.cr

require "tricki"
require "./snippet"

obfuscator = Triki.new({Snippet})
obfuscator.obfuscate(STDIN, STDOUT)
josacar commented 2 years ago

Hi, I'll try to look at this as soon as possible.

josacar commented 2 years ago

Thanks for reporting, config_scaffolder generates broken code, I've fixed it but I'm still fighting with some failing scenarios.

josacar commented 2 years ago

v0.2.4 is released

josacar commented 2 years ago

Is it possible load result of snippet to obfuscator like this?

I think as Snippet is a custom Crystal Object, I'd say it's not possible as it's not a JSON / YAML.

josacar commented 2 years ago

@Pavlentio did last release solve one of your issues?

smirninini commented 2 years ago

@josacar plan to take a look this week. I believe you do your best 🙏 and everything ok.

VicDeo commented 2 years ago

I have the same question as I'm trying to create more or less automated solution... Unfortunately I have no Crystal experience and last time I see Ruby code was over 10 years ago :(

My guess that the file snippet should contain Snippet var declaration besides the bare scaffolded structure:

Snippet = { # Added
  "table_name" => {
    "column1_name" => :keep   # scaffold
    "column2_name" => :keep   # scaffold
    ... 
} # Added
josacar commented 2 years ago

@VicDeo can you try https://github.com/josacar/triki/tree/obfuscator-as-a-constant branch?

It should produce something similar as:

SCAFFOLD = {
  "city" => {
    "ID"                                      => :keep,   # scaffold
    "Name"                                    => :keep,   # scaffold
    "CountryCode"                             => :keep,   # scaffold
    "District"                                => :keep,   # scaffold
    "Population"                              => :keep,   # scaffold
  },
  "country" => {
    "Code"                                    => :keep,   # scaffold
    "Name"                                    => :keep,   # scaffold
    "Continent"                               => :keep,   # scaffold
    "Region"                                  => :keep,   # scaffold
    "SurfaceArea"                             => :keep,   # scaffold
    "IndepYear"                               => :keep,   # scaffold
    "Population"                              => :keep,   # scaffold
    "LifeExpectancy"                          => :keep,   # scaffold
    "GNP"                                     => :keep,   # scaffold
    "GNPOld"                                  => :keep,   # scaffold
    "LocalName"                               => :keep,   # scaffold
    "GovernmentForm"                          => :keep,   # scaffold
    "HeadOfState"                             => :keep,   # scaffold
    "Capital"                                 => :keep,   # scaffold
    "Code2"                                   => :keep,   # scaffold
  },
  "countrylanguage" => {
    "CountryCode"                             => :keep,   # scaffold
    "Language"                                => :keep,   # scaffold
    "IsOfficial"                              => :keep,   # scaffold
    "Percentage"                              => :keep,   # scaffold
  }
}