Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Decoding to Secrets #408

Merged
merged 3 commits into from
Jan 17, 2023
Merged

Add Decoding to Secrets #408

merged 3 commits into from
Jan 17, 2023

Conversation

ltcarbonell
Copy link
Contributor

Adds support for encoded Vault secrets.
Example usage:

        with:
          namespace: ${{ secrets.VAULT_NAMESPACE }}
          url: ${{ secrets.VAULT_ADDR }}
          method: token
          token: ${{ secrets.VAULT_TOKEN }}
          tlsSkipVerify: false
          secretEncoding: "hex"
          secrets: |
            kv/test foohex | FOOHEX;

Resolves #105

Copy link
Member

@austingebauer austingebauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good! Left a few small comments.

src/action.js Outdated
@@ -17,6 +17,8 @@ async function exportSecrets() {
const secretsInput = core.getInput('secrets', { required: false });
const secretRequests = parseSecretsInput(secretsInput);

const secretEncoding = core.getInput('secretEncoding', { required: false });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does anything validate that the given encoding is one of "base64", "hex", "utf8"? Are their other encodings that could work via the buffer.From API that we'd want to prevent from using?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good note. I will add a check for supported encoding type.

action.yml Outdated
@@ -76,6 +76,9 @@ inputs:
description: 'Time in seconds, after which token expires'
required: false
default: 3600
secretEncoding:
description: 'Encoding of the secret value. Can be "base64", "hex", "utf8".'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I first read this, I thought it would encode the secret value. I see that at actually decodes based on the encoding set here. Perhaps we can improve the description to make that more obvious?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true. Reading it again now I can see how it is fairly confusing. Will work on making that clearer

@@ -17,6 +17,8 @@ async function exportSecrets() {
const secretsInput = core.getInput('secrets', { required: false });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth dropping a test case in here to cover the behavior. Not sure how challenging that is (still learning about vault-action myself 🙂).

Copy link
Member

@austingebauer austingebauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ltcarbonell ltcarbonell merged commit 0f409d4 into main Jan 17, 2023
@ltcarbonell ltcarbonell deleted the secret-decoding branch January 17, 2023 16:42
@austingebauer austingebauer mentioned this pull request Jan 26, 2023
TomNorth pushed a commit to TomNorth/vault-action that referenced this pull request Mar 25, 2023
* Add decoding to secrets

* remove index.js

* Add test case, and other updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add base64 decoding[FEAT]
2 participants