#json #replace #transform #snitch #obfuscate

snitch-transform

JSON data transformation lib used by snitch components

6 releases

0.0.6 Jul 27, 2023
0.0.5 Jul 11, 2023

#631 in Encoding

Download history 6/week @ 2023-10-31 1/week @ 2023-11-14 19/week @ 2023-11-21 20/week @ 2023-11-28 6/week @ 2023-12-12 18/week @ 2023-12-26 12/week @ 2024-01-30 1/week @ 2024-02-06 45/week @ 2024-02-13

58 downloads per month

MIT license

10KB
168 lines

snitch-transform

Library used by snitch-wasm to perform transformations on JSON payloads.

Currently only has support for overwrite, mask and obfuscate.

Usage

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

    let req = Request {
        data: sample_json.into(),
        path: "hello".to_string(),
        value: r#""baz""#.to_string(),
    };

    let updated_json = snitch_transform::transform::overwrite(&req).unwrap();

    println!(
        "Input JSON: {} || Result JSON: {}",
        sample_json, updated_json,
    )
}

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 :)

Dependencies

~4.5MB
~35K SLoC