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

[BUG] Error parsing multi-line secrets because the output contains "\n" #160

Closed
tombertrand opened this issue Dec 8, 2020 · 7 comments
Closed
Labels
bug Something isn't working

Comments

@tombertrand
Copy link

tombertrand commented Dec 8, 2020

Describe the bug
We currently have a vault secret that is a multi-line exported certificate. When setting it to an env variable, the output of vault-action contains \n instead of new lines.

To Reproduce
Store a multi line pub key, eg:

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSU
GPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3
Pbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XA
NrRFi9wrf+M7Q==

Notice that the key will be returned as

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSU\nGPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3\nPbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XA\nNrRFi9wrf+M7Q==

Expected behavior
Since the key is being used to sign an app it needs to be returned without the line escaping.

By adding a result = JSON.parse(result) before removing the quote we are able to get the expected value and our code sign task succeeds but I doubt that's the correct fix.
https://github.com/hashicorp/vault-action/blob/master/src/secrets.js#L75

@tombertrand tombertrand added the bug Something isn't working label Dec 8, 2020
@tombertrand tombertrand changed the title [BUG] Error parsing multi-line secrets because it contains "\n" [BUG] Error parsing multi-line secrets because the output contains "\n" Dec 8, 2020
@jasonodonnell
Copy link
Contributor

Thanks for the report @tombertrand, we'll take a look!

@bilucodota
Copy link
Contributor

@jasonodonnell any news about this?

@jasonodonnell
Copy link
Contributor

Sorry for the delay, we have a company wide shutdown for a few weeks in December and are just returning. We'll take a look at this soon!

@bilucodota
Copy link
Contributor

bilucodota commented Jan 5, 2021

@jasonodonnell Thanks for the quick answer.
In my case we store a yaml file as a secret (which we feed as values.yaml to helm install).
I guess that due to that JSON.stringify of the body - the returned value includes serialized chars such as \n & ""

@bilucodota
Copy link
Contributor

Opened a PR

@jasonodonnell
Copy link
Contributor

Thanks @bilucodota, taking a look!

@jasonodonnell
Copy link
Contributor

Fixed per #173.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants