repos / pico

pico services mono repo
git clone https://github.com/picosh/pico.git

commit
1acc4d5
parent
92facd1
author
Eric Bower
date
2026-02-24 20:23:21 -0500 EST
fix: properly parse ssh command args with quotes
4 files changed,  +13, -5
M go.mod
M go.sum
M go.mod
+1, -0
1@@ -32,6 +32,7 @@ require (
2 	github.com/emersion/go-sasl v0.0.0-20241020182733-b788ff22d5a6
3 	github.com/emersion/go-smtp v0.24.0
4 	github.com/gkampitakis/go-snaps v0.5.15
5+	github.com/go-andiamo/splitter v1.2.5
6 	github.com/google/go-cmp v0.7.0
7 	github.com/google/renameio/v2 v2.0.2
8 	github.com/google/uuid v1.6.0
M go.sum
+2, -0
1@@ -329,6 +329,8 @@ github.com/gkampitakis/go-diff v1.3.2/go.mod h1:LLgOrpqleQe26cte8s36HTWcTmMEur6O
2 github.com/gkampitakis/go-snaps v0.5.15 h1:amyJrvM1D33cPHwVrjo9jQxX8g/7E2wYdZ+01KS3zGE=
3 github.com/gkampitakis/go-snaps v0.5.15/go.mod h1:HNpx/9GoKisdhw9AFOBT1N7DBs9DiHo/hGheFGBZ+mc=
4 github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
5+github.com/go-andiamo/splitter v1.2.5 h1:P3NovWMY2V14TJJSolXBvlOmGSZo3Uz+LtTl2bsV/eY=
6+github.com/go-andiamo/splitter v1.2.5/go.mod h1:8WHU24t9hcMKU5FXDQb1hysSEC/GPuivIp0uKY1J8gw=
7 github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
8 github.com/go-errors/errors v1.0.2/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs=
9 github.com/go-errors/errors v1.1.1/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs=
M pkg/pssh/server.go
+8, -3
 1@@ -15,12 +15,12 @@ import (
 2 	"net/http"
 3 	"os"
 4 	"path"
 5-	"strings"
 6 	"sync"
 7 	"time"
 8 	"unicode/utf8"
 9 
10 	"github.com/antoniomika/syncmap"
11+	"github.com/go-andiamo/splitter"
12 	"github.com/prometheus/client_golang/prometheus"
13 	"github.com/prometheus/client_golang/prometheus/promauto"
14 	"github.com/prometheus/client_golang/prometheus/promhttp"
15@@ -531,9 +531,14 @@ func NewSSHServer(ctx context.Context, logger *slog.Logger, config *SSHServerCon
16 									return
17 								}
18 
19+								commaSplitter, _ := splitter.NewSplitter(
20+									' ',
21+									splitter.DoubleQuotes,
22+									splitter.SingleQuotes,
23+								)
24 								command = payload.Value
25-
26-								sesh.SetValue("command", strings.Fields(payload.Value))
27+								cmdSlice, _ := commaSplitter.Split(command)
28+								sesh.SetValue("command", cmdSlice)
29 							}
30 
31 							if !utf8.ValidString(command) {
M pkg/pssh/server_test.go
+2, -2
 1@@ -325,9 +325,9 @@ func TestSSHServerCommandParsing(t *testing.T) {
 2 	time.Sleep(100 * time.Millisecond)
 3 
 4 	// Send command to server
 5-	user.MustCmd(nil, "accept --comment 'here we go' 101")
 6+	_, _ = user.Cmd(nil, "accept --comment 'here we go' 101")
 7 
 8-	time.Sleep(1000 * time.Millisecond)
 9+	time.Sleep(100 * time.Millisecond)
10 
11 	expectedCommand := []string{"accept", "--comment", "'here we go'", "101"}
12 	if !slices.Equal(expectedCommand, capturedCommand) {