2017-06-22 07:03:36 +00:00
|
|
|
const traverse = require('traverse');
|
|
|
|
|
|
|
|
module.exports = configSerializer;
|
|
|
|
|
|
|
|
function configSerializer(config) {
|
2017-08-29 07:25:44 +00:00
|
|
|
const redactedFields = [
|
2018-02-19 08:11:24 +00:00
|
|
|
'authorization',
|
2017-08-29 07:25:44 +00:00
|
|
|
'token',
|
|
|
|
'githubAppKey',
|
|
|
|
'npmToken',
|
|
|
|
'npmrc',
|
|
|
|
'yarnrc',
|
2017-09-01 04:45:51 +00:00
|
|
|
'privateKey',
|
2017-12-09 16:56:23 +00:00
|
|
|
'gitPrivateKey',
|
2017-12-14 10:47:00 +00:00
|
|
|
'forkToken',
|
2018-08-29 05:30:03 +00:00
|
|
|
'password',
|
2017-08-29 07:25:44 +00:00
|
|
|
];
|
2018-04-17 08:34:30 +00:00
|
|
|
const templateFields = ['prBody'];
|
2018-03-08 06:22:06 +00:00
|
|
|
const contentFields = [
|
|
|
|
'content',
|
|
|
|
'contents',
|
|
|
|
'packageLockParsed',
|
|
|
|
'yarnLockParsed',
|
|
|
|
];
|
2018-05-03 12:17:45 +00:00
|
|
|
const arrayFields = ['packageFiles', 'upgrades'];
|
2017-06-22 07:03:36 +00:00
|
|
|
// eslint-disable-next-line array-callback-return
|
|
|
|
return traverse(config).map(function scrub(val) {
|
2018-06-04 18:44:32 +00:00
|
|
|
if (val && redactedFields.includes(this.key)) {
|
2017-06-22 07:03:36 +00:00
|
|
|
this.update('***********');
|
|
|
|
}
|
2018-06-04 18:44:32 +00:00
|
|
|
if (val && templateFields.includes(this.key)) {
|
2017-07-02 04:28:43 +00:00
|
|
|
this.update('[Template]');
|
|
|
|
}
|
2018-03-08 06:22:06 +00:00
|
|
|
if (val && contentFields.includes(this.key)) {
|
2017-08-08 04:25:44 +00:00
|
|
|
this.update('[content]');
|
|
|
|
}
|
2018-06-27 05:21:17 +00:00
|
|
|
if (val && this.key === 'releases') {
|
|
|
|
this.update(val.map(release => release.version));
|
|
|
|
}
|
2018-05-03 12:17:45 +00:00
|
|
|
// istanbul ignore if
|
|
|
|
if (val && arrayFields.includes(this.key)) {
|
|
|
|
this.update('[Array]');
|
|
|
|
}
|
2017-06-22 07:03:36 +00:00
|
|
|
});
|
|
|
|
}
|