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

fix secrets stored in JSON format #473

Merged
merged 14 commits into from
Jul 6, 2023

Conversation

fairclothjm
Copy link
Contributor

@fairclothjm fairclothjm commented Jul 3, 2023

We broke support for secrets in JSON format in #173. This adds that support back and also adds more tests to ensure we can catch any regressions moving forward.

Closes #194

@fairclothjm fairclothjm force-pushed the VAULT-17445/fix-multiline-json-str-bug branch from 3e33a89 to a24b038 Compare July 3, 2023 20:57
@fairclothjm fairclothjm force-pushed the VAULT-17445/fix-multiline-json-str-bug branch from 7b2ddb7 to 788264d Compare July 5, 2023 17:25
@fairclothjm fairclothjm marked this pull request as ready for review July 5, 2023 18:23
@fairclothjm fairclothjm requested a review from a team July 5, 2023 18:23
src/secrets.js Outdated
if (isJSONString(d)) {
// If we already have a JSON string we will not "stringify" it yet so
// that we don't end up calling JSON.parse. This would break the
// secrets that are stored as pure JSON. See: https://github.com/hashicorp/vault-action/issues/194
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like you mentioned this before so apologies if this is a repeated q:
Are we avoiding calling JSON.stringify here because under the hood it calls JSON.parse? In that case, a follow up — Hasn't the try-catch block on L139-L143 ensured that JSON.parse does not break things?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, JSON.parse does not call JSON.stringify --if I am understanding you correctly. I see how this comment might convey that though. I will see if I can improve the wording a bit.

src/secrets.js Outdated Show resolved Hide resolved
Copy link
Contributor

@vinay-gopalan vinay-gopalan left a comment

Choose a reason for hiding this comment

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

LGTM

@fairclothjm fairclothjm merged commit b138504 into main Jul 6, 2023
6 checks passed
@fairclothjm fairclothjm deleted the VAULT-17445/fix-multiline-json-str-bug branch July 6, 2023 15:51
- name: Verify Vault Action Outputs
run: npm run test:integration:e2e
env:
OTHER_SECRET_OUTPUT: ${{ steps.kv-secrets.outputs.otherSecret }}


Copy link
Member

@robmonte robmonte Jul 6, 2023

Choose a reason for hiding this comment

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

Looks like an accidental second newline added?

Copy link
Member

Choose a reason for hiding this comment

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

Whoops submitted this too late 😓

fairclothjm added a commit that referenced this pull request Jul 12, 2023
fairclothjm added a commit that referenced this pull request Jul 12, 2023
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.

[BUG] v2.1.2 breaks secrets in JSON format
4 participants