Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PathMask: unable to mask an array element by its index #735

Open
brenuart opened this issue Jan 3, 2022 · 1 comment
Open

PathMask: unable to mask an array element by its index #735

brenuart opened this issue Jan 3, 2022 · 1 comment

Comments

@brenuart
Copy link
Collaborator

brenuart commented Jan 3, 2022

Suppose a configuration that produces the following JSON:

{
   "array": ["a", {"foo":"bar"}]
}

If you want to mask the second array entry you should configure a MaskingJsonGeneratorDecorator with a PathMask of /array/1. This should produce the following result:

{
   "array": ["a", "****"]
}

Unfortunately this doesn't work and nothing is masked. To recap the observed behaviour:

PathMask Comment
/array Path points to the array field whose content is entirely masked.

Result: { "array": "****" }
/array/1 Path points to the second array entry BUT nothing is masked.

Result: "{ array": ["a", {"foo":"bar"}] }
Expected: "{ array": ["a", "****"] }
/array/1/foo Path points to the foo property of the second entry which is masked. This shows that a path can correctly identify an array entry by its index.

Result: "{ array": ["a", {"foo":"****"}] }

logstash-logback-encoder: 7.0.1

brenuart added a commit that referenced this issue Aug 26, 2022
@denisvasconcelos
Copy link

Hi @brenuart how are you?
I got the solution passing the path like this: /array/*/foo
So my logback.xml was like below:

            <jsonGeneratorDecorator class="net.logstash.logback.mask.MaskingJsonGeneratorDecorator">

                <!-- The default mask string can optionally be specified by <defaultMask>.
                     When the default mask string is not specified, **** is used.
                -->
                <defaultMask>****</defaultMask>

                <!-- Field paths to mask added via <path> will use the default mask string -->
                <path>foo</path>
                <path>array/*/foo</path>
            </jsonGeneratorDecorator>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants