From ea1a47fa08f48f68746540bee45f4d1ecd862856 Mon Sep 17 00:00:00 2001 From: Martin Multhaupt Date: Fri, 26 May 2023 16:34:04 +0200 Subject: [PATCH 1/9] First draft implementation for scheme handler registry --- CHANGES.md | 3 + cmd/launcher/launcher/run.go | 19 ++++- docs/deployment-config.md | 3 + docs/glossary.md | 3 + go.mod | 3 + go.sum | 94 ++++++++++++++---------- pkg/launcher/bundle/updater.go | 4 +- pkg/launcher/config/deployment_config.go | 6 ++ 8 files changed, 94 insertions(+), 41 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 79dd6430..17a79309 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,9 @@ # Release-Changelog ## TBD (TBD) +### Features +* Add option to register `SchemeHandlers` to deployment-config. See [deployment-config.md](docs/deployment-config.md). + ### Changes * Raise minimum golang requirement to 1.17 diff --git a/cmd/launcher/launcher/run.go b/cmd/launcher/launcher/run.go index dc99766f..750e48a8 100644 --- a/cmd/launcher/launcher/run.go +++ b/cmd/launcher/launcher/run.go @@ -2,8 +2,11 @@ package launcher import ( "context" + "strings" + "github.com/setlog/systemuri" "github.com/setlog/trivrost/pkg/launcher/config" + "github.com/setlog/trivrost/pkg/system" "github.com/setlog/trivrost/cmd/launcher/flags" "github.com/setlog/trivrost/cmd/launcher/gui" @@ -24,7 +27,7 @@ func Run(ctx context.Context, launcherFlags *flags.LauncherFlags) { updater := createUpdater(ctx, wireHandler(gui.NewGuiDownloadProgressHandler(fetching.MaxConcurrentDownloads))) gui.SetStage(gui.StageGetDeploymentConfig, 0) - updater.Prepare(resources.LauncherConfig.DeploymentConfigURL) + updater.ObtainDeploymentConfig(resources.LauncherConfig.DeploymentConfigURL) if !IsInstanceInstalledInSystemMode() && !launcherFlags.SkipSelfUpdate { updateLauncherToLatestVersion(updater, launcherFlags) @@ -33,6 +36,7 @@ func Run(ctx context.Context, launcherFlags *flags.LauncherFlags) { gui.SetStage(gui.StageLaunchApplication, 0) handleUpdateOmissions(ctx, updater) + registerSchemeHandlers(launcherFlags, updater.GetDeploymentConfig().SchemeHandlers) launch(ctx, updater.GetDeploymentConfig().Execution, launcherFlags) } @@ -101,6 +105,19 @@ func handleInsufficientPrivileges(ctx context.Context, wasAtLeastOneMandatoryUpd } } +func registerSchemeHandlers(launcherFlags *flags.LauncherFlags, schemaHandlers []config.SchemeHandler) { + transmittingFlags := launcherFlags.GetTransmittingFlags() + for _, schemaHandler := range schemaHandlers { + // TODO: Create flag "-lockagnostic" (or such) to allow to eliminate all self-restarting behavior (when used in combination with "-skipselfupdate") to reduce UI flickering? + // TODO: Create and then always add flag "-skipschemehandlerregistry" (or such) here to prevent -extra-env from being added? + // TODO: systemuri does not presently allow a commandLine: only application path. + // TODO: systemuri does not presently allow positional URL resource template argument according to deployment-config.md. + // TODO: systemuri does not presently implement %%-escapes according to deployment-config.md. + commandLine := system.GetBinaryPath() + " " + strings.Join(transmittingFlags, " ") + schemaHandler.ArgumentLine + systemuri.RegisterURLHandler(resources.LauncherConfig.BrandingName, schemaHandler.Scheme, commandLine) + } +} + func launch(ctx context.Context, execution config.ExecutionConfig, launcherFlags *flags.LauncherFlags) { executeCommands(ctx, execution.Commands, launcherFlags) lingerTimeMilliseconds = execution.LingerTimeMilliseconds diff --git a/docs/deployment-config.md b/docs/deployment-config.md index a8849d14..1b5f4ac7 100644 --- a/docs/deployment-config.md +++ b/docs/deployment-config.md @@ -5,6 +5,9 @@ The deployment-config is a JSON-file which is supposed to be hosted on a webserv ## Fields * **`Timestamp`** (string): A timestamp in the form `YYYY-MM-DD HH:mm:SS` which indicates when the deployment-config was last changed. This field protects trivrost against attacks. A utility script `script/insert_timestamp` is provided, which replaces a placeholder with a current timestamp. It can be called like this: `insert_timestamp "" …/deployment-config.json`. See [security.md](security.md) for more information. +* **`SchemeHandlers`** (array): An array of objects which define scheme handlers to be registered with the operating system to run trivrost with a specified command line. + * **`Scheme`** (string): The scheme for which to register the handler, such as `mailto`. We recommend to use some sort of reverse-DNS scheme, e.g. `com.example.productname.customername`. + * **`ArgumentLine`** (string): The arguments to pass. Any occurrences of the special string `%s` will be replaced with the operating system-specific template which receives the resource part of the URL (i.e. path, query and fragment). Any occurrences of `%%` will be replaced with `%` to allow for a literal string `%s` to be written (not that we'd recommend doing so). Note that any [transmitting flags](glossary.md#transmitting-flags) will be prepended to these arguments at the time of registry. * **`LauncherUpdate`** (array): An array of objects which define bundle configurations for how trivrost updates itself. When trivrost runs, this list must boil down to either one single configuration, or no configurations, through filtering by `TargetPlatforms`. * **`BundleInfoURL`**, **`BaseURL`**, **`TargetPlatforms`**: See [Common fields](#Common-fields) below. * **`Bundles`** (array): An array of objects which define the bundles which trivrost should download and keep up to date. diff --git a/docs/glossary.md b/docs/glossary.md index 6cfac3cd..249acf4d 100644 --- a/docs/glossary.md +++ b/docs/glossary.md @@ -20,3 +20,6 @@ The deployment config tells trivrost where to check for updates to itself and it ## trivrost deployment artifact We occasionally need to differ between just trivrost's executable binary and its entire deployment artifact as a whole. On Windows and Linux these two concepts are the same thing. On MacOS however, the deployment artifact of trivrost actually is a `.app`-folder, which contains the binary at `Contents/MacOS/launcher`. + +## Transmitting flags +Whenever trivrost restarts itself as part of its exclusive lock and self-update mechanisms, it passes most of the command line arguments it was run with (such as `-skipselfupdate`) to the new instance as well. We refer to arguments affected by this as "transmitting flags". diff --git a/go.mod b/go.mod index 3e04b0ed..88ac0be0 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( github.com/gofrs/flock v0.8.1 github.com/mattn/go-ieproxy v0.0.11 github.com/prometheus/client_golang v1.15.1 + github.com/setlog/systemuri v0.0.0-20230526080928-88974150704d github.com/shirou/gopsutil v3.21.11+incompatible github.com/sirupsen/logrus v1.9.0 github.com/stretchr/testify v1.8.3 @@ -22,6 +23,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/golang/protobuf v1.5.3 // indirect + github.com/kr/text v0.2.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.17 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect @@ -30,6 +32,7 @@ require ( github.com/prometheus/client_model v0.3.0 // indirect github.com/prometheus/common v0.42.0 // indirect github.com/prometheus/procfs v0.9.0 // indirect + github.com/rogpeppe/go-internal v1.10.0 // indirect github.com/tklauser/go-sysconf v0.3.4 // indirect github.com/tklauser/numcpus v0.2.1 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect diff --git a/go.sum b/go.sum index 1003eca8..47827055 100644 --- a/go.sum +++ b/go.sum @@ -19,6 +19,7 @@ cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvf cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/compute/metadata v0.2.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= @@ -35,11 +36,13 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/MMulthaupt/chronometry v0.1.1 h1:7z/2ORMk42/k1pEdBG2LIrNWcKjdqXabljsgmKUCLHA= github.com/MMulthaupt/chronometry v0.1.1/go.mod h1:sp7LDX9NJVTqiR84IGVlzHhAJoS/kByMVy77Es08ciI= +github.com/alecthomas/kingpin/v2 v2.3.1/go.mod h1:oYL5vtsvEHZGHxU7DMp32Dvx+qL+ptGn6lWaot2vCNE= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= github.com/andlabs/ui v0.0.0-20200610043537-70a69d6ae31e h1:wSQCJiig/QkoUnpvelSPbLiZNWvh2yMqQTQvIQqSUkU= github.com/andlabs/ui v0.0.0-20200610043537-70a69d6ae31e/go.mod h1:5G2EjwzgZUPnnReoKvPWVneT8APYbyKkihDVAHUi0II= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -48,7 +51,6 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -57,6 +59,7 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -64,8 +67,6 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= -github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -74,9 +75,12 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2 github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= +github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= @@ -109,7 +113,6 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= @@ -123,8 +126,10 @@ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -154,26 +159,21 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U= -github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-ieproxy v0.0.1 h1:qiyop7gCflfhwCzGyeT0gro3sF9AIg9HU98JORTkqfI= -github.com/mattn/go-ieproxy v0.0.1/go.mod h1:pYabZ6IHcRpFh7vIaLfK7rdcWgFEb3SFJ6/gNWuh88E= github.com/mattn/go-ieproxy v0.0.11 h1:MQ/5BuGSgDAHZOJe6YY80IF2UVCfGkwfo6AeD7HtHYo= github.com/mattn/go-ieproxy v0.0.11/go.mod h1:/NsJd+kxZBmjMc5hrJCKMbP57B84rvq9BiDRbtO9AS0= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= @@ -184,6 +184,7 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -194,33 +195,37 @@ github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.12.2 h1:51L9cDoUHVrXx4zWYlcLQIZ+d+VXHgqnYKkIuq4g/34= -github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= github.com/prometheus/client_golang v1.15.1 h1:8tXpTmJbyH5lydzFPoxSIJ0J46jdh3tylbvM1xCv0LI= github.com/prometheus/client_golang v1.15.1/go.mod h1:e9yaBhRPU2pPNsZwE+JdQl0KEt1N9XgF6zxWmaC0xOk= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/setlog/systemuri v0.0.0-20230526080928-88974150704d h1:AQGV8NyH71kpiuW35nvqfnFe9ffrCsdAWrSQjyEqxiQ= +github.com/setlog/systemuri v0.0.0-20230526080928-88974150704d/go.mod h1:gq1832MMUy0gN037ydvmttmzlYhqUUPO/sVNrVQ60d4= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= @@ -233,13 +238,13 @@ github.com/smallnest/preallocate v0.1.1/go.mod h1:9yyz7jeM3zMwFJ0o6Njpu3K9KeXnWe github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.5 h1:s5PTfem8p8EbKQOctVV53k6jCJt3UX4IEJzwh+C324Q= -github.com/stretchr/testify v1.7.5/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tklauser/go-sysconf v0.3.4 h1:HT8SVixZd3IzLdfs/xlpq0jeSfTX57g1v6wB1EuzV7M= @@ -252,9 +257,11 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= +github.com/xhit/go-str2duration v1.2.0/go.mod h1:3cPSlfZlUHVlneIVfePFWcJZsuwf+P1v2SRTV4cUmp4= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= @@ -268,6 +275,7 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -298,6 +306,8 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -312,7 +322,6 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191112182307-2180aed22343/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -327,10 +336,12 @@ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220930213112-107f3e3c3b0b h1:uKO3Js8lXGjpjdc4J3rqs0/Ex5yDKUGfk43tTYWVLas= -golang.org/x/net v0.0.0-20220930213112-107f3e3c3b0b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= @@ -340,6 +351,8 @@ golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.5.0/go.mod h1:9/XBHVqLaWO3/BRHs5jbpYCnOZVjj5V0ndyaAM7KB4I= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -349,6 +362,9 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -364,12 +380,10 @@ golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191112214154-59a1497f0cea/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -390,28 +404,28 @@ golang.org/x/sys v0.0.0-20210217105451-b926d437f341/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 h1:v6hYoSR9T5oet+pMXwUWkbiVqx/63mlHjefrHmxwfeY= -golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= @@ -458,10 +472,11 @@ golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= @@ -485,6 +500,7 @@ google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -537,15 +553,17 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/pkg/launcher/bundle/updater.go b/pkg/launcher/bundle/updater.go index 467417ad..f886c278 100644 --- a/pkg/launcher/bundle/updater.go +++ b/pkg/launcher/bundle/updater.go @@ -68,8 +68,8 @@ func (u *Updater) announceStatus(status UpdaterStatus, progressTarget uint64) { } } -func (u *Updater) Prepare(deploymentConfigURL string) { - log.Infof("Downloading deployment config from \"%s\".", deploymentConfigURL) +func (u *Updater) ObtainDeploymentConfig(deploymentConfigURL string) { + log.Infof("Obtaining deployment config from \"%s\".", deploymentConfigURL) data, err := u.downloader.DownloadSignedResource(deploymentConfigURL, u.publicKeys) if err != nil { panic(err) diff --git a/pkg/launcher/config/deployment_config.go b/pkg/launcher/config/deployment_config.go index be8c6db0..62bb0f9b 100644 --- a/pkg/launcher/config/deployment_config.go +++ b/pkg/launcher/config/deployment_config.go @@ -12,11 +12,17 @@ import ( type DeploymentConfig struct { Timestamp string `json:"Timestamp,omitempty"` + SchemeHandlers []SchemeHandler `json:"SchemeHandlers,omitempty"` LauncherUpdate []LauncherUpdateConfig `json:"LauncherUpdate,omitempty"` Bundles []BundleConfig `json:"Bundles,omitempty"` Execution ExecutionConfig `json:"Execution,omitempty"` } +type SchemeHandler struct { + Scheme string `json:"Scheme,omitempty"` + ArgumentLine string `json:"ArgumentLine,omitempty"` +} + type HashDataConfig struct { BundleInfoURL string `json:"BundleInfoURL"` BaseURL string `json:"BaseURL,omitempty"` From 21bbe86ab7f425bd33e94b9966224974077aa331 Mon Sep 17 00:00:00 2001 From: Michael G Date: Thu, 1 Jun 2023 11:41:05 +0200 Subject: [PATCH 2/9] Update implementation --- cmd/launcher/launcher/install.go | 20 ++++++++++++++++++++ cmd/launcher/launcher/run.go | 23 +++-------------------- cmd/launcher/launcher/uninstall.go | 11 +++++++++++ docs/deployment-config.md | 2 +- go.mod | 2 +- go.sum | 6 ++++-- pkg/launcher/config/deployment_config.go | 4 ++-- 7 files changed, 42 insertions(+), 26 deletions(-) diff --git a/cmd/launcher/launcher/install.go b/cmd/launcher/launcher/install.go index e3b0f41e..22cb805d 100644 --- a/cmd/launcher/launcher/install.go +++ b/cmd/launcher/launcher/install.go @@ -1,6 +1,7 @@ package launcher import ( + "github.com/setlog/trivrost/pkg/launcher/config" "os/exec" "path/filepath" "runtime" @@ -8,6 +9,7 @@ import ( "sync" "time" + "github.com/setlog/systemuri" "github.com/setlog/trivrost/cmd/launcher/flags" "github.com/setlog/trivrost/cmd/launcher/resources" @@ -111,6 +113,8 @@ func Install(launcherFlags *flags.LauncherFlags) { InstallShortcuts(targetProgramPath, launcherFlags) + // Registering the scheme handlers had to happen in run.go, since we do not have the deployment config here, yet. + MustRestartWithInstalledBinary(launcherFlags) } @@ -124,6 +128,22 @@ func InstallShortcuts(targetProgramPath string, launcherFlags *flags.LauncherFla waitGroup.Wait() } +// RegisterSchemeHandlers registers the schemes defined in the deployment config +func RegisterSchemeHandlers(launcherFlags *flags.LauncherFlags, schemeHandlers []config.SchemeHandler) { + transmittingFlags := launcherFlags.GetTransmittingFlags() + for _, schemeHandler := range schemeHandlers { + // TODO: Create flag "-lockagnostic" (or such) to allow to eliminate all self-restarting behavior (when used in combination with "-skipselfupdate") to reduce UI flickering? + // TODO: Create and then always add flag "-skipschemehandlerregistry" (or such) here to prevent -extra-env from being added? + // TODO: systemuri does not presently implement %%-escapes according to deployment-config.md. + binaryPath := system.GetBinaryPath() + arguments := strings.Join(transmittingFlags, " ") + schemeHandler.Arguments + err := systemuri.RegisterURLHandler(resources.LauncherConfig.BrandingName, schemeHandler.Scheme, binaryPath, arguments) + if err != nil { + log.Warnf("Registering the scheme \"%s\" failed: %v", schemeHandler.Scheme, err) + } + } +} + func MustRestartWithInstalledBinary(launcherFlags *flags.LauncherFlags) { locking.RestartWithBinary(true, getTargetBinaryPath(), launcherFlags) } diff --git a/cmd/launcher/launcher/run.go b/cmd/launcher/launcher/run.go index 750e48a8..0de2d681 100644 --- a/cmd/launcher/launcher/run.go +++ b/cmd/launcher/launcher/run.go @@ -2,17 +2,12 @@ package launcher import ( "context" - "strings" - - "github.com/setlog/systemuri" - "github.com/setlog/trivrost/pkg/launcher/config" - "github.com/setlog/trivrost/pkg/system" - "github.com/setlog/trivrost/cmd/launcher/flags" "github.com/setlog/trivrost/cmd/launcher/gui" "github.com/setlog/trivrost/cmd/launcher/locking" "github.com/setlog/trivrost/cmd/launcher/places" "github.com/setlog/trivrost/cmd/launcher/resources" + "github.com/setlog/trivrost/pkg/launcher/config" "github.com/setlog/trivrost/pkg/fetching" "github.com/setlog/trivrost/pkg/logging" @@ -36,7 +31,8 @@ func Run(ctx context.Context, launcherFlags *flags.LauncherFlags) { gui.SetStage(gui.StageLaunchApplication, 0) handleUpdateOmissions(ctx, updater) - registerSchemeHandlers(launcherFlags, updater.GetDeploymentConfig().SchemeHandlers) + // Registering the schema handlers here instead of install.go, since we have the updater (deployment config) here + RegisterSchemeHandlers(launcherFlags, updater.GetDeploymentConfig().SchemeHandlers) launch(ctx, updater.GetDeploymentConfig().Execution, launcherFlags) } @@ -105,19 +101,6 @@ func handleInsufficientPrivileges(ctx context.Context, wasAtLeastOneMandatoryUpd } } -func registerSchemeHandlers(launcherFlags *flags.LauncherFlags, schemaHandlers []config.SchemeHandler) { - transmittingFlags := launcherFlags.GetTransmittingFlags() - for _, schemaHandler := range schemaHandlers { - // TODO: Create flag "-lockagnostic" (or such) to allow to eliminate all self-restarting behavior (when used in combination with "-skipselfupdate") to reduce UI flickering? - // TODO: Create and then always add flag "-skipschemehandlerregistry" (or such) here to prevent -extra-env from being added? - // TODO: systemuri does not presently allow a commandLine: only application path. - // TODO: systemuri does not presently allow positional URL resource template argument according to deployment-config.md. - // TODO: systemuri does not presently implement %%-escapes according to deployment-config.md. - commandLine := system.GetBinaryPath() + " " + strings.Join(transmittingFlags, " ") + schemaHandler.ArgumentLine - systemuri.RegisterURLHandler(resources.LauncherConfig.BrandingName, schemaHandler.Scheme, commandLine) - } -} - func launch(ctx context.Context, execution config.ExecutionConfig, launcherFlags *flags.LauncherFlags) { executeCommands(ctx, execution.Commands, launcherFlags) lingerTimeMilliseconds = execution.LingerTimeMilliseconds diff --git a/cmd/launcher/launcher/uninstall.go b/cmd/launcher/launcher/uninstall.go index 7ee9a7e2..7397d4e9 100644 --- a/cmd/launcher/launcher/uninstall.go +++ b/cmd/launcher/launcher/uninstall.go @@ -7,6 +7,7 @@ import ( "regexp" "runtime" + "github.com/setlog/systemuri" "github.com/setlog/trivrost/cmd/launcher/locking" "github.com/setlog/trivrost/cmd/launcher/flags" @@ -38,11 +39,21 @@ func uninstall(launcherFlags *flags.LauncherFlags) { gui.ShowWaitDialog("Uninstalling "+brandingName, "Please wait as "+brandingName+" is uninstalling.") deletePlainFiles() deleteBundles() + unregisterSchemeHandlers() defer prepareProgramDeletionWithFinalizerFunc()() gui.HideWaitDialog() gui.BlockingDialog("Uninstallation complete", brandingName+" has been uninstalled.", []string{"Close"}, 0, launcherFlags.DismissGuiPrompts) } +// unregisterSchemeHandlers removes all handlers that are associated with this binary +func unregisterSchemeHandlers() { + binaryPath := system.GetBinaryPath() + err := systemuri.UnregisterURLHandlerByPath(binaryPath) + if err != nil { + log.Warnf("Unregistering the schemes for binary \"%s\" failed: %v", binaryPath, err) + } +} + func deletePlainFiles() { deleteDesktopShortcuts() if runtime.GOOS != system.OsMac { diff --git a/docs/deployment-config.md b/docs/deployment-config.md index 1b5f4ac7..ed9ed589 100644 --- a/docs/deployment-config.md +++ b/docs/deployment-config.md @@ -7,7 +7,7 @@ The deployment-config is a JSON-file which is supposed to be hosted on a webserv * **`Timestamp`** (string): A timestamp in the form `YYYY-MM-DD HH:mm:SS` which indicates when the deployment-config was last changed. This field protects trivrost against attacks. A utility script `script/insert_timestamp` is provided, which replaces a placeholder with a current timestamp. It can be called like this: `insert_timestamp "" …/deployment-config.json`. See [security.md](security.md) for more information. * **`SchemeHandlers`** (array): An array of objects which define scheme handlers to be registered with the operating system to run trivrost with a specified command line. * **`Scheme`** (string): The scheme for which to register the handler, such as `mailto`. We recommend to use some sort of reverse-DNS scheme, e.g. `com.example.productname.customername`. - * **`ArgumentLine`** (string): The arguments to pass. Any occurrences of the special string `%s` will be replaced with the operating system-specific template which receives the resource part of the URL (i.e. path, query and fragment). Any occurrences of `%%` will be replaced with `%` to allow for a literal string `%s` to be written (not that we'd recommend doing so). Note that any [transmitting flags](glossary.md#transmitting-flags) will be prepended to these arguments at the time of registry. + * **`Arguments`** (string): The arguments to pass. Any occurrences of the special string `%s` will be replaced with the operating system-specific template which receives the resource part of the URL (i.e. path, query and fragment). Any occurrences of `%%` will be replaced with `%` to allow for a literal string `%s` to be written (we do not recommend doing so). * **`LauncherUpdate`** (array): An array of objects which define bundle configurations for how trivrost updates itself. When trivrost runs, this list must boil down to either one single configuration, or no configurations, through filtering by `TargetPlatforms`. * **`BundleInfoURL`**, **`BaseURL`**, **`TargetPlatforms`**: See [Common fields](#Common-fields) below. * **`Bundles`** (array): An array of objects which define the bundles which trivrost should download and keep up to date. diff --git a/go.mod b/go.mod index 88ac0be0..709035f6 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/gofrs/flock v0.8.1 github.com/mattn/go-ieproxy v0.0.11 github.com/prometheus/client_golang v1.15.1 - github.com/setlog/systemuri v0.0.0-20230526080928-88974150704d + github.com/setlog/systemuri v0.0.0-20230601092534-82770c4053ba github.com/shirou/gopsutil v3.21.11+incompatible github.com/sirupsen/logrus v1.9.0 github.com/stretchr/testify v1.8.3 diff --git a/go.sum b/go.sum index 47827055..1dc5b236 100644 --- a/go.sum +++ b/go.sum @@ -224,8 +224,10 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/setlog/systemuri v0.0.0-20230526080928-88974150704d h1:AQGV8NyH71kpiuW35nvqfnFe9ffrCsdAWrSQjyEqxiQ= -github.com/setlog/systemuri v0.0.0-20230526080928-88974150704d/go.mod h1:gq1832MMUy0gN037ydvmttmzlYhqUUPO/sVNrVQ60d4= +github.com/setlog/systemuri v0.0.0-20230601090920-e6e374b3b5f4 h1:k0gCu2523rknGl1l2o/zrEmSv1/YVcBgWAJRW/YstR0= +github.com/setlog/systemuri v0.0.0-20230601090920-e6e374b3b5f4/go.mod h1:gq1832MMUy0gN037ydvmttmzlYhqUUPO/sVNrVQ60d4= +github.com/setlog/systemuri v0.0.0-20230601092534-82770c4053ba h1:6vHnyps2j1UyoUISvDCy/jhT4beUlQtHRdyatAKz6WE= +github.com/setlog/systemuri v0.0.0-20230601092534-82770c4053ba/go.mod h1:gq1832MMUy0gN037ydvmttmzlYhqUUPO/sVNrVQ60d4= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= diff --git a/pkg/launcher/config/deployment_config.go b/pkg/launcher/config/deployment_config.go index 62bb0f9b..7f1ba010 100644 --- a/pkg/launcher/config/deployment_config.go +++ b/pkg/launcher/config/deployment_config.go @@ -19,8 +19,8 @@ type DeploymentConfig struct { } type SchemeHandler struct { - Scheme string `json:"Scheme,omitempty"` - ArgumentLine string `json:"ArgumentLine,omitempty"` + Scheme string `json:"Scheme,omitempty"` + Arguments string `json:"Arguments,omitempty"` } type HashDataConfig struct { From f47ce9b73fccab209a0bb2e28c5a8268d3cf91ab Mon Sep 17 00:00:00 2001 From: Michael G Date: Thu, 1 Jun 2023 11:42:02 +0200 Subject: [PATCH 3/9] Fix typos --- cmd/launcher/launcher/install.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/launcher/launcher/install.go b/cmd/launcher/launcher/install.go index 22cb805d..513927b4 100644 --- a/cmd/launcher/launcher/install.go +++ b/cmd/launcher/launcher/install.go @@ -45,12 +45,12 @@ func IsInstanceInstalled() bool { return isInstalled } -// IsInstanceInstalledInSystemMode returns true iff we are in system mode. +// IsInstanceInstalledInSystemMode returns true if we are in system mode. func IsInstanceInstalledInSystemMode() bool { return system.FolderExists(places.GetSystemWideBundleFolderPath()) } -// IsInstanceInstalledForCurrentUser returns true iff the launcher's desired path under user files is occupied by the program running this code. +// IsInstanceInstalledForCurrentUser returns true if the launcher's desired path under user files is occupied by the program running this code. func IsInstanceInstalledForCurrentUser() bool { programPath := system.GetProgramPath() targetProgramPath := getTargetProgramPath() From 4397a1d3bd846c36899db006e2bf0d7910c8f318 Mon Sep 17 00:00:00 2001 From: Michael G Date: Thu, 1 Jun 2023 11:49:35 +0200 Subject: [PATCH 4/9] Clarify documentation --- docs/deployment-config.md | 2 +- examples/deployment-config.json.complex.example | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/deployment-config.md b/docs/deployment-config.md index ed9ed589..2a83b388 100644 --- a/docs/deployment-config.md +++ b/docs/deployment-config.md @@ -5,7 +5,7 @@ The deployment-config is a JSON-file which is supposed to be hosted on a webserv ## Fields * **`Timestamp`** (string): A timestamp in the form `YYYY-MM-DD HH:mm:SS` which indicates when the deployment-config was last changed. This field protects trivrost against attacks. A utility script `script/insert_timestamp` is provided, which replaces a placeholder with a current timestamp. It can be called like this: `insert_timestamp "" …/deployment-config.json`. See [security.md](security.md) for more information. -* **`SchemeHandlers`** (array): An array of objects which define scheme handlers to be registered with the operating system to run trivrost with a specified command line. +* **`SchemeHandlers`** (array): An array of objects which define scheme handlers to be registered with the operating system to run this trivrost app with a specified command line. The idea is to use it in combination with the `--extra-env` commandline option to pass info to the launched application. See also the [exhaustive example](../examples/deployment-config.json.complex.example) of the deployment-config. * **`Scheme`** (string): The scheme for which to register the handler, such as `mailto`. We recommend to use some sort of reverse-DNS scheme, e.g. `com.example.productname.customername`. * **`Arguments`** (string): The arguments to pass. Any occurrences of the special string `%s` will be replaced with the operating system-specific template which receives the resource part of the URL (i.e. path, query and fragment). Any occurrences of `%%` will be replaced with `%` to allow for a literal string `%s` to be written (we do not recommend doing so). * **`LauncherUpdate`** (array): An array of objects which define bundle configurations for how trivrost updates itself. When trivrost runs, this list must boil down to either one single configuration, or no configurations, through filtering by `TargetPlatforms`. diff --git a/examples/deployment-config.json.complex.example b/examples/deployment-config.json.complex.example index 09c70926..6a765e79 100644 --- a/examples/deployment-config.json.complex.example +++ b/examples/deployment-config.json.complex.example @@ -1,5 +1,11 @@ { "Timestamp": "2019-02-07 14:53:17", + "SchemeHandlers": [ + { + "Scheme": "com.setlog.example", + "Arguments": "--extra-env=\"APP_LAUNCH_OPTIONS=%s\"" + } + ], "LauncherUpdate": [ { "BundleInfoURL": "https://example.com/windows/launcher/bundleinfo.json", From f77a6f635d0cf399d7fef829a30123d47baa5e2b Mon Sep 17 00:00:00 2001 From: Michael G Date: Thu, 1 Jun 2023 16:03:41 +0200 Subject: [PATCH 5/9] Update deprecated API --- cmd/bundown/main.go | 3 +-- cmd/echo_field/main.go | 3 +-- cmd/installdown/main.go | 2 +- cmd/launcher/locking/signature_io.go | 5 ++--- cmd/metawriter/main.go | 7 +++---- cmd/signer/main.go | 6 +++--- cmd/validator/http.go | 9 +++++---- pkg/dummy/io_test.go | 6 +++--- pkg/fetching/downloader.go | 5 ++--- pkg/fetching/downloader_test.go | 9 +++++---- pkg/launcher/config/bundleinfo.go | 7 ++++--- pkg/launcher/timestamps/timestamps.go | 3 +-- pkg/misc/must.go | 3 +-- pkg/system/file_system_funcs.go | 6 +++--- 14 files changed, 35 insertions(+), 39 deletions(-) diff --git a/cmd/bundown/main.go b/cmd/bundown/main.go index a457b459..3a0e168c 100644 --- a/cmd/bundown/main.go +++ b/cmd/bundown/main.go @@ -6,7 +6,6 @@ import ( "flag" "fmt" "io" - "io/ioutil" "os" "path/filepath" "strings" @@ -145,7 +144,7 @@ func isFolder(filePath string) bool { } func mustReaderForFile(filePath string) io.Reader { - data, err := ioutil.ReadFile(filePath) + data, err := os.ReadFile(filePath) if err != nil { fatalf("Could not read file \"%s\": %v", filePath, err) } diff --git a/cmd/echo_field/main.go b/cmd/echo_field/main.go index 3fbe60e1..bc17c01c 100644 --- a/cmd/echo_field/main.go +++ b/cmd/echo_field/main.go @@ -5,7 +5,6 @@ import ( "flag" "fmt" "io" - "io/ioutil" "os" "github.com/setlog/trivrost/pkg/launcher/config" @@ -38,7 +37,7 @@ func parseFlags() { } func mustReaderForFile(filePath string) io.Reader { - data, err := ioutil.ReadFile(filePath) + data, err := os.ReadFile(filePath) if err != nil { fatalf("Could not read file \"%s\": %v", filePath, err) } diff --git a/cmd/installdown/main.go b/cmd/installdown/main.go index 5a5d293d..00e1a657 100644 --- a/cmd/installdown/main.go +++ b/cmd/installdown/main.go @@ -241,7 +241,7 @@ func configure() *wxsConfig { } func mustReaderForFile(filePath string) io.Reader { - data, err := ioutil.ReadFile(filePath) + data, err := os.ReadFile(filePath) if err != nil { fatalf("Could not read file \"%s\": %v", filePath, err) } diff --git a/cmd/launcher/locking/signature_io.go b/cmd/launcher/locking/signature_io.go index 9f7c99b4..a4d95b3f 100644 --- a/cmd/launcher/locking/signature_io.go +++ b/cmd/launcher/locking/signature_io.go @@ -3,7 +3,6 @@ package locking import ( "encoding/json" "fmt" - "io/ioutil" "os" "github.com/setlog/trivrost/pkg/system" @@ -11,7 +10,7 @@ import ( ) func readProcessSignatureListFile(filePath string) (procSigs []system.ProcessSignature) { - bytes, err := ioutil.ReadFile(filePath) + bytes, err := os.ReadFile(filePath) if err != nil { if os.IsNotExist(err) { return nil @@ -36,7 +35,7 @@ func mustWriteProcessSignatureListFile(filePath string, procSigs []system.Proces if err != nil { panic(fmt.Sprintf("Could not marshal process signature slice of length %d: %v", len(procSigs), err)) } - err = ioutil.WriteFile(filePath, bytes, 0666) + err = os.WriteFile(filePath, bytes, 0666) if err != nil { panic(fmt.Sprintf("Could not write process signature list file \"%s\": %v", filePath, err)) } diff --git a/cmd/metawriter/main.go b/cmd/metawriter/main.go index d53dbe9e..e4ea1fad 100644 --- a/cmd/metawriter/main.go +++ b/cmd/metawriter/main.go @@ -5,7 +5,6 @@ import ( "flag" "fmt" "io" - "io/ioutil" "os" "strconv" "strings" @@ -56,7 +55,7 @@ func replacePlaceholders(text string) string { func mustReadFile(filePath string) string { fmt.Printf("Metawriter: Reading \"%s\".\n", filePath) - data, err := ioutil.ReadFile(filePath) + data, err := os.ReadFile(filePath) if err != nil { fatalf("Could not read \"%s\": %v", filePath, err) } @@ -65,7 +64,7 @@ func mustReadFile(filePath string) string { func mustWriteFile(filePath string, data []byte) { fmt.Printf("Metawriter: Writing \"%s\".\n", filePath) - err := ioutil.WriteFile(filePath, data, 0600) + err := os.WriteFile(filePath, data, 0600) if err != nil { fatalf("Could not open file \"%s\" for writing: %v", filePath, err) } @@ -108,7 +107,7 @@ func validateVariables() { } func mustReaderForFile(filePath string) io.Reader { - data, err := ioutil.ReadFile(filePath) + data, err := os.ReadFile(filePath) if err != nil { fatalf("Could not read file \"%s\": %v", filePath, err) } diff --git a/cmd/signer/main.go b/cmd/signer/main.go index fae8033f..9f7c8ef5 100644 --- a/cmd/signer/main.go +++ b/cmd/signer/main.go @@ -10,7 +10,6 @@ import ( "encoding/pem" "flag" "fmt" - "io/ioutil" "os" ) @@ -35,7 +34,8 @@ func createSignatures() { if err != nil { fatalf("Creating of a signature for the file %s failed: %v", targetFiles[i], err) } - if err = ioutil.WriteFile(targetFiles[i]+".signature", []byte(signature), 0644); err != nil { + + if err = os.WriteFile(targetFiles[i]+".signature", []byte(signature), 0644); err != nil { fatalf("Could not write a signature into the file %s.signature: %v", targetFiles[i], err) } } @@ -55,7 +55,7 @@ func createFileSignature(key *rsa.PrivateKey, fileContent []byte) (string, error } func readFile(fileName string) []byte { - content, err := ioutil.ReadFile(fileName) + content, err := os.ReadFile(fileName) if err != nil { fatalf("Could not read a file %s: %v", fileName, err) } diff --git a/cmd/validator/http.go b/cmd/validator/http.go index f17117c6..a87efb7e 100644 --- a/cmd/validator/http.go +++ b/cmd/validator/http.go @@ -2,9 +2,10 @@ package main import ( "fmt" - "io/ioutil" + "io" "net/http" "net/url" + "os" "time" ) @@ -12,9 +13,9 @@ func getFile(fileUrlString string) ([]byte, error) { fileUrl, err := url.Parse(fileUrlString) if err == nil && fileUrl.Scheme == "file" { fileUrl.Scheme = "" - return ioutil.ReadFile(fileUrl.String()) + return os.ReadFile(fileUrl.String()) } else if err != nil || fileUrl.Scheme == "" { - return ioutil.ReadFile(fileUrlString) + return os.ReadFile(fileUrlString) } client := &http.Client{} @@ -27,7 +28,7 @@ func getFile(fileUrlString string) ([]byte, error) { if resp.StatusCode != http.StatusOK { return nil, fmt.Errorf("received bad status code %s", resp.Status) } - return ioutil.ReadAll(resp.Body) + return io.ReadAll(resp.Body) } func getHttpHeadResult(url string) (responseCode int, err error) { diff --git a/pkg/dummy/io_test.go b/pkg/dummy/io_test.go index 0ae4c62b..27ea8540 100644 --- a/pkg/dummy/io_test.go +++ b/pkg/dummy/io_test.go @@ -2,7 +2,7 @@ package dummy_test import ( "bytes" - "io/ioutil" + "io" "testing" "github.com/setlog/trivrost/pkg/dummy" @@ -12,7 +12,7 @@ import ( func TestReadCloser(t *testing.T) { data := []byte("super amazing data") rc := &dummy.ByteReadCloser{Buffer: bytes.NewBuffer(data)} - readData, err := ioutil.ReadAll(rc) + readData, err := io.ReadAll(rc) if err != nil { t.Fatalf("Error: %v", err) } @@ -24,7 +24,7 @@ func TestReadCloser(t *testing.T) { func TestReadCloserBigFile(t *testing.T) { data := []byte("hyper amazing data" + misc.MustGetRandomHexString(10000)) rc := &dummy.ByteReadCloser{Buffer: bytes.NewBuffer(data)} - readData, err := ioutil.ReadAll(rc) + readData, err := io.ReadAll(rc) if err != nil { t.Fatalf("Error: %v", err) } diff --git a/pkg/fetching/downloader.go b/pkg/fetching/downloader.go index 650477a4..8e0c434f 100644 --- a/pkg/fetching/downloader.go +++ b/pkg/fetching/downloader.go @@ -8,7 +8,6 @@ import ( "encoding/hex" "fmt" "io" - "io/ioutil" "log" "net/http" "os" @@ -141,12 +140,12 @@ func (downloader *Downloader) DownloadToRAM(fileMap config.FileInfoMap) (fileDat return fileData, downloader.DownloadResources(fileMap.FilePaths(), func(dl *Download) error { wantedFileInfo := fileMap[dl.url] hash := sha256.New() - data, err := ioutil.ReadAll(io.TeeReader(dl, hash)) + data, err := io.ReadAll(io.TeeReader(dl, hash)) if err != nil { if downloader.ctx.Err() != nil { return downloader.ctx.Err() } - return fmt.Errorf("ioutil.ReadAll failed: %v", err) + return fmt.Errorf("io.ReadAll failed: %v", err) } dlFileSha := hex.EncodeToString(hash.Sum(nil)) if wantedFileInfo.SHA256 != "" && !strings.EqualFold(wantedFileInfo.SHA256, dlFileSha) { diff --git a/pkg/fetching/downloader_test.go b/pkg/fetching/downloader_test.go index 8bac8974..83eb2d31 100644 --- a/pkg/fetching/downloader_test.go +++ b/pkg/fetching/downloader_test.go @@ -6,6 +6,7 @@ import ( "crypto/sha256" "encoding/hex" "fmt" + "io" "io/ioutil" "math/rand" "net/http" @@ -77,7 +78,7 @@ func (db *RiggedReader) Close() error { func (de *DummyEnvironment) TestDownload(t *testing.T, fromUrl string) { dl := NewDownload(context.Background(), fromUrl) - data, err := ioutil.ReadAll(dl) + data, err := io.ReadAll(dl) if err != nil { t.Fatalf("Download \"%s\" failed unexpectedly: %v", fromUrl, err) } @@ -94,7 +95,7 @@ func (de *DummyEnvironment) TestDownloadCancel(t *testing.T, fromUrl string, can t.Fatalf("Download \"%s\" could not deliver %d bytes: %v", fromUrl, cancelAfter, err) } cancelFunc() - data, err := ioutil.ReadAll(dl) + data, err := io.ReadAll(dl) if err != context.Canceled { t.Fatalf("Download \"%s\" did not fail with context.Canceled after %d bytes. Remainder: %d. Error: %v", fromUrl, cancelAfter, len(data), err) } @@ -102,7 +103,7 @@ func (de *DummyEnvironment) TestDownloadCancel(t *testing.T, fromUrl string, can func (de *DummyEnvironment) TestDownloadFailure(t *testing.T, fromUrl string) { dl := NewDownload(context.Background(), fromUrl) - _, err := ioutil.ReadAll(dl) + _, err := io.ReadAll(dl) if err == nil { t.Fatalf("Download \"%s\" succeeded unexpectedly", fromUrl) } @@ -174,7 +175,7 @@ func TestUpdateFile(t *testing.T) { t.Fatal(err) } defer os.Remove("testfile.txt") - diskData, err := ioutil.ReadFile("testfile.txt") + diskData, err := os.ReadFile("testfile.txt") if err != nil { t.Fatal(err) } diff --git a/pkg/launcher/config/bundleinfo.go b/pkg/launcher/config/bundleinfo.go index dd7124ef..40f60654 100644 --- a/pkg/launcher/config/bundleinfo.go +++ b/pkg/launcher/config/bundleinfo.go @@ -3,7 +3,8 @@ package config import ( "encoding/json" "fmt" - "io/ioutil" + "io" + "os" "path/filepath" "strings" @@ -120,7 +121,7 @@ func (bundleFiles FileInfoMap) FilePaths() []string { } func ReadInfo(filePath string) *BundleInfo { - data, err := ioutil.ReadFile(filePath) + data, err := os.ReadFile(filePath) if err != nil { panic(err) } @@ -128,7 +129,7 @@ func ReadInfo(filePath string) *BundleInfo { } func ReadInfoFromReader(reader *strings.Reader) *BundleInfo { - data, err := ioutil.ReadAll(reader) + data, err := io.ReadAll(reader) if err != nil { panic(err) } diff --git a/pkg/launcher/timestamps/timestamps.go b/pkg/launcher/timestamps/timestamps.go index a2b6baf4..184b5f11 100644 --- a/pkg/launcher/timestamps/timestamps.go +++ b/pkg/launcher/timestamps/timestamps.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "os" "time" @@ -60,7 +59,7 @@ func (timestamps *Timestamps) write(filePath string) { } func ReadTimestampsFromReader(reader io.Reader) *Timestamps { - bytes, err := ioutil.ReadAll(reader) + bytes, err := io.ReadAll(reader) if err != nil { panic(fmt.Sprintf("Could not read from reader: %v", err)) } diff --git a/pkg/misc/must.go b/pkg/misc/must.go index 763c02a3..f2676818 100644 --- a/pkg/misc/must.go +++ b/pkg/misc/must.go @@ -3,11 +3,10 @@ package misc import ( "encoding/json" "io" - "io/ioutil" ) func MustReadAll(fromReader io.Reader) []byte { - data, err := ioutil.ReadAll(fromReader) + data, err := io.ReadAll(fromReader) if err != nil { panic(err) } diff --git a/pkg/system/file_system_funcs.go b/pkg/system/file_system_funcs.go index 02409bef..4fd7ddfd 100644 --- a/pkg/system/file_system_funcs.go +++ b/pkg/system/file_system_funcs.go @@ -99,7 +99,7 @@ func MustPutFile(localFilePath string, bytes []byte) { } func MustReadFile(filePath string) []byte { - data, err := ioutil.ReadFile(filePath) + data, err := os.ReadFile(filePath) if err != nil { panic(&FileSystemError{fmt.Sprintf("Could not read file \"%s\"", filePath), err}) } @@ -107,7 +107,7 @@ func MustReadFile(filePath string) []byte { } func MustCopyFile(from, to string) { - data, err := ioutil.ReadFile(from) + data, err := os.ReadFile(from) if err != nil { panic(&FileSystemError{fmt.Sprintf("Could not read file \"%s\"", from), err}) } @@ -116,7 +116,7 @@ func MustCopyFile(from, to string) { panic(&FileSystemError{fmt.Sprintf("Could not stat file \"%s\"", from), err}) } log.Debugf(`Copying "%s" to "%s" with mode %s.`, from, to, strconv.FormatInt(int64(info.Mode()), 8)) - err = ioutil.WriteFile(to, data, info.Mode()) + err = os.WriteFile(to, data, info.Mode()) if err != nil { panic(&FileSystemError{fmt.Sprintf("Could not write file \"%s\"", to), err}) } From 3f0ce90daa49d96065df8c1b48f1fee757fc220c Mon Sep 17 00:00:00 2001 From: Michael G Date: Thu, 1 Jun 2023 17:18:28 +0200 Subject: [PATCH 6/9] Filter flags with whitelist --- cmd/launcher/launcher/install.go | 70 +++++++++++++++++++++++++++++--- 1 file changed, 65 insertions(+), 5 deletions(-) diff --git a/cmd/launcher/launcher/install.go b/cmd/launcher/launcher/install.go index 513927b4..e3f88c0e 100644 --- a/cmd/launcher/launcher/install.go +++ b/cmd/launcher/launcher/install.go @@ -1,18 +1,18 @@ package launcher import ( + "github.com/setlog/systemuri" + "github.com/setlog/trivrost/cmd/launcher/flags" + "github.com/setlog/trivrost/cmd/launcher/resources" "github.com/setlog/trivrost/pkg/launcher/config" "os/exec" "path/filepath" "runtime" + "sort" "strings" "sync" "time" - "github.com/setlog/systemuri" - "github.com/setlog/trivrost/cmd/launcher/flags" - "github.com/setlog/trivrost/cmd/launcher/resources" - "github.com/setlog/trivrost/cmd/launcher/places" log "github.com/sirupsen/logrus" @@ -136,7 +136,15 @@ func RegisterSchemeHandlers(launcherFlags *flags.LauncherFlags, schemeHandlers [ // TODO: Create and then always add flag "-skipschemehandlerregistry" (or such) here to prevent -extra-env from being added? // TODO: systemuri does not presently implement %%-escapes according to deployment-config.md. binaryPath := system.GetBinaryPath() - arguments := strings.Join(transmittingFlags, " ") + schemeHandler.Arguments + // We want to pass a few flags from the current execution (transmitting flags) as well, but only if they are not set in the passed arguments. + finalArguments := []string{} + finalArguments = removeFromList(transmittingFlags, extractArguments(schemeHandler.Arguments)) + finalArguments = filterWhitelistArguments(finalArguments) + + transmittingFlagsFiltered := removeFromList(transmittingFlags, finalArguments) + transmittingFlagsFiltered = []string{} // TODO: We actually want to create a whitelist here of flags that are okay to retain + + arguments := strings.Join(transmittingFlagsFiltered, " ") + schemeHandler.Arguments err := systemuri.RegisterURLHandler(resources.LauncherConfig.BrandingName, schemeHandler.Scheme, binaryPath, arguments) if err != nil { log.Warnf("Registering the scheme \"%s\" failed: %v", schemeHandler.Scheme, err) @@ -144,6 +152,58 @@ func RegisterSchemeHandlers(launcherFlags *flags.LauncherFlags, schemeHandlers [ } } +// TODO: Make case insensitive +func filterWhitelistArguments(arguments []string) []string { + // slice of entries to allow in the arguments list + whitelist := []string{ + "debug", + "skipselfupdate", + "roaming", + "deployment-config", + "extra-env", + } + + var filteredArguments []string + + sort.Strings(whitelist) + for _, argument := range arguments { + if found := sort.SearchStrings(whitelist, argument); found < len(whitelist) && whitelist[found] == argument { + continue + } + filteredArguments = append(filteredArguments, argument) + } + + return filteredArguments +} + +// TODO: Make case insensitive +func removeFromList(sourceList []string, itemsToRemove []string) []string { + argSet := make(map[string]bool) + for _, item := range itemsToRemove { + argSet[item] = true + } + + var filteredSourceList []string + for _, item := range sourceList { + if _, ok := argSet[item]; !ok { + filteredSourceList = append(filteredSourceList, item) + } + } + return filteredSourceList +} + +func extractArguments(input string) []string { + words := strings.Fields(input) + var args []string + for _, w := range words { + if strings.HasPrefix(w, "-") || strings.HasPrefix(w, "--") { + arg := strings.SplitN(w, "=", 2)[0] + args = append(args, arg) + } + } + return args +} + func MustRestartWithInstalledBinary(launcherFlags *flags.LauncherFlags) { locking.RestartWithBinary(true, getTargetBinaryPath(), launcherFlags) } From 18f5030f2294cc082814bc013cdca488d52184ea Mon Sep 17 00:00:00 2001 From: Michael G Date: Thu, 1 Jun 2023 19:57:21 +0200 Subject: [PATCH 7/9] Mod tidy --- go.sum | 3 +++ 1 file changed, 3 insertions(+) diff --git a/go.sum b/go.sum index 19273a8b..307b6464 100644 --- a/go.sum +++ b/go.sum @@ -224,6 +224,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/setlog/systemuri v0.0.0-20230601092534-82770c4053ba h1:6vHnyps2j1UyoUISvDCy/jhT4beUlQtHRdyatAKz6WE= +github.com/setlog/systemuri v0.0.0-20230601092534-82770c4053ba/go.mod h1:gq1832MMUy0gN037ydvmttmzlYhqUUPO/sVNrVQ60d4= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= @@ -243,6 +245,7 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tklauser/go-sysconf v0.3.4 h1:HT8SVixZd3IzLdfs/xlpq0jeSfTX57g1v6wB1EuzV7M= From 156c400985e650614805d0e3666ce696570f3d44 Mon Sep 17 00:00:00 2001 From: Michael G Date: Fri, 2 Jun 2023 14:34:57 +0200 Subject: [PATCH 8/9] Update systemrui --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9ff451a4..2bee81cf 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/gofrs/flock v0.8.1 github.com/mattn/go-ieproxy v0.0.1 github.com/prometheus/client_golang v1.15.1 - github.com/setlog/systemuri v0.0.0-20230601092534-82770c4053ba + github.com/setlog/systemuri v0.0.0-20230602115055-b85b65c23a14 github.com/shirou/gopsutil v3.21.11+incompatible github.com/sirupsen/logrus v1.9.0 github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index 307b6464..361986c7 100644 --- a/go.sum +++ b/go.sum @@ -224,8 +224,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/setlog/systemuri v0.0.0-20230601092534-82770c4053ba h1:6vHnyps2j1UyoUISvDCy/jhT4beUlQtHRdyatAKz6WE= -github.com/setlog/systemuri v0.0.0-20230601092534-82770c4053ba/go.mod h1:gq1832MMUy0gN037ydvmttmzlYhqUUPO/sVNrVQ60d4= +github.com/setlog/systemuri v0.0.0-20230602115055-b85b65c23a14 h1:zXGZ+F63oO9+PreP40bNIUxmCNIS7+4XUxxu4kO7p4U= +github.com/setlog/systemuri v0.0.0-20230602115055-b85b65c23a14/go.mod h1:zKnFCdzySDBLqxRKu2vBU9okcVCYrhkiLtobnSkSEGg= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= From 17ec0b30f6041c34184c05a38f87b88aa9cbc367 Mon Sep 17 00:00:00 2001 From: Michael G Date: Mon, 5 Jun 2023 23:11:47 +0200 Subject: [PATCH 9/9] Ignore test-deployment-config --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 097eadef..eb2d2797 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,6 @@ test.json .idea/ *.iml .vscode/ + +# local test deployment-config +deployment-config.json