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

Support for deep-wildcard object redaction #65

Open
byrne-greg opened this issue Dec 18, 2023 · 2 comments
Open

Support for deep-wildcard object redaction #65

byrne-greg opened this issue Dec 18, 2023 · 2 comments

Comments

@byrne-greg
Copy link

byrne-greg commented Dec 18, 2023

Tried to set-up using fast-redact for redacting PII from logs. However the logs are unstructured and it's non-obvious the package doesn't support wildcarding depths in object paths rather than widths at specific depths.
e.g.

import fastRedact from 'fast-redact';

describe('fastRedact', () => {
  test('deep wildcard redaction', () => {
    const redact = fastRedact({ paths: ['*.firstName'] });
    const obj = {
      x: { firstName: 'redactme' },
      y: { a: { firstName: 'redactme' } },
      z: { c: { h: { firstName: 'redactme' } } },
    };

    expect(redact(obj)).toStrictEqual(
      JSON.stringify({
        x: { firstName: '[REDACTED]' },
        y: { a: { firstName: '[REDACTED]' } }, // is 'redactme
        z: { c: { h: { firstName: '[REDACTED]' } } }, // 'redactme'
      }),
    );
  });
});

I can get the above to work if I add paths: ['*.firstName', '*.*.firstName', '*.*.*.firstName'] but as these are unstructured logs, I'll never know the depth of the object beforehand

Have I missed something in the documentation to enable the depth wildcard traversal?

@sawyerh
Copy link

sawyerh commented Dec 22, 2023

Potentially related: #5 (was just searching for the same behavior)

@tushar32

This comment was marked as off-topic.

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

3 participants