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

Multi-level wildcards redact things that should not be redacted #62

Open
nagy135 opened this issue Sep 19, 2023 · 1 comment
Open

Multi-level wildcards redact things that should not be redacted #62

nagy135 opened this issue Sep 19, 2023 · 1 comment

Comments

@nagy135
Copy link

nagy135 commented Sep 19, 2023

Hello, i wrote test that shows what i mean,
so basically, if you provide deep enough sequence of wildcards, then all it needs is matching last key in object and its redacted. Even thou in paths you require also "the one before it" to match.

test("Test with multiple levels of wildcards", ({ end, is }) => {
  const censor = "censored";
  const value = "value";

  const paths = [
    "a.x",
    "a.y",
    "*.a.x",
    "*.a.y",

    // These break it
    "*.*.a.x",
    "*.*.a.y",

    // These wont do it
    // "*.*.a.x2",
    // "*.*.a.y2"
  ];

  const redact = fastRedact({ paths, censor, serialize: false });
  const o = {
    a: {
      x: value,
      y: value,
    },
    b: {
      x: value,
      y: value,
    },
  };

  redact(o);
  is(o.a.x, censor);
  is(o.a.y, censor);
  is(o.b.x, value);
  is(o.b.y, value);
  redact.restore(o);
  is(o.a.x, value);
  is(o.a.y, value);
  is(o.b.x, value);
  is(o.b.y, value);
  end();
});
@BennoDev
Copy link

BennoDev commented Feb 7, 2024

Same issue here, we want to redact PII from potentially deeply nested objects - data structures defined by API responses / external librariers - for example *.*.*.*.*.team.name results in redacting all name properties.

This tied with the fact deep wildcard redaction doesn't work makes it very hard to use the library now.

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

No branches or pull requests

2 participants