pico

created pr with 112.1 on 2026-02-24T22:19:31Z · by c8ef7d19
added 112.2 on 2026-02-25T01:29:54Z · by c8ef7d19
1: 92facd1 = 1: 92facd1 chore: added test for pssh cmd parsing
-: ------- > 2: 1acc4d5 fix: properly parse ssh command args with quotes
cmds
checkout latest patchset:
ssh pr.pico.sh print 112 | git am -3
checkout any patchset in a patch request:
ssh pr.pico.sh print 112.[rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 112
+1 -0 go.mod #
......@@ -32,6 +32,7 @@ require (
3232 github.com/emersion/go-sasl v0.0.0-20241020182733-b788ff22d5a6
3333 github.com/emersion/go-smtp v0.24.0
3434 github.com/gkampitakis/go-snaps v0.5.15
35+ github.com/go-andiamo/splitter v1.2.5
3536 github.com/google/go-cmp v0.7.0
3637 github.com/google/renameio/v2 v2.0.2
3738 github.com/google/uuid v1.6.0
+2 -0 go.sum #
......@@ -329,6 +329,8 @@ github.com/gkampitakis/go-diff v1.3.2/go.mod h1:LLgOrpqleQe26cte8s36HTWcTmMEur6O
329329 github.com/gkampitakis/go-snaps v0.5.15 h1:amyJrvM1D33cPHwVrjo9jQxX8g/7E2wYdZ+01KS3zGE=
330330 github.com/gkampitakis/go-snaps v0.5.15/go.mod h1:HNpx/9GoKisdhw9AFOBT1N7DBs9DiHo/hGheFGBZ+mc=
331331 github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
332+github.com/go-andiamo/splitter v1.2.5 h1:P3NovWMY2V14TJJSolXBvlOmGSZo3Uz+LtTl2bsV/eY=
333+github.com/go-andiamo/splitter v1.2.5/go.mod h1:8WHU24t9hcMKU5FXDQb1hysSEC/GPuivIp0uKY1J8gw=
332334 github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
333335 github.com/go-errors/errors v1.0.2/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs=
334336 github.com/go-errors/errors v1.1.1/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs=
+8 -3 pkg/pssh/server.go #
......@@ -15,12 +15,12 @@ import (
1515 "net/http"
1616 "os"
1717 "path"
18- "strings"
1918 "sync"
2019 "time"
2120 "unicode/utf8"
2221
2322 "github.com/antoniomika/syncmap"
23+ "github.com/go-andiamo/splitter"
2424 "github.com/prometheus/client_golang/prometheus"
2525 "github.com/prometheus/client_golang/prometheus/promauto"
2626 "github.com/prometheus/client_golang/prometheus/promhttp"
......@@ -531,9 +531,14 @@ func NewSSHServer(ctx context.Context, logger *slog.Logger, config *SSHServerCon
531531 return
532532 }
533533
534+ commaSplitter, _ := splitter.NewSplitter(
535+ ' ',
536+ splitter.DoubleQuotes,
537+ splitter.SingleQuotes,
538+ )
534539 command = payload.Value
535-
536- sesh.SetValue("command", strings.Fields(payload.Value))
540+ cmdSlice, _ := commaSplitter.Split(command)
541+ sesh.SetValue("command", cmdSlice)
537542 }
538543
539544 if !utf8.ValidString(command) {
+2 -2 pkg/pssh/server_test.go #
......@@ -325,9 +325,9 @@ func TestSSHServerCommandParsing(t *testing.T) {
325325 time.Sleep(100 * time.Millisecond)
326326
327327 // Send command to server
328- user.MustCmd(nil, "accept --comment 'here we go' 101")
328+ _, _ = user.Cmd(nil, "accept --comment 'here we go' 101")
329329
330- time.Sleep(1000 * time.Millisecond)
330+ time.Sleep(100 * time.Millisecond)
331331
332332 expectedCommand := []string{"accept", "--comment", "'here we go'", "101"}
333333 if !slices.Equal(expectedCommand, capturedCommand) {
Back to top