diff --git a/lib/datasource/npm.js b/lib/datasource/npm.js index 6e5bc2db1f8de0d79bacaf0788cb76bf6e2e3d3a..5734270a76952136246394a02b6164c9321a1c6d 100644 --- a/lib/datasource/npm.js +++ b/lib/datasource/npm.js @@ -50,7 +50,7 @@ function setNpmrc(input, exposeEnv = false) { npmrc = ini.parse(input); // massage _auth to _authToken for (const [key, val] of Object.entries(npmrc)) { - if (key.endsWith('_auth')) { + if (key.endsWith('_auth') && isBase64(val)) { logger.debug('Massaging _auth to _authToken'); npmrc[key + 'Token'] = val; npmrc.massagedAuth = true; diff --git a/test/manager/npm/registry.spec.js b/test/manager/npm/registry.spec.js index 0558b98b84ea07b872cdd5ea4af2d0d583136f76..c3628e08bac642bc7af72ea770dab7abb7f18ee2 100644 --- a/test/manager/npm/registry.spec.js +++ b/test/manager/npm/registry.spec.js @@ -205,7 +205,8 @@ describe('api/npm', () => { .get('/foobar') .reply(200, npmResponse); npm.setNpmrc( - 'registry=https://npm.mycustomregistry.com/\n//npm.mycustomregistry.com/:_auth = abcdef' + 'registry=https://npm.mycustomregistry.com/\n//npm.mycustomregistry.com/:_auth = ' + + Buffer.from('abcdef').toString('base64') ); const res = await npm.getDependency('foobar'); expect(res).toMatchSnapshot();