Repository navigation
Replies: 1 comment
|
In zx 8.8.4, the default logger exposes import { $, log } from 'zx';
const valuesToHide = ['example-password'];
const redact = text => valuesToHide.filter(Boolean).reduce(
(result, value) => result.split(value).join('******'), text,
);
log.output = {
write(chunk) {
process.stderr.write(redact(String(chunk)));
},
};
$.verbose = true;
await $`printf '%s\n' ${valuesToHide[0]}`;I tested the actual command and its output with zx 8.8.4: the default logger's command display and stdout display contained This masks exact strings in individual logger writes. It is not a guarantee against every form of disclosure: output split across writes, shell escaping/encoding, directly inherited stdio, your own |
Uh oh!
There was an error while loading. Please reload this page.
Is there a built-in way to mark some specific strings as censored, so if they appear in the logs they are replaced with
******.Thinking something like this:
This would output to stdout:
$`psql postgres://example:*************@production.com:5432/example`You could also use this same feature to just censor any process.env value:
And then have confidence no secrets are being logged.
All reactions