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

Equal sign in multi-line evar can split single evar into two #668

Open
stratedge opened this issue Jun 13, 2018 · 0 comments
Open

Equal sign in multi-line evar can split single evar into two #668

stratedge opened this issue Jun 13, 2018 · 0 comments

Comments

@stratedge
Copy link

I've found a minor issue where a multi-line environmental variable in a file loaded with nanobox evar load that contains an equal sign will split on the line with the equal sign into two variables. The regex used to identify lines that begin new variables currently can't tell if the line is actually part of a previous quoted, multi-line variable body.

In my case, I have secret variables in Gitlab that are sent as environmental variables as a part of my CI/CD pipeline, and a script pulls these values from the environment into a file to then be loaded into the nanobox environment with nanobox evar load. One of the values that I'm passing is an RSA public key that has two equal signs. Because of this it's being parsed into two variables and breaking the key.

Example:

Input:

FIRST="Key below was generated just for this issue submission"
PUBLIC_KEY="-----BEGIN PUBLIC KEY-----
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAy+FQLV6ywRZg5RO7sD93
BDsjGk7k1tqySPmVY4HI2nkHqNRnzMiEVy4AzCZpQoA0BtmugKWUgfNO8LqLzZMP
KrexR1kE4ngL5t8ubDciERJYyEeCi99FIksSXE7z/yIjBOQExF2HiuMfGqTwHO3s
FkUb7UoC5596COrSXdq5UCs97wPeiHoeBGrSfbzXSQgHITaYjYnCWI7gCAUqXGrv
fs/FeuvrVbntLDZPOgBPWC81nUKBGE44cq9Whk3ekMVBeKbvmg97su9vqYUVc4te
InffgAZeRBhKMEvPoh+4jkx8AX3ikDYMnilV4Mkkvi7Q8IkiLxkpeJHxp+i7FZOc
mgioXbHQQdyu4kihq1c7FIrL1UvaZQnGKXUjJRsI4+Mei1WeEIPZUx+33JZmdWea
7/gn2el2g/2z3lyMAEbRtOsoQXnF3QA9Zu48h0gZ2HQr3LCgmHDynQnjP9KVYRIm
qVsP3EfpgXBeZrjq7J2qZqRxZ3FKCxBtB+CUshqnmmaqAw8NFMxyyV8WPu8xikhn
NaC/jOXEJYjGrU/Ha8GbPeid2ebt843GkQLIhboZh4uLYbTJD0J3+OOvMh7ePnwz
fkhtA5Va1z1h/BHi520AzBbQWZv02zYDhFg8hOV3RZbmj55Na0+AfKoJy/DdD6Mi
milGLhsuyYY8OieCXGvPkOMCAwEAAQ==
-----END PUBLIC KEY-----"
SECOND="So it's not actually in use anywhere"

Expected output is 3 variables: FIRST; PUBLIC_KEY; and SECOND.

Actual output is 4 variables: FIRST; PUBIC_KEY; MILGLHSUYYY8OIECXGVPKOMCAWEAAQ; and SECOND. The resulting value for PUBLIC_KEY does not contain the full key.

The issue is in the commands/evar/load.go file, in the loadVars function. Here's where the regex kicks off the root of problem, along with the subsequent for loop: https://github.com/nanobox-io/nanobox/blob/master/commands/evar/load.go#L86.

I have a fix in a branch that I'll submit a pull request for momentarily, but as this is the first time I've written any Go before, I fear my solution will be substandard. My additional unit tests pass, so it works (for what I'm testing for, at least), but in case that PR is fairly rejected, I thought I'd open this issue to track the problem.

My guess this issue is a fairly edgy edge-case and not pressing, so hopefully my PR will do the trick and no team members will have to divert from more important items.

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

No branches or pull requests

1 participant