From cf1ffef4b2e1ee551b45d5291186a1a12f3d9fdc Mon Sep 17 00:00:00 2001 From: JM Faircloth Date: Tue, 13 May 2025 10:27:11 -0500 Subject: [PATCH] fix: replace all dot chars during normalization --- dist/index.js | 2 +- integrationTests/basic/integration.test.js | 18 ++++++++++++++++++ src/utils.js | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index adb2590..e0d4f5f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -19309,7 +19309,7 @@ module.exports = { */ function normalizeOutputKey(dataKey, upperCase = false) { let outputKey = dataKey - .replace(".", "__") + .replaceAll(".", "__") .replace(new RegExp("-", "g"), "") .replace(/[^\p{L}\p{N}_-]/gu, ""); if (upperCase) { diff --git a/integrationTests/basic/integration.test.js b/integrationTests/basic/integration.test.js index 3060466..95f6794 100644 --- a/integrationTests/basic/integration.test.js +++ b/integrationTests/basic/integration.test.js @@ -39,6 +39,14 @@ describe('integration', () => { body: `{"data":{"secret.foo":"SUPERSECRET"}}` }); + await got(`${vaultUrl}/v1/secret/data/test-with-multi-dot-chars`, { + method: 'POST', + headers: { + 'X-Vault-Token': vaultToken, + }, + body: `{"data":{"secret.foo.bar":"SUPERSECRET"}}` + }); + await got(`${vaultUrl}/v1/secret/data/nested/test`, { method: 'POST', headers: { @@ -293,6 +301,16 @@ describe('integration', () => { expect(core.exportVariable).toBeCalledWith('SECRET__FOO', 'SUPERSECRET'); }); + it('get secrets with multiple dot chars', async () => { + mockInput(`secret/data/test-with-multi-dot-chars * ;`); + + await exportSecrets(); + + expect(core.exportVariable).toBeCalledTimes(1); + + expect(core.exportVariable).toBeCalledWith('SECRET__FOO__BAR', 'SUPERSECRET'); + }); + it('get wildcard secrets', async () => { mockInput(`secret/data/test * ;`); diff --git a/src/utils.js b/src/utils.js index 0f5e4de..6e93279 100644 --- a/src/utils.js +++ b/src/utils.js @@ -5,7 +5,7 @@ */ function normalizeOutputKey(dataKey, upperCase = false) { let outputKey = dataKey - .replace(".", "__") + .replaceAll(".", "__") .replace(new RegExp("-", "g"), "") .replace(/[^\p{L}\p{N}_-]/gu, ""); if (upperCase) {