mirror of
https://github.com/hashicorp/vault-action.git
synced 2025-11-07 07:06:56 +00:00
fix: replace all dot chars during normalization
This commit is contained in:
parent
4d5899dd0e
commit
cf1ffef4b2
3 changed files with 20 additions and 2 deletions
2
dist/index.js
vendored
2
dist/index.js
vendored
|
|
@ -19309,7 +19309,7 @@ module.exports = {
|
||||||
*/
|
*/
|
||||||
function normalizeOutputKey(dataKey, upperCase = false) {
|
function normalizeOutputKey(dataKey, upperCase = false) {
|
||||||
let outputKey = dataKey
|
let outputKey = dataKey
|
||||||
.replace(".", "__")
|
.replaceAll(".", "__")
|
||||||
.replace(new RegExp("-", "g"), "")
|
.replace(new RegExp("-", "g"), "")
|
||||||
.replace(/[^\p{L}\p{N}_-]/gu, "");
|
.replace(/[^\p{L}\p{N}_-]/gu, "");
|
||||||
if (upperCase) {
|
if (upperCase) {
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,14 @@ describe('integration', () => {
|
||||||
body: `{"data":{"secret.foo":"SUPERSECRET"}}`
|
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`, {
|
await got(`${vaultUrl}/v1/secret/data/nested/test`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
|
@ -293,6 +301,16 @@ describe('integration', () => {
|
||||||
expect(core.exportVariable).toBeCalledWith('SECRET__FOO', 'SUPERSECRET');
|
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 () => {
|
it('get wildcard secrets', async () => {
|
||||||
mockInput(`secret/data/test * ;`);
|
mockInput(`secret/data/test * ;`);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
function normalizeOutputKey(dataKey, upperCase = false) {
|
function normalizeOutputKey(dataKey, upperCase = false) {
|
||||||
let outputKey = dataKey
|
let outputKey = dataKey
|
||||||
.replace(".", "__")
|
.replaceAll(".", "__")
|
||||||
.replace(new RegExp("-", "g"), "")
|
.replace(new RegExp("-", "g"), "")
|
||||||
.replace(/[^\p{L}\p{N}_-]/gu, "");
|
.replace(/[^\p{L}\p{N}_-]/gu, "");
|
||||||
if (upperCase) {
|
if (upperCase) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue