fix: prevent false positive secret replacement for Golang projects (#1562)

This commit is contained in:
Nicholas Shine
2020-05-24 11:53:00 -07:00
committed by GitHub
parent 5f3a8bb14e
commit eed1d3c8cb
2 changed files with 18 additions and 3 deletions
+8 -3
View File
@@ -2,9 +2,14 @@ const {escapeRegExp, size, isString} = require('lodash');
const {SECRET_REPLACEMENT, SECRET_MIN_SIZE} = require('./definitions/constants');
module.exports = (env) => {
const toReplace = Object.keys(env).filter(
(envVar) => /token|password|credential|secret|private/i.test(envVar) && size(env[envVar].trim()) >= SECRET_MIN_SIZE
);
const toReplace = Object.keys(env).filter((envVar) => {
// https://github.com/semantic-release/semantic-release/issues/1558
if (envVar === 'GOPRIVATE') {
return false;
}
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');
return (output) =>