Repository navigation
Commit 9c24b4e
fix(cli): path-escape server names in security subcommands (#1753)
# Pull Request
## Description
`cmd/mcpproxy/security_cmd.go` builds every per-server request as
`"/api/v1/servers/"+serverName+"/…"`. The daemon decodes a `%2F`-encoded
`{id}` on `/api/v1/servers/{id}/*` (MCP-1118), but only if the client
sends one. With an official-registry id like `io.github.owner/repo`, the
raw slash splits the name across path segments and the request lands on
another route.
**Trigger.** `mcpproxy security
scan|status|report|approve|reject|integrity io.github.owner/repo`. Ten
call sites: `/scan`, `/scan/status` (x3), `/scan/files`, `/scan/report`
(x2), `/security/approve`, `/security/reject`, `/integrity`.
All ten now go through one `serverAPIPath(name, suffix)` helper using
`url.PathEscape`, so a new subcommand doesn't add an eleventh raw
concatenation. `security_cmd.go` isn't touched by any open PR.
## Testing
- [x] I have tested these changes locally
- [x] I have added/updated tests that prove my fix is effective or my
feature works
- [x] All existing tests pass
`cmd/mcpproxy/security_cmd_path_escape_test.go`:
- `TestSecurityCmd_EscapesSlashServerName` runs
`fetchFailedScannerInfo`, `printScanSummary` and `printScanDryRunPlan`
against an `httptest` daemon and checks every per-server `EscapedPath()`
carries `io.github.owner%2Frepo`.
- `TestServerAPIPath` covers the helper, including the unchanged
plain-name case.
```
go vet ./cmd/mcpproxy # clean
go test ./cmd/mcpproxy -count=1 # ok
# with the original call sites restored (helper kept so the test compiles):
go test ./cmd/mcpproxy -run TestSecurityCmd_EscapesSlashServerName -count=1
# FAIL: per-server request path "/api/v1/servers/io.github.owner/repo/scan/status" ...
gofmt -l <changed files> # clean
```
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent e9181a1 commit 9c24b4e
2 files changed
Lines changed: 85 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
643 | 644 | | |
644 | 645 | | |
645 | 646 | | |
646 | | - | |
| 647 | + | |
647 | 648 | | |
648 | 649 | | |
649 | 650 | | |
| |||
717 | 718 | | |
718 | 719 | | |
719 | 720 | | |
720 | | - | |
| 721 | + | |
721 | 722 | | |
722 | 723 | | |
723 | 724 | | |
| |||
905 | 906 | | |
906 | 907 | | |
907 | 908 | | |
908 | | - | |
| 909 | + | |
909 | 910 | | |
910 | 911 | | |
911 | 912 | | |
| |||
1389 | 1390 | | |
1390 | 1391 | | |
1391 | 1392 | | |
1392 | | - | |
| 1393 | + | |
1393 | 1394 | | |
1394 | 1395 | | |
1395 | 1396 | | |
| |||
1453 | 1454 | | |
1454 | 1455 | | |
1455 | 1456 | | |
1456 | | - | |
| 1457 | + | |
1457 | 1458 | | |
1458 | 1459 | | |
1459 | 1460 | | |
| |||
1522 | 1523 | | |
1523 | 1524 | | |
1524 | 1525 | | |
1525 | | - | |
| 1526 | + | |
1526 | 1527 | | |
1527 | 1528 | | |
1528 | 1529 | | |
| |||
1581 | 1582 | | |
1582 | 1583 | | |
1583 | 1584 | | |
1584 | | - | |
| 1585 | + | |
1585 | 1586 | | |
1586 | 1587 | | |
1587 | 1588 | | |
| |||
1628 | 1629 | | |
1629 | 1630 | | |
1630 | 1631 | | |
1631 | | - | |
| 1632 | + | |
1632 | 1633 | | |
1633 | 1634 | | |
1634 | 1635 | | |
| |||
1741 | 1742 | | |
1742 | 1743 | | |
1743 | 1744 | | |
1744 | | - | |
| 1745 | + | |
1745 | 1746 | | |
1746 | 1747 | | |
1747 | 1748 | | |
| |||
1815 | 1816 | | |
1816 | 1817 | | |
1817 | 1818 | | |
1818 | | - | |
| 1819 | + | |
1819 | 1820 | | |
1820 | 1821 | | |
1821 | 1822 | | |
| |||
2973 | 2974 | | |
2974 | 2975 | | |
2975 | 2976 | | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
| 2980 | + | |
| 2981 | + | |
| 2982 | + | |
| 2983 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
0 commit comments