Fizcko / Azure_DevOps_Vault_Interaction

Azure DevOps extension to interact with HashiCorp Vault.
MIT License
10 stars 13 forks source link

Error: Secrets cannot contain multiple lines #18

Closed docbyte86 closed 1 year ago

docbyte86 commented 1 year ago

Hello,

we have secrets with multiple lines in our path. (Privat Keys, for example). In this case the pipeline breaks with the following error:

(node:118) UnhandledPromiseRejectionWarning: Error: Error during browsing engine. Error when exporting values. Error when exporting values. Error: Secrets cannot contain multiple lines at /__w/_tasks/VaultReadKV_807a85d5-8ac9-4b8c-a0fc-1b233bb2bcc6/4.0.1/kv_read.js:77:35 at process._tickCallback (internal/process/next_tick.js:68:7) (node:118) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) (node:118) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

[error]Error during browsing engine. Error when exporting values. Error when exporting values. Error: Secrets cannot contain multiple lines

Fizcko commented 1 year ago

Hi @docbyte86 ,

You have to use the option "Replace carriage return by a token".

Then you have to replace back the token by yourself or use the second tool of this extension "Tool - Create a File".

See more details in file overview.md > Tool - Create a File > Use case 1

regards

docbyte86 commented 1 year ago

@Fizcko , thanks for the fast reply. we tried the following parameters:

strCRPrefix: '(LF, \n)' strCRPrefix: 'LF, \n' strCRPrefix: '\n' strCRPrefix: '(\n)' strCRPrefix: 'LF'

suddenly with the same results. Can you give some more details about the syntax?

Fizcko commented 1 year ago

For this exemple you have a vault multine secret like this:

-----BEGIN CERTIFICATE-----
MIIDfjCCAmagAwIBAgIEGWY2EzANBgkqhkiG9w0BAQsFADBbMScwJQYDVQQDDB5SZWdlcnkgU2Vs
Zi1TaWduZWQgQ2VydGlmaWNhdGUxIzAhBgNVBAoMGlJlZ2VyeSwgaHR0cHM6Ly9yZWdlcnkuY29t
MQswCQYDVQQGEwJVQTAgFw0yMzA2MjkwMDAwMDBaGA8yMTIzMDYyOTE0MzU1MlowQDEMMAoGA1UE
-----END CERTIFICATE-----

Using task "Vault - Read KV secrets" with settings:

replaceCR: true
strCRPrefix: "#{rn}#"

This will load this secret in variable in this format :

-----BEGIN CERTIFICATE-----#{rn}#MIIDfjCCAmagAwIBAgIEGWY2EzANBgkqhkiG9w0BAQsFADBbMScwJQYDVQQDDB5SZWdlcnkgU2Vs#{rn}#Zi1TaWduZWQgQ2VydGlmaWNhdGUxIzAhBgNVBAoMGlJlZ2VyeSwgaHR0cHM6Ly9yZWdlcnkuY29t#{rn}#MQswCQYDVQQGEwJVQTAgFw0yMzA2MjkwMDAwMDBaGA8yMTIzMDYyOTE0MzU1MlowQDEMMAoGA1UE#{rn}#-----END CERTIFICATE-----

Then you have to replace back the token (#{rn}#) by yourself or use the second tool of this extension "Tool - Create a File".

docbyte86 commented 1 year ago

@Fizcko , thank you very much. it works. but it is possible to use another token like "\n" instead of "#{n}#". ?

that I get format like (one line):

-----BEGIN CERTIFICATE-----\nb3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAACFwAAAAdzc2gtcn\nNhAAAAAwEAAQAAAgEA7o6MAteLB22d0SLqKy4YjnRGI7MTm1bbLErTNBXm/7WEm7RQUC5J\noC1x8FEokVrIEOrkBQkXhtsitj39fyro58xkw4rUWT2YYewWuRcw4XTFQLo2RINwULky48\nHCi7TfuUXS+5p7+fWzhwrRHhQutszkCxxQzjzP2BxnUvn17JOsqMZFsJUoH3KDRQSTVjRd\ngU6GuW5BUG+n21Uo0uJbD7tz2WuOQy8ws9SrmSYusIHvbCVByUfDHe/m/roSAUMqssSVUo\nN2+sq2q4ozf5gz1tA09rJyNIUCNbDCElyEDgWrtZ1lFJrgOPNeHL/tpdsibPQiBBcJ+z6f\nGKftICenEPEiGkko+P8v1Ytdx7EwHALkwRHsMgn0WANY8yyE/\n18ASWTupwPMAAAAAAQID\n-----END CERTIFICATE-----

Fizcko commented 1 year ago

Yes you can enter anything you want