Skip to content

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

Description

@tombertrand

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions