1
0
mirror of synced 2026-06-10 16:40:47 +00:00

Validate plugin binary path

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
This commit is contained in:
Stefan Prodan
2026-06-04 21:23:56 +03:00
parent d78d406a52
commit 0afcda1a50
4 changed files with 216 additions and 0 deletions
+12
View File
@@ -20,6 +20,8 @@ import (
"fmt"
"io"
"net/http"
"path/filepath"
"strings"
"time"
"github.com/hashicorp/go-retryablehttp"
@@ -83,6 +85,16 @@ func (c *CatalogClient) FetchManifest(name string) (*plugintypes.Manifest, error
return nil, fmt.Errorf("plugin %q has unexpected kind %q (expected %q)", name, manifest.Kind, plugintypes.PluginKind)
}
// Bin becomes the on-disk binary path during install. Require a plain
// flux-prefixed filename: no separators or traversal, matching what the
// discovery layer surfaces.
if manifest.Bin == "" ||
manifest.Bin != filepath.Base(manifest.Bin) ||
!filepath.IsLocal(manifest.Bin) ||
!strings.HasPrefix(manifest.Bin, pluginPrefix) {
return nil, fmt.Errorf("plugin %q has invalid bin %q (must be a plain filename prefixed with %q)", name, manifest.Bin, pluginPrefix)
}
return &manifest, nil
}