Closed c00 closed 1 year ago
Yes, ++. v 2.0.0 works fine with the overrides.
Interesting detail @a1ex-var1amov ! Looking at the diff between 2.0.0 and 2.0.1 we can see that indeed, an eval was added at the line where stuff goes wrong.
Looking at the changelog:
Previously users were able to use environment variable strings within parameters, this functionality was removed in 2.0.0 and has been added back with this change.
The reason for this change was to make sure that environment variables within parameters are updated. Which is a cool thing. However, under the values-to-override thing, the value isn't just a string that can be eval'd, but rather a key=value
string, which when evals, just fails.
On top of that, this is arguably a security issue. eval
just executes a command, so in theory any command could be injected here. If the only purpose is to replace env variables, I would suggest using something like envsubst
that simply takes an input, and replaces env variables where they are found.
Using a envsubst
would achieve the same thing in terms of env variable replacement, but without the execution of arbitrary code.
@c00 yes, 100%.
Just in case, I'll put the example of a wrong eval
usage here:
❯ MYTEST="123"
❯ eval $MYTEST
zsh: command not found: 123`
And the proper one:
❯ mkdir test
❯ MYTEST="cd test"
❯ eval $MYTEST
❯ pwd
<omitted>/test
I agree @c00, we run into this issue all the time. envsubst would absolutely be the key here, but it is also another dependency that users would need to ensure is present on their image in order to use the orb. It may be worth doing though, based on the good examples you have shared here.
but it is also another dependency that users would need to ensure is present on their image
Yeah this is a problem. There may be some fancy sed
alternative that's doable (as sed is available pretty much everywhere). My first thought was a regex that extracts the env variables, and then a loop with sed
that does the substitutions, but I can't really get a working example.
Alternatively you could consider checking for the existence of envsubst, output a warning/error if it's not on the container. The error would make sense along with a flag like substitute-env-vars
or something.
Considering this is a CCI orb and will probably often be used with CCI base images, this would really only make sense if envsubst was part of the CCI base images, which I do not know. (edit: They don't seem to include it.)
You could also considering installing envsubst if it doesn't exist... But it feels kinda dirty.
Hey @c00,
I've added circleci env subst
to the parameter in PR #68. I'm working on closing out the remaining issues for this orb and will get a new version published as soon as we can.
Thank for you flagging! -Brian
Orb version
2.0.1
What happened
Halfway through the logs I get a "/bin/bash: line 34: image.tag=[redacted-git-sha]: command not found". But then the task does continue on its merry way as if nothing happened.
At the end the new settings are not applied.
The shortened version of the cci config:
Expected behavior