plugin: restrict characters in plugin names

Thanks to ⬡-49016 for reporting this issue.

Fixes GHSA-32gq-x56h-299c
This commit is contained in:
Filippo Valsorda
2024-12-18 16:01:18 +01:00
parent cda3988cc7
commit 482cf6fc9b
3 changed files with 45 additions and 0 deletions
+6
View File
@@ -15,6 +15,7 @@ import (
"os"
"path/filepath"
"strconv"
"strings"
"time"
exec "golang.org/x/sys/execabs"
@@ -178,6 +179,9 @@ func NewIdentity(s string, ui *ClientUI) (*Identity, error) {
func NewIdentityWithoutData(name string, ui *ClientUI) (*Identity, error) {
s := EncodeIdentity(name, nil)
if s == "" {
return nil, fmt.Errorf("invalid plugin name: %q", name)
}
return &Identity{
name: name, encoding: s, ui: ui,
}, nil
@@ -390,6 +394,8 @@ func openClientConnection(name, protocol string) (*clientConnection, error) {
path := "age-plugin-" + name
if testOnlyPluginPath != "" {
path = filepath.Join(testOnlyPluginPath, path)
} else if strings.ContainsRune(name, os.PathSeparator) {
return nil, fmt.Errorf("invalid plugin name: %q", name)
}
cmd := exec.Command(path, "--age-plugin="+protocol)