snitch-transform 0.0.1

JSON data transformation lib used by snitch components
Documentation

snitch-transformer

Library used by snitch-wasm to transform JSON data.

Currently only has support for "overwrite", "mask" and "obfuscate".

Usage

use snitch_transformer;

fn main() {
    let json = r#"{"object": {"hello": "world"}}"#;

    let updated_json = transformer::overwrite(json, "object.hello", r#"test"#).unwrap();

    println!("updated json: {}", updated_json);
    // {"object": {"hello": "test"}}
   
    // Keep in mind that replace value will be used as-is
    let updated_json = transformer::overwrite(json, "object.hello", "test").unwrap();
    // Will result in: {"object": {"hello": test}}
   
    // OR
    let updated_json = transformer::mask(json, "object.hello", '*');
    // updated_json == {"object": {"hello": "*****"}}

    // OR
    let updated_json = transformer::obfuscate(json, "object.hello");
    // updated_json == {"object": {"hello": "woAF1"}}
}

IMPORTANT

  1. overwrite()
    1. Overwrite value will be used as-is - if target is intended to be a string, then make sure to include quotes in the payload ( Ie. "123")
  2. mask() 2. Works for numbers and strings 3. For numbers, it will replace 80% of the number characters with 0 4. For strings, it will replace 80% of the characters with *
  3. obfuscate() 2. Works ONLY on strings 3. Will replace 100% of the characters with a sha256 hash

Use as-is - has not been tested in production :)