fix: mask secrets when characters get uri encoded
This commit is contained in:
@@ -11,7 +11,12 @@ module.exports = (env) => {
|
||||
return /token|password|credential|secret|private/i.test(envVar) && size(env[envVar].trim()) >= SECRET_MIN_SIZE;
|
||||
});
|
||||
|
||||
const regexp = new RegExp(toReplace.map((envVar) => escapeRegExp(env[envVar])).join('|'), 'g');
|
||||
const regexp = new RegExp(
|
||||
toReplace
|
||||
.map((envVar) => `${escapeRegExp(env[envVar])}|${encodeURI(escapeRegExp(env[envVar]))}`)
|
||||
.join('|'),
|
||||
'g'
|
||||
);
|
||||
return (output) =>
|
||||
output && isString(output) && toReplace.length > 0 ? output.toString().replace(regexp, SECRET_REPLACEMENT) : output;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user