Repository navigation
Conversation
|
Awesome contribution. I have a few suggestions.
|
I think |
mafredri
left a comment
There was a problem hiding this comment.
Nice addition!
As previously mentioned, I think self-upgrade (or self-update) would be a good naming alternative.
A few things came to my mind as I was reviewing this:
- We shouldn't rely on the install script, we should instead build this out with Go code (example from restic: https://github.com/restic/restic/blob/master/cmd/restic/cmd_self_update.go)
- We should verify the hash of the downloaded binary against our signing key
The problem with 1) is that it's a point-of-failure on at least two fronts, 1. coder.com may be down and 2. someone may replace it with an arbitrary script by attacking coder.com server or hijacking the domain.
By doing 2) (verifying the hash), and fixing 1), we ensure that only a signed binary is able to update to another signed binary, this preventing many forms of MITM. Otherwise an attacker only needs to gain enough access to modify our GitHub release and upload a malicious binary in place of the real one.
I don't think we necessarily have to fix both in this PR, and we can use the install script for a short while, but IMO it should be fairly high priority to move to a built-in updating method.
| Short: "Upgrade the Coder CLI to match the version of a deployment.", | ||
| Options: clibase.OptionSet{ | ||
| { | ||
| Flag: "install-script-url", |
There was a problem hiding this comment.
Suggestion: We have some other flags introduced for tests that are named test.x (i.e. test.install-script-url). This way the purpose of the flag is more clear and won't collide with non-test flags.
|
|
||
| version := semver.Canonical(serverInfo.Version) | ||
| version = strings.TrimSuffix(version, "-devel") | ||
| version = strings.TrimPrefix(version, "v") |
There was a problem hiding this comment.
Should we check that this isn't 0.0.0 in case the server was built without Makefile?
| errC := inv.WithContext(ctx).Run() | ||
| assert.NoError(t, errC) |
There was a problem hiding this comment.
| errC := inv.WithContext(ctx).Run() | |
| assert.NoError(t, errC) | |
| err := inv.WithContext(ctx).Run() | |
| assert.NoError(t, err) |
| errC := inv.WithContext(ctx).Run() | ||
| assert.Error(t, errC) |
There was a problem hiding this comment.
| errC := inv.WithContext(ctx).Run() | |
| assert.Error(t, errC) | |
| err := inv.WithContext(ctx).Run() | |
| assert.Error(t, err) |
| } | ||
|
|
||
| // nolint: gosec | ||
| cmd := exec.Command("sh", "-s", "--", "--version", version) |
There was a problem hiding this comment.
I notice we're not controlling where the binary will end up (path). If the idea is for the binary to update itself, it should replace itself in the same location. Otherwise we will most definitely end up placing multiple coder binaries on user filesystems which would be confusing.
This could be a flag (--binary-path) to allow the user to change it (default arg0).
This may or may not have "file is in use" ramifications on certain systems as long as the coder command is running, but probably not on Linux/macOS.
|
People at fly.io seems to use the install script. |
Interesting. As a personal anecdote, I would be uncomfortable using that. 😄 |
fixes #2744
This PR provides a command to sync a
coderclient with a deployment. It is mostly an alias forcurl -L https://coder.com/install.sh | sh -s -- --version <version>It does not currently support Windows but I believe it should be possible to support. I'll try to get my hands on a Windows laptop tomorrow and try it out.