Compare commits

...
2 Commits
Author SHA1 Message Date
Pierre Vanduynslager 467635bc14 fix: prioritize GIT_CREDENTIALS for gtit credentials
Allow to defined a both `GIT_CREDENTIALS` for repository access and `GH_TOKEN` or `GL_TOKEN` for API access
2018-01-27 20:31:59 -05:00
Pierre Vanduynslager 8b3605dd04 fix: hide sensitive info for Buffer and undefined 2018-01-27 18:24:24 -05:00
3 changed files with 14 additions and 9 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ const {parse, format} = require('url');
const {isUndefined} = require('lodash');
const gitUrlParse = require('git-url-parse');
const GIT_TOKENS = ['GH_TOKEN', 'GITHUB_TOKEN', 'GL_TOKEN', 'GITLAB_TOKEN', 'GIT_CREDENTIALS'];
const GIT_TOKENS = ['GIT_CREDENTIALS', 'GH_TOKEN', 'GITHUB_TOKEN', 'GL_TOKEN', 'GITLAB_TOKEN'];
/**
* Generate the git repository URL with creadentials.
+5 -8
View File
@@ -1,11 +1,8 @@
const {escapeRegExp} = require('lodash');
const regexp = new RegExp(
Object.keys(process.env)
.filter(envVar => /token|password|credential|secret|private/i.test(envVar))
.map(envVar => escapeRegExp(process.env[envVar]))
.join('|'),
'g'
);
const toReplace = Object.keys(process.env).filter(envVar => /token|password|credential|secret|private/i.test(envVar));
const regexp = new RegExp(toReplace.map(envVar => escapeRegExp(process.env[envVar])).join('|'), 'g');
module.exports = output => output.replace(regexp, '[secure]');
module.exports = output => {
return output && toReplace.length > 0 ? output.toString().replace(regexp, '[secure]') : output;
};
+8
View File
@@ -32,3 +32,11 @@ test.serial('Escape regexp special characters', t => {
'https://user:[secure]@host.com'
);
});
test.serial('Accept "undefined" input', t => {
t.is(require('../lib/hide-sensitive')(), undefined);
});
test.serial('Return same string if no environment variable has to be replaced', t => {
t.is(require('../lib/hide-sensitive')('test'), 'test');
});