-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
cmd/go: build with vendor depends on modcache for checksums #46400
Comments
This is quite the issue for us, since there is also no way to skip adding the module info to the binary. |
If your (FWIW, I suspect that the issue in the original post is due to a bad interaction with |
clarifying: the issue (or one of the issues) is that you can |
@bcmills the file is tidy, the only difference is having the dependencies in your ~/go folder (which will be filled when you run
And here the
Conclusion: when you don't have the dependencies in ~/go, it will not insert the sums. |
I did some more research into this, the build info is built by this function: https://github.com/golang/go/blob/master/src/cmd/go/internal/load/pkg.go#L2269 It uses
go/src/cmd/go/internal/modfetch/fetch.go Line 732 in 599a1e4
I have added some debugging and the returned ziphash path is something like this: It then tries to open that file and doesn't exist ofcourse to then
|
Aha! I have been hunting this down for a little while, started with what I thought was bugs in SBoM software, eventually leading here. Is it fair to say that this is an error in how it processes and loads the modules? One of the points of
In my case, I cannot run In any case, is there some way I can assist? |
vendor directories don't contain enough data to verify against checksums, ref #27348 |
How interesting. Thanks for the helpful reference. Does that mean that when I So what is the right approach for combining:
|
Probably for now when we are building with |
@bcmills sounds like a good compromise yes |
@bcmills does it actually verify it for non-vendor builds though? |
For non- |
@bcmills If it doesn't verify it at build, adding the ziphash guarantees about as much as the go.sum hash, so in that case you might not want to add the checksum at all. Because why trust the user not editing the cache folder, but not trust it with not editing the vendor folder? |
@jerbob92 captured my thoughts really well (thanks). If when we build w/o However, if the build-time verification is identical - no verification - but just download time, then we should include the checksums both times as well. An alternative might be to verify build time for both, and therefore include enough in Beyond the "how do we fix this", what is the right approach using the current state of tooling to get checksums into the compiled binary? Is it to ensure that the go mod cache is properly populated before build, even if |
The module cache is per-user (or per-machine), verified at download time, and by default has read-only permissions. They are not equivalent. |
That is fair enough. Your point about, "we shouldn't include the hash unless we can verify with what we have at hand" is eminently sensible, although silently not verifying at all if there is no cache is a bit strange behaviour. It means that What would be the right path to getting equivalency? And what would be the right path to using and verifying and including hashes in |
@samthanawalla, this might be another good one for you to look into while you're working on #52792. |
Change https://go.dev/cl/564195 mentions this issue: |
Fixes golang#46400 Tested: Ran go test cmd/go Change-Id: I60655129c55d40a70a13ed23937ef990f315fd73 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/564195 Reviewed-by: Bryan Mills <[email protected]> Run-TryBot: Sam Thanawalla <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Commit-Queue: Sam Thanawalla <[email protected]>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
build a module with a vendor dir.
Whether or not the module sums are embedded depends on the module cache
What did you expect to see?
build output not affected by module cache contents
What did you see instead?
checksums only embedded when module cache is populated
cc @bcmills @jayconrod @matloob
The text was updated successfully, but these errors were encountered: