mirror of
https://github.com/FiloSottile/age.git
synced 2026-09-19 14:34:21 +00:00
plugin: restrict characters in plugin names
Thanks to ⬡-49016 for reporting this issue. Fixes GHSA-32gq-x56h-299c
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user