[JIRA] (JENKINS-52889) new lines in secret is substituted by spaces when reading via Vault plugin

7 views
Skip to first unread message

saillinux@gmail.com (JIRA)

unread,
Aug 5, 2018, 1:26:04 AM8/5/18
to jenkinsc...@googlegroups.com
Hee Won Kim created an issue
 
Jenkins / Bug JENKINS-52889
new lines in secret is substituted by spaces when reading via Vault plugin
Issue Type: Bug Bug
Assignee: Peter Tierno
Components: hashicorp-vault-plugin
Created: 2018-08-05 05:25
Priority: Minor Minor
Reporter: Hee Won Kim

When I read secrets using Vault Plugin from both Freestyle and Pipeline jobs, if secrets contains new lines e.g. '\n'. it gets substituted to space characters.

In vault JSON:

{"key1": "multi lines contents\nsecond lines"}

when it's been read from Vault plugin to a job,

"multi lines contents second lines"

 

Please let me know if you need further detail.

 

Thanks in advanced.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.10.1#710002-sha1:6efc396)

saillinux@gmail.com (JIRA)

unread,
Aug 5, 2018, 1:27:01 AM8/5/18
to jenkinsc...@googlegroups.com
Hee Won Kim updated an issue
Change By: Hee Won Kim
When I read secrets using Vault Plugin from both Freestyle and Pipeline jobs, if secrets contains new lines e.g. '\n'. it gets substituted to space characters.

 

In actual contents in the secret:
{quote}multi lines contents

second lines
{quote}
In
vault JSON:

{ quote}{ "key1": "multi lines contents\nsecond lines"}
{quote}
when it's been read from Vault plugin to a job,

{quote} "multi lines contents second lines"
{quote}
 


Please let me know if you need further detail.

 

Thanks in advanced.

fragpit@gmail.com (JIRA)

unread,
Oct 18, 2018, 12:43:02 PM10/18/18
to jenkinsc...@googlegroups.com
fragpit fragpit commented on Bug JENKINS-52889
 
Re: new lines in secret is substituted by spaces when reading via Vault plugin

Same for me, looks like it's unable to work with certificates stored as secrets using this plugin without additional formatting.

This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

the.samuel.beaulieu@gmail.com (JIRA)

unread,
Jul 29, 2019, 7:15:04 PM7/29/19
to jenkinsc...@googlegroups.com
Samuel Beaulieu edited a comment on Bug JENKINS-52889
[~saillinux] you should iclude include the actual shell script lines you are running.

 

I hit the same issue and debugged the plugin. Things are received from Vault with the "\n" preserved as far as I could see, so I looked into issues with the printing of it. The issue arises because of the command substitution in bash [http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_03]

and you can fix that by setting {{IFS=}} as per [https://unix.stackexchange.com/questions/164508/why-do-newline-characters-get-lost-when-using-command-substitution]

 

BUT its easier to just embed it in double quotes so that:

if I do this it is replaced by spaces
{code:java}
echo $FOO > .foo{code}
but if I do this instead it works
{code:java}
echo "$FOO" > .foo{code}
then the newlines are preserved

the.samuel.beaulieu@gmail.com (JIRA)

unread,
Jul 29, 2019, 7:15:04 PM7/29/19
to jenkinsc...@googlegroups.com

Hee Won Kim you should iclude the actual shell script lines you are running.

 

I hit the same issue and debugged the plugin. Things are received from Vault with the "\n" preserved as far as I could see, so I looked into issues with the printing of it. The issue arises because of the command substitution in bash http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_03

and you can fix that by setting IFS= as per https://unix.stackexchange.com/questions/164508/why-do-newline-characters-get-lost-when-using-command-substitution

 

BUT its easier to just embed it in double quotes so that:

if I do this it is replaced by spaces

 echo $FOO > .foo

but if I do this instead it works

 echo "$FOO" > .foo

then the newlines are preserved

josephp90@gmail.com (JIRA)

unread,
Apr 22, 2020, 12:18:04 AM4/22/20
to jenkinsc...@googlegroups.com
Joseph Petersen closed an issue as Cannot Reproduce
 
Change By: Joseph Petersen
Status: Open Closed
Assignee: Peter Tierno Joseph Petersen
Resolution: Cannot Reproduce
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages