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?
Tried to set-up using
fast-redactfor 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.
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 beforehandHave I missed something in the documentation to enable the depth wildcard traversal?