From 161b35fd446932573006115101200adf5edc5f27 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Sun, 31 May 2015 01:32:38 -0700 Subject: [PATCH] Fix bug where scrubbing system usernames would accidentally scrub entire paths --- __tests__/Util-test.js | 4 ++-- src/utils/Util.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/__tests__/Util-test.js b/__tests__/Util-test.js index 985d05bd..932185ca 100644 --- a/__tests__/Util-test.js +++ b/__tests__/Util-test.js @@ -26,8 +26,8 @@ describe('Util', function () { expect(util.removeSensitiveData(testdata).indexOf('/Users//')).toNotEqual(-1); 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//')).toNotEqual(-1); + expect(util.removeSensitiveData(testdata).indexOf('/Users/some.wei-rdUsername/.docker')).toEqual(-1); + expect(util.removeSensitiveData(testdata).indexOf('/Users//.docker')).toNotEqual(-1); }); it ('returns input if empty or not a string', function () { diff --git a/src/utils/Util.js b/src/utils/Util.js index c2830592..8d90f741 100644 --- a/src/utils/Util.js +++ b/src/utils/Util.js @@ -59,7 +59,7 @@ module.exports = { } return str.replace(/-----BEGIN CERTIFICATE-----.*-----END CERTIFICATE-----/mg, '') .replace(/-----BEGIN RSA PRIVATE KEY-----.*-----END RSA PRIVATE KEY-----/mg, '') - .replace(/\/Users\/.*\//mg, '/Users//'); + .replace(/\/Users\/[^\/]*\//mg, '/Users//'); }, packagejson: function () { return JSON.parse(fs.readFileSync(path.join(__dirname, '../..', 'package.json'), 'utf8'));