pico
created pr with
112.1
added 112.2
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 -3checkout any patchset in a patch request:
ssh pr.pico.sh print 112.[rev] | git am -3add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 112
Patchset
112.2
fix: properly parse ssh command args with quotes
Eric Bower
2026-02-25T01:23:21ZSemantic diff summary
0 added,
3 modified,
0 signature changed,
0 removed
across 2 analyzed files
(2 files skipped: unsupported file type)
+1
-0
go.mod
#
| ... | ... | @@ -32,6 +32,7 @@ require ( | |
| 32 | 32 | github.com/emersion/go-sasl v0.0.0-20241020182733-b788ff22d5a6 | |
| 33 | 33 | github.com/emersion/go-smtp v0.24.0 | |
| 34 | 34 | github.com/gkampitakis/go-snaps v0.5.15 | |
| 35 | + | github.com/go-andiamo/splitter v1.2.5 | |
| 35 | 36 | github.com/google/go-cmp v0.7.0 | |
| 36 | 37 | github.com/google/renameio/v2 v2.0.2 | |
| 37 | 38 | 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 | |
| 329 | 329 | github.com/gkampitakis/go-snaps v0.5.15 h1:amyJrvM1D33cPHwVrjo9jQxX8g/7E2wYdZ+01KS3zGE= | |
| 330 | 330 | github.com/gkampitakis/go-snaps v0.5.15/go.mod h1:HNpx/9GoKisdhw9AFOBT1N7DBs9DiHo/hGheFGBZ+mc= | |
| 331 | 331 | 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= | |
| 332 | 334 | github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= | |
| 333 | 335 | github.com/go-errors/errors v1.0.2/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs= | |
| 334 | 336 | github.com/go-errors/errors v1.1.1/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs= |
+8
-3
pkg/pssh/server.go
#
| ... | ... | @@ -15,12 +15,12 @@ import ( | |
| 15 | 15 | "net/http" | |
| 16 | 16 | "os" | |
| 17 | 17 | "path" | |
| 18 | - | "strings" | |
| 19 | 18 | "sync" | |
| 20 | 19 | "time" | |
| 21 | 20 | "unicode/utf8" | |
| 22 | 21 | ||
| 23 | 22 | "github.com/antoniomika/syncmap" | |
| 23 | + | "github.com/go-andiamo/splitter" | |
| 24 | 24 | "github.com/prometheus/client_golang/prometheus" | |
| 25 | 25 | "github.com/prometheus/client_golang/prometheus/promauto" | |
| 26 | 26 | "github.com/prometheus/client_golang/prometheus/promhttp" |
| ... | ... | @@ -531,9 +531,14 @@ func NewSSHServer(ctx context.Context, logger *slog.Logger, config *SSHServerCon | |
| 531 | 531 | return | |
| 532 | 532 | } | |
| 533 | 533 | ||
| 534 | + | commaSplitter, _ := splitter.NewSplitter( | |
| 535 | + | ' ', | |
| 536 | + | splitter.DoubleQuotes, | |
| 537 | + | splitter.SingleQuotes, | |
| 538 | + | ) | |
| 534 | 539 | command = payload.Value | |
| 535 | - | ||
| 536 | - | sesh.SetValue("command", strings.Fields(payload.Value)) | |
| 540 | + | cmdSlice, _ := commaSplitter.Split(command) | |
| 541 | + | sesh.SetValue("command", cmdSlice) | |
| 537 | 542 | } | |
| 538 | 543 | ||
| 539 | 544 | if !utf8.ValidString(command) { |
+2
-2
pkg/pssh/server_test.go
#
| ... | ... | @@ -325,9 +325,9 @@ func TestSSHServerCommandParsing(t *testing.T) { | |
| 325 | 325 | time.Sleep(100 * time.Millisecond) | |
| 326 | 326 | ||
| 327 | 327 | // Send command to server | |
| 328 | - | user.MustCmd(nil, "accept --comment 'here we go' 101") | |
| 328 | + | _, _ = user.Cmd(nil, "accept --comment 'here we go' 101") | |
| 329 | 329 | ||
| 330 | - | time.Sleep(1000 * time.Millisecond) | |
| 330 | + | time.Sleep(100 * time.Millisecond) | |
| 331 | 331 | ||
| 332 | 332 | expectedCommand := []string{"accept", "--comment", "'here we go'", "101"} | |
| 333 | 333 | if !slices.Equal(expectedCommand, capturedCommand) { |