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

Make the build consistent across archs for Go to correctly report the package path inside the binary #127

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

macedogm
Copy link
Contributor

Problem:

The build process is passing directly the main.go file for the build. According to Go's spec, this results in Go not properly identifying the package and module path and then marking the compiled binary as command-line-arguments.

Before:

> go version -m main
main: go1.22.9
	path	command-line-arguments

Now:

> go version -m webhook 
webhook: go1.22.9
	path	github.com/harvester/harvester-network-controller/cmd/webhook
	mod	github.com/harvester/harvester-network-controller	(devel)

Although this is a minor thing and that doesn't affect the binary itself, it actually blocks security scanners, for example Trivy, from correctly matching the binary (and its path/module origin) with a VEX entry.

This was identified internally when a false-positive vulnerability that was supposed to be suppressed was still being reported in the scanning reports.

Solution:

Only pass the directory that contains the Go file to build, not the file itself.

Related Issue:
N/A

Test plan:

See above.

… package path inside the binary

Signed-off-by: Guilherme Macedo <[email protected]>
@macedogm
Copy link
Contributor Author

PTAL @bk201

Copy link

@ihcsim ihcsim left a comment

Choose a reason for hiding this comment

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

This makes sense to me. It also makes thing consistent with the h/h repo.

@bk201 bk201 requested a review from rrajendran17 December 3, 2024 01:37
@rrajendran17
Copy link
Contributor

LGTM,Thanks

@ihcsim ihcsim merged commit 637d6de into harvester:master Dec 5, 2024
4 checks passed
@ihcsim
Copy link

ihcsim commented Dec 5, 2024

@mergify backport v0.4.x v0.5.x

Copy link

mergify bot commented Dec 5, 2024

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.

3 participants