fast-redact icon indicating copy to clipboard operation
fast-redact copied to clipboard

Multi-wildcard implementation broke paths passed to censor function

Open ethanresnick opened this issue 3 years ago • 3 comments

Hi! I love the new support for multiple wildcards in redaction paths. Unfortunately, when the PR for that feature was merged, it looks like it introduced some weird behavior.

As shown in this test and the one right below it, when a wildcard is used in a redaction path, and that path is exposed to the censor function, the prior contract was for the censor function to see a path based on what the wildcard actually matched. E.g., the path '*.b' would be passed to the censor function as ['a', 'b'] if the wildcard matched a key named 'a'.

With multiple wildcards, though, as shown in this test, the first wildcard in the path is exposed to the censor function using the actual key it matched, but subsequent wildcards are passed in as a literal '*'.

I implemented the original support for passing a path to the censor function, so I'd normally be open to fixing this ticket, but I really have no time right now. I've also completely forgotten everything figured out about specialSet, and generally how all the pieces of this library fit together.

If @lukehedger is able to fix this, that would be amazing, since he's obviously touched the code more recently and wrote the multi-wildcard code. But, if he doesn't have time either, I figured I'd still open this issue just to document the problem.

ethanresnick avatar Feb 23 '22 02:02 ethanresnick

Thanks, that would be amazing.

mcollina avatar Feb 23 '22 09:02 mcollina

I think you've got the wrong guy @ethanresnick! At least, I have no memory of writing this code 😄

lukehedger avatar Feb 23 '22 15:02 lukehedger

Doh, my bad. I meant @lrecknagel

ethanresnick avatar Feb 23 '22 16:02 ethanresnick