Closed steve-baldwin closed 1 year ago
If I have a structure:
{ headers: { host: "xxx", "user-agent": "xxx", "x-authorization": "xxx" } }
How do I specify a path that redacts headers.x-authorization ?
headers.x-authorization
Here's a test script I was using for something similar:
import * as F from 'fast-redact'; import { inspect } from 'util'; describe('Redact', () => { it('can redact', () => { const options: F.RedactOptions = { paths: ['authorization', 'abc."x-authorization"'], serialize: false }; const original = { innocuous: 'public info', authorization: 'secret info', abc: { 'x-authorization': 'another secret' } }; const r = F(options); r(original); console.log(inspect(original, { depth: null })); expect(original.authorization).toEqual('[REDACTED]'); }); });
I get:
fast-redact – Invalid path (abc."x-authorization") 15 | } 16 | }; > 17 | const r = F(options); | ^
I tried other options - e.g. 'abc.x-authorization', but I couldn't come up with anything that worked.
'abc.x-authorization'
Never mind. I was able to get the test script above working with:
paths: ['authorization', 'abc["x-authorization"]'],
Makes sense when you think about it 😄 .
If I have a structure:
How do I specify a path that redacts
headers.x-authorization
?Here's a test script I was using for something similar:
I get:
I tried other options - e.g.
'abc.x-authorization'
, but I couldn't come up with anything that worked.