-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: install with explicit version should allow overriding versions of dependencies #44892
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
Comments
What if an extra argument results in no changes in version selection for the main package to be built? For example, |
It seems well-formed, so I think that should be allowed, even if it isn't necessarily useful. It might make it easier to install a bunch of commands from different modules:
The extra module dependency would still influence the |
My wording of "results in no changes in version selection" was also poor. What if I think what I meant is: reject arguments which can't possibly affect version selection for the main module, such as modules which are not in the module graph of the main module. That said, I think you're right that it seems too restrictive. It could also cause problems if |
Some comments from the golang-tools meeting earlier today:
|
I also worry about package/module ambiguity. The arguments to Users often try to upgrade dependencies by passing module paths to But if someone tries to do that with |
Consider also that it'd make it possible for users to make a command vulnerable (accidentally or by being tricked). Suppose that The same problem can happen when authors perform version selection, but this is to support that the responsibility of selecting versions is better suited for authors (fewer, goes through code review, vulnerability databases, etc.) than users (many, can be copy-pasted from anywhere). |
I was pushing for this but based on the discussion it sounds like we should probably not do it. |
Withdrawing this issue, reflecting discussion above. |
This issue is based on a discussion with @rsc around https://blog.golang.org/path-security.
Let's say I want to install a command with
go install example.com/cmd@latest
. I know that the latest version of that command depends on a version ofgolang.org/x/tools
that has a security vulnerability, so I actually want to buildexample.com/cmd
with a different version ofgolang.org/x/tools
where the vulnerability is fixed.In Go 1.16, this is an error.
go install cmd@version
requires that all arguments refer tomain
packages in the same module, at the same version. We could relax this a bit: if an argument refers to non-main packages (perhaps just a module path that's not a package, as above), that argument is used in version selection.In other words, the above command would do the same thing as:
The rules here should also apply to
go run example.com/cmd@version
and other commands if/when we support them.cc @bcmills @matloob
The text was updated successfully, but these errors were encountered: