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

builder: go: Allow equal signs in env vars #1232

Merged
merged 1 commit into from
Nov 16, 2022

Conversation

cfergeau
Copy link
Contributor

If .slsa-goreleaser.yml contains an env var with multiple '=' signs:

env:
  - CGO_ENABLED=1
  - CGO_CFLAGS=-mmacosx-version-min=11.0

the 'build dry project' GH workflow step fails with "invalid environment
variable: CGO_CFLAGS=-mmacosx-version-min=11.0"
This is caused by the way the env vars are parsed in GoReleaserConfig:setEnvs
which only allow for a single '=' sign.

This commit fixes this by splitting the env string at the first equal sign,
first part is the env var name and won't contain '=' signs, second part
is its value and can contain any number of '='.

This also adds unit tests for this situation, and for env vars with no
values (CGO_CFLAGS=).

This fixes #1231

If .slsa-goreleaser.yml contains an env var with multiple '=' signs:
```
env:
  - CGO_ENABLED=1
  - CGO_CFLAGS=-mmacosx-version-min=11.0
```

the 'build dry project' GH workflow step fails with "invalid environment
variable: CGO_CFLAGS=-mmacosx-version-min=11.0"
This is caused by the way the env vars are parsed in GoReleaserConfig:setEnvs
which only allow for a single '=' sign.

This commit fixes this by splitting the env string at the first equal sign,
first part is the env var name and won't contain '=' signs, second part
is its value and can contain any number of '='.

This also adds unit tests for this situation, and for env vars with no
values (`CGO_CFLAGS=`).

This fixes slsa-framework#1231

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Copy link
Collaborator

@laurentsimon laurentsimon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@laurentsimon laurentsimon merged commit 1936957 into slsa-framework:main Nov 16, 2022
@ianlewis
Copy link
Member

Good, you allowed no value. 👍 Thanks!

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

Successfully merging this pull request may close these issues.

[bug] Environment variable value cannot contain =
3 participants