mirror of
https://github.com/hashicorp/vault-action.git
synced 2025-11-06 23:06:54 +00:00
fix: replace all dot chars during normalization (#580)
* fix: replace all dot chars during normalization * changelog
This commit is contained in:
parent
4d5899dd0e
commit
b022ecdb0c
4 changed files with 26 additions and 2 deletions
|
|
@ -1,3 +1,9 @@
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
Bugs:
|
||||||
|
|
||||||
|
* replace all dot chars during normalization (https://github.com/hashicorp/vault-action/pull/580)
|
||||||
|
|
||||||
## 3.3.0 (March 3, 2025)
|
## 3.3.0 (March 3, 2025)
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
|
|
|
||||||
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