Git Product home page Git Product logo

json-masker's People

Contributors

alexeyshary avatar breus avatar dependabot[bot] avatar donavdey avatar gavlyukovskiy avatar robertblaauwendraad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

json-masker's Issues

Keys and JsonPATH keys are not isolated form each other in the trie

Given the following configuration

maskKeys: $.a
maskJsonPaths: $.b, $.c

And the following json:

{
  "a": "do not mask",
  "b": "mask",
  "c": "mask",
}

The result will be:

{
  "a": "***",
  "b": "***",
  "c": "***",
}

The expected result should be:

{
  "a": "do not mask",
  "b": "***",
  "c": "***",
}

The bug is caused by not separating keys and JsonPATH keys in the trie. This can be solved by either using a separate trie instance for JsonPATH keys or ascribing a type to the endOfWord field in trie nodes (endOfJsonPathKeyWord and endOfKeyWord)

Unify API runmtime exceptions on masker when invalid JSON is provided

Currently, calling JsonMasker.mask(String or byte[]) can give two results:

  1. In case valid JSON was provided, valid JSON is returned according to the provided masking configurations
  2. In case invalid JSON was provided, some runtime exception is thrown

The second case can be caused by multiple cases (e.g. IllegalStateException or ArrayOutOfBoundException).

This should be unified such that the API can give two results:

  1. Unchanged
  2. An InvalidJsonException runtime exception is thrown

Support wildcards in JsonPath

We want to support wildcards for array and object matching:

$.a.*.b

which should mask

{
  "a": [
    {
      "b": "masked",
      "c": "allowed"
    },
    "allowed"
  ]
}

and

{
  "a": {
    "d": {
      "b": "masked",
      "c": "allowed"
    },
    "e": "allowed"
  }
}

Support for recursive selectors $.a..b is not planned as it would require matching from the tail and require a loopback.

Replace RandomWhiteSpaceInjector to Jackson PrettyPrinter implementation

Currently, the RandomJsonWhiteSpaceInjector is used to have fuzzing tests that also have random white spaces injected in different places.

However, Jackson is not able to deal with certain white spaces which are injected that way. For example, unescaped cariage return cannot be used inside a JSON key in Jackson.

Right now, the Fuzzing test checks if the randomly generated, white space injected JSON can be parsed by Jackson. If it cannot, it is disregarded and a new random JSON is generated to do fuzzing testing on.

This however, is a quick fix we added and wastes computing resources which in turn decrease the number of fuzzing tests that can be run in a predetermined time frame (in our pipelines).

What we can do instead is implement a com.fasterxml.jackson.core.PrettyPrinter instance that also randomly injects white spaces and use that instead of our current RandomJsonWhiteSpaceInjector implementation.

Disallow unambiguous JsonPath

With the introduction of wildcards, we want to disallow unambiguous JsonPath combinations. The main reason is to avoid loopbacks during matching that could occur for such combinations:

$.a.*.c
$.a.b.*

on a JSON

{
  "a": {
    "b": {
      "d": "masked"
    }
  }
}

current implementation only matches forward, meaning that node "a.b" would be already matched against "a.*", but the next node "d" would fail to match the first JsonPath while satisfying the second JsonPath, which would require a loopback.

Until someone asks for this particular use case, providing a good reason, we should not allow these.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.