Fix bug where scrubbing system usernames would accidentally scrub entire paths

This commit is contained in:
Jeffrey Morgan 2015-05-31 01:32:38 -07:00
Родитель 7abd94fc30
Коммит 161b35fd44
2 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -26,8 +26,8 @@ describe('Util', function () {
expect(util.removeSensitiveData(testdata).indexOf('/Users/<redacted>/')).toNotEqual(-1); expect(util.removeSensitiveData(testdata).indexOf('/Users/<redacted>/')).toNotEqual(-1);
testdata = String.raw`/Users/some.wei-rdUsername/.docker/machine/machines/dev2/id_rsa docker@localhost echo`; testdata = String.raw`/Users/some.wei-rdUsername/.docker/machine/machines/dev2/id_rsa docker@localhost echo`;
expect(util.removeSensitiveData(testdata).indexOf('/Users/some.wei-rdUsername/')).toEqual(-1); expect(util.removeSensitiveData(testdata).indexOf('/Users/some.wei-rdUsername/.docker')).toEqual(-1);
expect(util.removeSensitiveData(testdata).indexOf('/Users/<redacted>/')).toNotEqual(-1); expect(util.removeSensitiveData(testdata).indexOf('/Users/<redacted>/.docker')).toNotEqual(-1);
}); });
it ('returns input if empty or not a string', function () { it ('returns input if empty or not a string', function () {

Просмотреть файл

@ -59,7 +59,7 @@ module.exports = {
} }
return str.replace(/-----BEGIN CERTIFICATE-----.*-----END CERTIFICATE-----/mg, '<redacted>') return str.replace(/-----BEGIN CERTIFICATE-----.*-----END CERTIFICATE-----/mg, '<redacted>')
.replace(/-----BEGIN RSA PRIVATE KEY-----.*-----END RSA PRIVATE KEY-----/mg, '<redacted>') .replace(/-----BEGIN RSA PRIVATE KEY-----.*-----END RSA PRIVATE KEY-----/mg, '<redacted>')
.replace(/\/Users\/.*\//mg, '/Users/<redacted>/'); .replace(/\/Users\/[^\/]*\//mg, '/Users/<redacted>/');
}, },
packagejson: function () { packagejson: function () {
return JSON.parse(fs.readFileSync(path.join(__dirname, '../..', 'package.json'), 'utf8')); return JSON.parse(fs.readFileSync(path.join(__dirname, '../..', 'package.json'), 'utf8'));