fix(logs): err serializer strip secrets

This commit is contained in:
Rhys Arkins 2019-04-08 08:22:40 +02:00
parent 7be889e315
commit 3da629247e

View file

@ -1,3 +1,5 @@
const is = require('@sindresorhus/is');
module.exports = errSerializer; module.exports = errSerializer;
function errSerializer(err) { function errSerializer(err) {
@ -22,5 +24,14 @@ function errSerializer(err) {
) { ) {
response.gotOptions.headers.authorization = '** redacted **'; response.gotOptions.headers.authorization = '** redacted **';
} }
const redactedFields = ['message', 'stack', 'stdout', 'stderr'];
for (const field of redactedFields) {
if (is.string(response[field])) {
response[field] = response[field].replace(
/https:\/\/[^@]*@/g,
'https://**redacted**@'
);
}
}
return response; return response;
} }