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

Use trusted binary or build from source #114

Merged
merged 1 commit into from
Feb 5, 2025

Conversation

lcarva
Copy link
Member

@lcarva lcarva commented Feb 3, 2025

This commit changes the build process to either consume binaries from a trusted party, i.e. registry.redhat.io, or build the binary directly from source otherwise.

This approach allows us to stay up to date with automation such as renovate or dependabot. For the binaries built from source, we can also update transitivie dependencies individually if needed.

Since building from source requires a newer version of Go than what is officially released by Red Hat, the internal image from brew.registry.redhat.io is used instead.

This commit changes the build process to either consume binaries from a
trusted party, i.e. registry.redhat.io, or build the binary directly
from source otherwise.

This approach allows us to stay up to date with automation such as
renovate or dependabot. For the binaries built from source, we can also
update transitivie dependencies individually if needed.

Since building from source requires a newer version of Go than what is
officially released by Red Hat, the internal image from
brew.registry.redhat.io is used instead.

Signed-off-by: Luiz Carvalho <[email protected]>
@lcarva
Copy link
Member Author

lcarva commented Feb 3, 2025

Need to generate and add a token for brew.registry.redhat.io in the Konflux tenant. I'll do that once the token creation service is back online 😅

@lcarva
Copy link
Member Author

lcarva commented Feb 4, 2025

/retest

@lcarva
Copy link
Member Author

lcarva commented Feb 4, 2025

@chmeliik, @mmorhun, @tnevrlka, @simonbaird, wdyt? This completely removes the need of downloading binaries from GitHub.

Copy link
Member

@chmeliik chmeliik left a comment

Choose a reason for hiding this comment

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

Nice 🎉


RUN \
cd tools/yq && \
go install -trimpath --mod=readonly github.com/mikefarah/yq/v4 && \
Copy link
Member

Choose a reason for hiding this comment

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

Just for my information, what does -trimpath do? (I did find the description, but I'm still not sure what it actually does here)

-trimpath
	remove all file system paths from the resulting executable.
	Instead of absolute file system paths, the recorded file names
	will begin either a module path@version (when using modules),
	or a plain import path (when using the standard library, or GOPATH).

Copy link
Member Author

Choose a reason for hiding this comment

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

So someone inspecting the binary doesn't see the actual directory in which the go binary was built in.:

🐚 mkdir /tmp/no-trimpath
🐚 mkdir /tmp/with-trimpath

🐚 GOBIN=/tmp/with-trimpath go install -trimpath --mod=readonly github.com/mikefarah/yq/v4
🐚 GOBIN=/tmp/no-trimpath go install --mod=readonly github.com/mikefarah/yq/v4

🐚 strings /tmp/with-trimpath/yq | grep lucarval | head
<no output>
🐚 strings /tmp/no-trimpath/yq | grep lucarval | head
/home/lucarval/gocode/pkg/mod/golang.org/[email protected]
/home/lucarval/gocode/pkg/mod/golang.org/[email protected]/src/internal/cpu/cpu.go
/home/lucarval/gocode/pkg/mod/golang.org/[email protected]/src/internal/cpu/cpu_x86.go
/home/lucarval/gocode/pkg/mod/golang.org/[email protected]/src/internal/cpu/cpu_x86.s
/home/lucarval/gocode/pkg/mod/golang.org/[email protected]/src/internal/bytealg/count_native.go
/home/lucarval/gocode/pkg/mod/golang.org/[email protected]/src/internal/bytealg/index_amd64.go
/home/lucarval/gocode/pkg/mod/golang.org/[email protected]/src/internal/bytealg/compare_amd64.s
/home/lucarval/gocode/pkg/mod/golang.org/[email protected]/src/internal/bytealg/count_amd64.s
/home/lucarval/gocode/pkg/mod/golang.org/[email protected]/src/internal/bytealg/equal_amd64.s
/home/lucarval/gocode/pkg/mod/golang.org/[email protected]/src/internal/bytealg/index_amd64.s

Copy link
Member

Choose a reason for hiding this comment

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

TIL, thanks


go 1.23.0

require github.com/anchore/syft v1.14.2
Copy link
Member

Choose a reason for hiding this comment

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

I think this version of Syft may have CVEs in dependencies, we recently had to update rh-syft because of it.

Konflux isn't catching those?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is not. I used the same version that was here before to avoid any change in behavior. Let's merge this and I'll follow up with an update.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good 👍

@lcarva lcarva merged commit 6a43647 into redhat-appstudio:main Feb 5, 2025
4 checks passed
@lcarva lcarva deleted the use-better-binaries branch February 5, 2025 13:44
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.

2 participants