[MM-50748] Fix "Missing plugin executable should fail with explicit error" (#22398)

* short-circuit plugin activation steps if executable is not found

* improve error message by removing redundant ref to plugin and mor consise language about server environment
Этот коммит содержится в:
Michael Kochell
2023-03-10 10:05:52 -05:00
коммит произвёл GitHub
родитель 0a001b9c03
Коммит 6a9c4ad56b

Просмотреть файл

@@ -59,9 +59,13 @@ func newSupervisor(pluginInfo *model.BundleInfo, apiImpl API, driver Driver, par
".",
pluginInfo.Manifest.GetExecutableForRuntime(runtime.GOOS, runtime.GOARCH),
))
if executable == "" {
return nil, fmt.Errorf("backend executable not found for environment %s/%s", runtime.GOOS, runtime.GOARCH)
}
if strings.HasPrefix(executable, "..") {
return nil, fmt.Errorf("invalid backend executable")
}
executable = filepath.Join(pluginInfo.Path, executable)
cmd := exec.Command(executable)
@@ -71,7 +75,7 @@ func newSupervisor(pluginInfo *model.BundleInfo, apiImpl API, driver Driver, par
// https://mattermost.atlassian.net/browse/MM-49167
pluginChecksum, err := getPluginExecutableChecksum(executable)
if err != nil {
return nil, errors.Wrapf(err, "unable to generate a checksum for the plugin %s", pluginInfo.Path)
return nil, errors.Wrapf(err, "unable to generate plugin checksum")
}
sup.client = plugin.NewClient(&plugin.ClientConfig{