Skip to content

cmd/go: disable server fetch by full hash #31191

@FiloSottile

Description

@FiloSottile

Unfortunately, the two major code hosts used in the Go ecosystem—GitHub and Gerrit—allow anyone to inject commits into any git repository. On GitHub PRs show up in refs/pull/ in the main repo, and in Gerrit CLs show up as refs/changes/. This regularly causes confusion.

This means that they are reachable across the wire. The git policy is that anything reachable from a ref can be fetched remotely. It also means they can be used as preudoversions.

For example, golang.org/x/crypto@v0.0.0-20190330071201-e19e1a02deae is a valid pseudoversion for the unmerged https://go-review.googlesource.com/c/crypto/+/169037/3. It also ranks higher than master, which is older.

The problem is that anyone would take a PR that updates golang.org/x/crypto from v0.0.0-20190325154230-a5d413f7728c to v0.0.0-20190330071201-e19e1a02deae, and the chances that they would review the diff are none. In modules world in particular, using a module delegates trust to its author, but allowing anyone to effectively publish a pseudoversion for any module breaks that trust system.

We need to make sure anything we fetch is reachable from refs/heads or refs/tags.

Besides performance, there is a major drawback to that: if something was reachable but isn't anymore, it won't be possible to fetch it directly anymore. I'm afraid there is no way around it. (Hopefully a proxy might still have it cached.)

This is a superset of #30434: fixing this fixes the unexpected behavior there, too.

/cc @jayconrod @bcmills

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions