@johnhenry/wsh 0.48.0 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -30
- package/package.json +17 -3
- package/spec/capabilities.md +174 -0
- package/spec/capabilities.vectors.json +200 -0
- package/spec/key-options.vectors.json +248 -0
- package/spec/message-matrix.md +259 -0
- package/spec/wsh-v1.md +1607 -0
- package/spec/wsh-v1.yaml +2775 -0
- package/src/auth.mjs +3 -34
- package/src/capabilities.d.ts +53 -0
- package/src/capabilities.mjs +69 -0
- package/src/gateway-errors.mjs +45 -0
- package/src/identity.d.ts +61 -0
- package/src/identity.mjs +194 -0
- package/src/index.d.ts +11 -0
- package/src/index.mjs +1 -0
- package/src/key-names.mjs +115 -0
- package/src/key-options.mjs +2 -0
- package/src/mcp-duplex.mjs +184 -0
- package/src/memory-host.d.ts +5 -0
- package/src/memory-host.mjs +3 -2
- package/src/objects-core.mjs +31 -8
- package/src/objects.d.ts +18 -5
- package/src/objects.mjs +4 -1
- package/src/page-host.d.ts +46 -2
- package/src/page-host.mjs +10 -2
- package/src/server/connection.mjs +4 -1
- package/src/server/gateway-core.mjs +4 -4
- package/src/testing-doubles.mjs +115 -0
- package/src/testing.d.ts +44 -0
- package/src/testing.mjs +3 -0
- package/src/transport.mjs +1 -1
- package/src/webmcp.mjs +8 -4
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"description": "Shared test vectors for the notation of key capabilities (spec/capabilities.md): does a holder of capability list L permit request R. Run by test/capabilities.test.mjs (the JS evaluation, `permits` of @johnhenry/wsh/capabilities, and the full key check of key-options.mjs) and by the unit test in crates/wsh-server/src/auth/permissions.rs (the Rust server). Another implementation runs the cases that name its host class in `hosts` (default: every class). Add a case here, never to one suite only.",
|
|
4
|
+
"spec": "spec/capabilities.md",
|
|
5
|
+
"hostClasses": {
|
|
6
|
+
"node": "the JS implementation: @johnhenry/wsh/server, the memory host, the page host",
|
|
7
|
+
"rust": "the Rust wsh-server: no named endpoints, no execution targets, no wsh-objects; a key line with an objects: entry is refused at load (unknown-capability)"
|
|
8
|
+
},
|
|
9
|
+
"lists": [
|
|
10
|
+
{ "name": "no capabilities at all is a valid, empty list", "capabilities": [], "result": "ok" },
|
|
11
|
+
{ "name": "every simple capability", "capabilities": ["exec", "pty", "relay", "fs:read", "fs:write"], "result": "ok" },
|
|
12
|
+
{ "name": "gateway forms", "capabilities": ["gateway:tcp:db.internal:5432", "gateway:udp:*:53", "gateway:listen:tcp:8080", "gateway:tcp:*.example.com:*", "gateway:tcp:[::1]:80"], "result": "ok" },
|
|
13
|
+
{ "name": "unix forms", "capabilities": ["unix:/run/app.sock", "unix:/srv/*", "unix:listen:/run/x.sock", "unix:/*"], "result": "ok" },
|
|
14
|
+
{ "name": "named forms, with the wildcard where it is allowed", "capabilities": ["endpoint:logs", "endpoint:*", "target:web", "target:*", "mcp:search", "mcp:*", "rpc:my-proto"], "result": "ok" },
|
|
15
|
+
{ "name": "an objects: entry is served by the JS host and refused at load by the Rust server", "capabilities": ["objects:window"], "result": "ok", "hosts": ["node"] },
|
|
16
|
+
{ "name": "objects: root, operation and wildcard forms", "capabilities": ["objects:window", "objects:window:get", "objects:*:call", "objects:store:set", "objects:store:on"], "result": "ok", "hosts": ["node"] },
|
|
17
|
+
{ "name": "an objects: entry on the Rust server (its stated subset)", "capabilities": ["objects:window"], "result": "refused", "code": "unknown-capability", "hosts": ["rust"] },
|
|
18
|
+
|
|
19
|
+
{ "name": "an unknown capability fails the whole list, whatever else it holds", "capabilities": ["exec", "teleport"], "result": "refused", "code": "unknown-capability" },
|
|
20
|
+
{ "name": "capabilities are case sensitive", "capabilities": ["EXEC"], "result": "refused", "code": "unknown-capability" },
|
|
21
|
+
{ "name": "gateway with a protocol this notation does not have", "capabilities": ["gateway:icmp:*:*"], "result": "refused", "code": "unknown-capability" },
|
|
22
|
+
{ "name": "gateway: no wildcard of the kind", "capabilities": ["gateway:*"], "result": "refused", "code": "unknown-capability" },
|
|
23
|
+
{ "name": "an empty entry", "capabilities": ["exec", ""], "result": "refused", "code": "bad-capability" },
|
|
24
|
+
{ "name": "whitespace in an entry", "capabilities": ["exec pty"], "result": "refused", "code": "bad-capability" },
|
|
25
|
+
{ "name": "gateway: a host with no port", "capabilities": ["gateway:tcp:db.internal"], "result": "refused", "code": "bad-capability" },
|
|
26
|
+
{ "name": "gateway: port 0", "capabilities": ["gateway:tcp:db.internal:0"], "result": "refused", "code": "bad-capability" },
|
|
27
|
+
{ "name": "gateway: port above 65535", "capabilities": ["gateway:tcp:db.internal:65536"], "result": "refused", "code": "bad-capability" },
|
|
28
|
+
{ "name": "gateway: a port with a leading zero", "capabilities": ["gateway:tcp:db.internal:080"], "result": "refused", "code": "bad-capability" },
|
|
29
|
+
{ "name": "gateway: a wildcard in the middle of a host", "capabilities": ["gateway:tcp:a*.example.com:443"], "result": "refused", "code": "bad-capability" },
|
|
30
|
+
{ "name": "gateway: a wildcard that is not a whole leading label", "capabilities": ["gateway:tcp:*example.com:443"], "result": "refused", "code": "bad-capability" },
|
|
31
|
+
{ "name": "gateway: listen takes a port, not a host", "capabilities": ["gateway:listen:tcp:localhost:80"], "result": "refused", "code": "bad-capability" },
|
|
32
|
+
{ "name": "unix: a relative path", "capabilities": ["unix:srv/a.sock"], "result": "refused", "code": "bad-capability" },
|
|
33
|
+
{ "name": "unix: a .. segment", "capabilities": ["unix:/srv/../etc/x.sock"], "result": "refused", "code": "bad-capability" },
|
|
34
|
+
{ "name": "unix: a wildcard that is not the last segment", "capabilities": ["unix:/srv/*/x.sock"], "result": "refused", "code": "bad-capability" },
|
|
35
|
+
{ "name": "mcp: with no tool", "capabilities": ["mcp:"], "result": "refused", "code": "bad-capability" },
|
|
36
|
+
{ "name": "rpc: has no wildcard form", "capabilities": ["rpc:*"], "result": "refused", "code": "bad-capability" },
|
|
37
|
+
{ "name": "endpoint: a name that does not start with a letter or digit", "capabilities": ["endpoint:-x"], "result": "refused", "code": "bad-capability" },
|
|
38
|
+
{ "name": "objects: with no root", "capabilities": ["objects:"], "result": "refused", "code": "bad-capability", "hosts": ["node"] },
|
|
39
|
+
{ "name": "objects: an operation that does not exist", "capabilities": ["objects:window:fly"], "result": "refused", "code": "bad-capability", "hosts": ["node"] },
|
|
40
|
+
{ "name": "objects: a path is not a root", "capabilities": ["objects:window.document"], "result": "refused", "code": "bad-capability", "hosts": ["node"] },
|
|
41
|
+
{ "name": "objects: more than a root and an operation", "capabilities": ["objects:window:get:x"], "result": "refused", "code": "bad-capability", "hosts": ["node"] },
|
|
42
|
+
{ "name": "objects: a malformed entry on the Rust server is refused as unknown", "capabilities": ["objects:window:fly"], "result": "refused", "code": "unknown-capability", "hosts": ["rust"] }
|
|
43
|
+
],
|
|
44
|
+
"requests": [
|
|
45
|
+
{ "name": "exec: exec", "capabilities": ["exec"], "request": { "kind": "open", "channel": "exec" }, "permitted": true },
|
|
46
|
+
{ "name": "exec does not give a pty", "capabilities": ["exec"], "request": { "kind": "open", "channel": "pty" }, "permitted": false, "capability": "pty" },
|
|
47
|
+
{ "name": "pty does not give exec", "capabilities": ["pty"], "request": { "kind": "open", "channel": "exec" }, "permitted": false, "capability": "exec" },
|
|
48
|
+
{ "name": "an empty list permits nothing: exec", "capabilities": [], "request": { "kind": "open", "channel": "exec" }, "permitted": false, "capability": "exec" },
|
|
49
|
+
{ "name": "an empty list permits nothing: relay", "capabilities": [], "request": { "kind": "relay" }, "permitted": false, "capability": "relay" },
|
|
50
|
+
{ "name": "an empty list permits nothing: a file op", "capabilities": [], "request": { "kind": "file-op", "op": "list" }, "permitted": false, "capability": "fs:read" },
|
|
51
|
+
{ "name": "an empty list permits nothing: tcp", "capabilities": [], "request": { "kind": "tcp", "host": "example.com", "port": 443 }, "permitted": false, "capability": "gateway:tcp:example.com:443" },
|
|
52
|
+
{ "name": "an unknown entry permits nothing, not even what the other entries name", "capabilities": ["exec", "teleport"], "request": { "kind": "open", "channel": "exec" }, "permitted": false, "invalidList": true },
|
|
53
|
+
{ "name": "relay", "capabilities": ["relay"], "request": { "kind": "relay" }, "permitted": true },
|
|
54
|
+
{ "name": "relay is not granted by exec", "capabilities": ["exec"], "request": { "kind": "relay" }, "permitted": false, "capability": "relay" },
|
|
55
|
+
{ "name": "a key with a list may never install a key", "capabilities": ["exec", "pty", "relay", "fs:read", "fs:write", "mcp:*"], "request": { "kind": "key-admin" }, "permitted": false, "code": "key-admin-not-permitted" },
|
|
56
|
+
|
|
57
|
+
{ "name": "fs:read: a download", "capabilities": ["fs:read"], "request": { "kind": "open", "channel": "file", "direction": "download" }, "permitted": true },
|
|
58
|
+
{ "name": "fs:read: an upload", "capabilities": ["fs:read"], "request": { "kind": "open", "channel": "file", "direction": "upload" }, "permitted": false, "capability": "fs:write" },
|
|
59
|
+
{ "name": "fs:write: an upload", "capabilities": ["fs:write"], "request": { "kind": "open", "channel": "file", "direction": "upload" }, "permitted": true },
|
|
60
|
+
{ "name": "fs:write does not read", "capabilities": ["fs:write"], "request": { "kind": "open", "channel": "file", "direction": "download" }, "permitted": false, "capability": "fs:read" },
|
|
61
|
+
{ "name": "fs:read: list", "capabilities": ["fs:read"], "request": { "kind": "file-op", "op": "list" }, "permitted": true },
|
|
62
|
+
{ "name": "fs:read: stat", "capabilities": ["fs:read"], "request": { "kind": "file-op", "op": "stat" }, "permitted": true },
|
|
63
|
+
{ "name": "fs:read: read", "capabilities": ["fs:read"], "request": { "kind": "file-op", "op": "read" }, "permitted": true },
|
|
64
|
+
{ "name": "fs:read: write", "capabilities": ["fs:read"], "request": { "kind": "file-op", "op": "write" }, "permitted": false, "capability": "fs:write" },
|
|
65
|
+
{ "name": "fs:read: mkdir", "capabilities": ["fs:read"], "request": { "kind": "file-op", "op": "mkdir" }, "permitted": false, "capability": "fs:write" },
|
|
66
|
+
{ "name": "fs:read: remove", "capabilities": ["fs:read"], "request": { "kind": "file-op", "op": "remove" }, "permitted": false, "capability": "fs:write" },
|
|
67
|
+
{ "name": "fs:read: rename", "capabilities": ["fs:read"], "request": { "kind": "file-op", "op": "rename" }, "permitted": false, "capability": "fs:write" },
|
|
68
|
+
{ "name": "an operation nobody knows needs fs:write", "capabilities": ["fs:read"], "request": { "kind": "file-op", "op": "chmod" }, "permitted": false, "capability": "fs:write" },
|
|
69
|
+
{ "name": "fs:write: write", "capabilities": ["fs:write"], "request": { "kind": "file-op", "op": "write" }, "permitted": true },
|
|
70
|
+
{ "name": "fs:write: list", "capabilities": ["fs:write"], "request": { "kind": "file-op", "op": "list" }, "permitted": false, "capability": "fs:read" },
|
|
71
|
+
{ "name": "wsh-fs needs fs:read and fs:write both", "capabilities": ["fs:read"], "request": { "kind": "open", "channel": "rpc", "protocol": "wsh-fs" }, "permitted": false, "capability": "fs:write" },
|
|
72
|
+
{ "name": "wsh-fs with both", "capabilities": ["fs:read", "fs:write"], "request": { "kind": "open", "channel": "rpc", "protocol": "wsh-fs" }, "permitted": true },
|
|
73
|
+
|
|
74
|
+
{ "name": "mcp:echo: call echo", "capabilities": ["mcp:echo"], "request": { "kind": "mcp-call", "tool": "echo" }, "permitted": true },
|
|
75
|
+
{ "name": "mcp:echo: call another tool", "capabilities": ["mcp:echo"], "request": { "kind": "mcp-call", "tool": "shell" }, "permitted": false, "capability": "mcp:shell" },
|
|
76
|
+
{ "name": "mcp:echo: list echo", "capabilities": ["mcp:echo"], "request": { "kind": "mcp-tool", "tool": "echo" }, "permitted": true },
|
|
77
|
+
{ "name": "mcp:echo: another tool is not listed", "capabilities": ["mcp:echo"], "request": { "kind": "mcp-tool", "tool": "shell" }, "permitted": false, "capability": "mcp:shell" },
|
|
78
|
+
{ "name": "mcp tool names are case sensitive", "capabilities": ["mcp:echo"], "request": { "kind": "mcp-call", "tool": "Echo" }, "permitted": false, "capability": "mcp:Echo" },
|
|
79
|
+
{ "name": "mcp:*: any tool", "capabilities": ["mcp:*"], "request": { "kind": "mcp-call", "tool": "shell" }, "permitted": true },
|
|
80
|
+
{ "name": "mcp discovery needs some mcp entry", "capabilities": ["exec"], "request": { "kind": "mcp" }, "permitted": false, "capability": "mcp:*" },
|
|
81
|
+
{ "name": "mcp discovery with one tool", "capabilities": ["mcp:echo"], "request": { "kind": "mcp" }, "permitted": true },
|
|
82
|
+
{ "name": "the mcp rpc channel needs mcp:*", "capabilities": ["mcp:echo"], "request": { "kind": "open", "channel": "rpc", "protocol": "mcp" }, "permitted": false, "capability": "mcp:*" },
|
|
83
|
+
{ "name": "the mcp rpc channel with mcp:*", "capabilities": ["mcp:*"], "request": { "kind": "open", "channel": "rpc", "protocol": "mcp" }, "permitted": true },
|
|
84
|
+
{ "name": "the mcp rpc channel of a handler that narrows by tool is open to a key that names a tool", "capabilities": ["mcp:echo"], "request": { "kind": "open", "channel": "rpc", "protocol": "mcp", "scoped": true }, "permitted": true, "hosts": ["node"] },
|
|
85
|
+
{ "name": "a handler that narrows by tool is not open to a key with no mcp entry", "capabilities": ["exec"], "request": { "kind": "open", "channel": "rpc", "protocol": "mcp", "scoped": true }, "permitted": false, "capability": "mcp:<tool>", "hosts": ["node"] },
|
|
86
|
+
|
|
87
|
+
{ "name": "rpc:NAME opens that protocol", "capabilities": ["rpc:my-proto"], "request": { "kind": "open", "channel": "rpc", "protocol": "my-proto" }, "permitted": true },
|
|
88
|
+
{ "name": "rpc:NAME is exact", "capabilities": ["rpc:my-proto"], "request": { "kind": "open", "channel": "rpc", "protocol": "my-proto2" }, "permitted": false, "capability": "rpc:my-proto2" },
|
|
89
|
+
{ "name": "rpc: another protocol", "capabilities": ["rpc:my-proto"], "request": { "kind": "open", "channel": "rpc", "protocol": "other" }, "permitted": false, "capability": "rpc:other" },
|
|
90
|
+
{ "name": "rpc: wsh-host needs rpc:wsh-host", "capabilities": ["exec"], "request": { "kind": "open", "channel": "rpc", "protocol": "wsh-host" }, "permitted": false, "capability": "rpc:wsh-host" },
|
|
91
|
+
{ "name": "rpc: wsh-host with it", "capabilities": ["rpc:wsh-host"], "request": { "kind": "open", "channel": "rpc", "protocol": "wsh-host" }, "permitted": true },
|
|
92
|
+
|
|
93
|
+
{ "name": "tcp: exact host and port", "capabilities": ["gateway:tcp:db.internal:5432"], "request": { "kind": "tcp", "host": "db.internal", "port": 5432 }, "permitted": true },
|
|
94
|
+
{ "name": "tcp: the host is case insensitive", "capabilities": ["gateway:tcp:db.internal:5432"], "request": { "kind": "tcp", "host": "DB.Internal", "port": 5432 }, "permitted": true },
|
|
95
|
+
{ "name": "tcp: the pattern's case does not matter either", "capabilities": ["gateway:tcp:DB.Internal:5432"], "request": { "kind": "tcp", "host": "db.internal", "port": 5432 }, "permitted": true },
|
|
96
|
+
{ "name": "tcp: another port", "capabilities": ["gateway:tcp:db.internal:5432"], "request": { "kind": "tcp", "host": "db.internal", "port": 22 }, "permitted": false, "capability": "gateway:tcp:db.internal:22" },
|
|
97
|
+
{ "name": "tcp: a host that merely starts like it", "capabilities": ["gateway:tcp:db.internal:5432"], "request": { "kind": "tcp", "host": "db.internal.evil.com", "port": 5432 }, "permitted": false, "capability": "gateway:tcp:db.internal.evil.com:5432" },
|
|
98
|
+
{ "name": "tcp: a suffix pattern matches a subdomain", "capabilities": ["gateway:tcp:*.example.com:443"], "request": { "kind": "tcp", "host": "api.example.com", "port": 443 }, "permitted": true },
|
|
99
|
+
{ "name": "tcp: a suffix pattern matches a deeper subdomain", "capabilities": ["gateway:tcp:*.example.com:443"], "request": { "kind": "tcp", "host": "a.b.example.com", "port": 443 }, "permitted": true },
|
|
100
|
+
{ "name": "tcp: a suffix pattern does not match the apex", "capabilities": ["gateway:tcp:*.example.com:443"], "request": { "kind": "tcp", "host": "example.com", "port": 443 }, "permitted": false, "capability": "gateway:tcp:example.com:443" },
|
|
101
|
+
{ "name": "tcp: a suffix pattern does not match a look-alike", "capabilities": ["gateway:tcp:*.example.com:443"], "request": { "kind": "tcp", "host": "evilexample.com", "port": 443 }, "permitted": false, "capability": "gateway:tcp:evilexample.com:443" },
|
|
102
|
+
{ "name": "tcp: a suffix pattern does not match a host that only contains it", "capabilities": ["gateway:tcp:*.example.com:443"], "request": { "kind": "tcp", "host": "api.example.com.evil.net", "port": 443 }, "permitted": false, "capability": "gateway:tcp:api.example.com.evil.net:443" },
|
|
103
|
+
{ "name": "tcp: a suffix pattern is case insensitive", "capabilities": ["gateway:tcp:*.example.com:443"], "request": { "kind": "tcp", "host": "API.Example.COM", "port": 443 }, "permitted": true },
|
|
104
|
+
{ "name": "tcp: any port", "capabilities": ["gateway:tcp:db.internal:*"], "request": { "kind": "tcp", "host": "db.internal", "port": 1 }, "permitted": true },
|
|
105
|
+
{ "name": "tcp: any host, one port", "capabilities": ["gateway:tcp:*:443"], "request": { "kind": "tcp", "host": "1.2.3.4", "port": 443 }, "permitted": true },
|
|
106
|
+
{ "name": "tcp: any host, one port, another port", "capabilities": ["gateway:tcp:*:443"], "request": { "kind": "tcp", "host": "1.2.3.4", "port": 80 }, "permitted": false, "capability": "gateway:tcp:1.2.3.4:80" },
|
|
107
|
+
{ "name": "tcp: any host and port", "capabilities": ["gateway:tcp:*:*"], "request": { "kind": "tcp", "host": "anything.example", "port": 9 }, "permitted": true },
|
|
108
|
+
{ "name": "tcp: an IPv6 literal", "capabilities": ["gateway:tcp:[::1]:8080"], "request": { "kind": "tcp", "host": "::1", "port": 8080 }, "permitted": true },
|
|
109
|
+
{ "name": "tcp: another IPv6 literal", "capabilities": ["gateway:tcp:[::1]:8080"], "request": { "kind": "tcp", "host": "::2", "port": 8080 }, "permitted": false, "capability": "gateway:tcp:::2:8080" },
|
|
110
|
+
{ "name": "tcp: a second entry is enough", "capabilities": ["gateway:tcp:a.example:1", "gateway:tcp:b.example:2"], "request": { "kind": "tcp", "host": "b.example", "port": 2 }, "permitted": true },
|
|
111
|
+
{ "name": "tcp: the host of one entry with the port of another", "capabilities": ["gateway:tcp:a.example:1", "gateway:tcp:b.example:2"], "request": { "kind": "tcp", "host": "a.example", "port": 2 }, "permitted": false, "capability": "gateway:tcp:a.example:2" },
|
|
112
|
+
{ "name": "tcp does not give udp", "capabilities": ["gateway:tcp:*:*"], "request": { "kind": "udp", "host": "1.1.1.1", "port": 53 }, "permitted": false, "capability": "gateway:udp:1.1.1.1:53" },
|
|
113
|
+
{ "name": "udp: granted", "capabilities": ["gateway:udp:*:53"], "request": { "kind": "udp", "host": "1.1.1.1", "port": 53 }, "permitted": true },
|
|
114
|
+
{ "name": "udp: another port", "capabilities": ["gateway:udp:*:53"], "request": { "kind": "udp", "host": "1.1.1.1", "port": 123 }, "permitted": false, "capability": "gateway:udp:1.1.1.1:123" },
|
|
115
|
+
{ "name": "udp does not give tcp", "capabilities": ["gateway:udp:*:*"], "request": { "kind": "tcp", "host": "1.1.1.1", "port": 53 }, "permitted": false, "capability": "gateway:tcp:1.1.1.1:53" },
|
|
116
|
+
{ "name": "dns: a name the key may connect to", "capabilities": ["gateway:tcp:db.internal:5432"], "request": { "kind": "dns", "name": "db.internal" }, "permitted": true },
|
|
117
|
+
{ "name": "dns: a name it may not", "capabilities": ["gateway:tcp:db.internal:5432"], "request": { "kind": "dns", "name": "other.internal" }, "permitted": false, "capability": "gateway:tcp:other.internal:*" },
|
|
118
|
+
{ "name": "dns: a udp entry does not allow a lookup", "capabilities": ["gateway:udp:db.internal:53"], "request": { "kind": "dns", "name": "db.internal" }, "permitted": false, "capability": "gateway:tcp:db.internal:*" },
|
|
119
|
+
{ "name": "listen tcp: that port", "capabilities": ["gateway:listen:tcp:8080"], "request": { "kind": "listen-tcp", "port": 8080 }, "permitted": true },
|
|
120
|
+
{ "name": "listen tcp: another port", "capabilities": ["gateway:listen:tcp:8080"], "request": { "kind": "listen-tcp", "port": 80 }, "permitted": false, "capability": "gateway:listen:tcp:80" },
|
|
121
|
+
{ "name": "listen tcp: any port", "capabilities": ["gateway:listen:tcp:*"], "request": { "kind": "listen-tcp", "port": 80 }, "permitted": true },
|
|
122
|
+
{ "name": "connecting is not listening", "capabilities": ["gateway:tcp:*:*"], "request": { "kind": "listen-tcp", "port": 8080 }, "permitted": false, "capability": "gateway:listen:tcp:8080" },
|
|
123
|
+
{ "name": "listening is not connecting", "capabilities": ["gateway:listen:tcp:*"], "request": { "kind": "tcp", "host": "example.com", "port": 80 }, "permitted": false, "capability": "gateway:tcp:example.com:80" },
|
|
124
|
+
|
|
125
|
+
{ "name": "unix: exact path", "capabilities": ["unix:/run/app.sock"], "request": { "kind": "unix", "path": "/run/app.sock" }, "permitted": true },
|
|
126
|
+
{ "name": "unix: another path", "capabilities": ["unix:/run/app.sock"], "request": { "kind": "unix", "path": "/run/other.sock" }, "permitted": false, "capability": "unix:/run/other.sock" },
|
|
127
|
+
{ "name": "unix: an exact path is not a directory", "capabilities": ["unix:/run/app.sock"], "request": { "kind": "unix", "path": "/run/app.sock/x" }, "permitted": false, "capability": "unix:/run/app.sock/x" },
|
|
128
|
+
{ "name": "unix: under a directory", "capabilities": ["unix:/srv/*"], "request": { "kind": "unix", "path": "/srv/a/b.sock" }, "permitted": true },
|
|
129
|
+
{ "name": "unix: the directory itself is not under it", "capabilities": ["unix:/srv/*"], "request": { "kind": "unix", "path": "/srv" }, "permitted": false, "capability": "unix:/srv" },
|
|
130
|
+
{ "name": "unix: a look-alike directory", "capabilities": ["unix:/srv/*"], "request": { "kind": "unix", "path": "/srvx/a.sock" }, "permitted": false, "capability": "unix:/srvx/a.sock" },
|
|
131
|
+
{ "name": "unix: climbing out of the directory", "capabilities": ["unix:/srv/*"], "request": { "kind": "unix", "path": "/srv/../etc/x.sock" }, "permitted": false, "capability": "unix:/srv/../etc/x.sock" },
|
|
132
|
+
{ "name": "unix: a . segment", "capabilities": ["unix:/srv/*"], "request": { "kind": "unix", "path": "/srv/./a.sock" }, "permitted": false, "capability": "unix:/srv/./a.sock" },
|
|
133
|
+
{ "name": "unix: an empty segment", "capabilities": ["unix:/srv/*"], "request": { "kind": "unix", "path": "/srv//a.sock" }, "permitted": false, "capability": "unix:/srv//a.sock" },
|
|
134
|
+
{ "name": "unix: a relative path", "capabilities": ["unix:/srv/*"], "request": { "kind": "unix", "path": "srv/a.sock" }, "permitted": false, "capability": "unix:srv/a.sock" },
|
|
135
|
+
{ "name": "unix: /* is every path with a segment", "capabilities": ["unix:/*"], "request": { "kind": "unix", "path": "/a" }, "permitted": true },
|
|
136
|
+
{ "name": "unix: /* does not match the root itself", "capabilities": ["unix:/*"], "request": { "kind": "unix", "path": "/" }, "permitted": false, "capability": "unix:/" },
|
|
137
|
+
{ "name": "connecting to a socket is not listening on one", "capabilities": ["unix:/run/app.sock"], "request": { "kind": "listen-unix", "path": "/run/app.sock" }, "permitted": false, "capability": "unix:listen:/run/app.sock" },
|
|
138
|
+
{ "name": "unix listen: exact path", "capabilities": ["unix:listen:/run/x.sock"], "request": { "kind": "listen-unix", "path": "/run/x.sock" }, "permitted": true },
|
|
139
|
+
{ "name": "unix listen: under a directory", "capabilities": ["unix:listen:/run/*"], "request": { "kind": "listen-unix", "path": "/run/a.sock" }, "permitted": true },
|
|
140
|
+
{ "name": "listening on a socket is not connecting to one", "capabilities": ["unix:listen:/run/x.sock"], "request": { "kind": "unix", "path": "/run/x.sock" }, "permitted": false, "capability": "unix:/run/x.sock" },
|
|
141
|
+
|
|
142
|
+
{ "name": "endpoint: that name", "capabilities": ["endpoint:logs"], "request": { "kind": "endpoint", "name": "logs" }, "permitted": true, "hosts": ["node"] },
|
|
143
|
+
{ "name": "endpoint: another name", "capabilities": ["endpoint:logs"], "request": { "kind": "endpoint", "name": "db" }, "permitted": false, "capability": "endpoint:db", "hosts": ["node"] },
|
|
144
|
+
{ "name": "endpoint: names are case sensitive", "capabilities": ["endpoint:logs"], "request": { "kind": "endpoint", "name": "Logs" }, "permitted": false, "capability": "endpoint:Logs", "hosts": ["node"] },
|
|
145
|
+
{ "name": "endpoint:*", "capabilities": ["endpoint:*"], "request": { "kind": "endpoint", "name": "db" }, "permitted": true, "hosts": ["node"] },
|
|
146
|
+
{ "name": "endpoint on a target needs the target as well", "capabilities": ["endpoint:logs"], "request": { "kind": "endpoint", "name": "logs", "target": "web" }, "permitted": false, "capability": "target:web", "hosts": ["node"] },
|
|
147
|
+
{ "name": "endpoint on a target, with the target", "capabilities": ["endpoint:logs", "target:web"], "request": { "kind": "endpoint", "name": "logs", "target": "web" }, "permitted": true, "hosts": ["node"] },
|
|
148
|
+
{ "name": "target: a named target the list holds", "capabilities": ["exec", "target:web"], "request": { "kind": "open", "channel": "exec", "target": "web" }, "permitted": true, "hosts": ["node"] },
|
|
149
|
+
{ "name": "target: another target", "capabilities": ["exec", "target:web"], "request": { "kind": "open", "channel": "exec", "target": "db" }, "permitted": false, "capability": "target:db", "hosts": ["node"] },
|
|
150
|
+
{ "name": "target: the target is not enough without the kind", "capabilities": ["target:web"], "request": { "kind": "open", "channel": "exec", "target": "web" }, "permitted": false, "capability": "exec", "hosts": ["node"] },
|
|
151
|
+
{ "name": "target:*", "capabilities": ["exec", "target:*"], "request": { "kind": "open", "channel": "exec", "target": "db" }, "permitted": true, "hosts": ["node"] },
|
|
152
|
+
{ "name": "target: the host's own backends need no target entry", "capabilities": ["exec", "target:web"], "request": { "kind": "open", "channel": "exec" }, "permitted": true },
|
|
153
|
+
{ "name": "target: a file op on a target", "capabilities": ["fs:read"], "request": { "kind": "file-op", "op": "list", "target": "web" }, "permitted": false, "capability": "target:web", "hosts": ["node"] },
|
|
154
|
+
{ "name": "target: listing shows the targets the list holds", "capabilities": ["target:web"], "request": { "kind": "target", "name": "web" }, "permitted": true, "hosts": ["node"] },
|
|
155
|
+
{ "name": "target: listing hides the others", "capabilities": ["target:web"], "request": { "kind": "target", "name": "db" }, "permitted": false, "capability": "target:db", "hosts": ["node"] },
|
|
156
|
+
|
|
157
|
+
{ "name": "objects: a root with one operation", "capabilities": ["objects:window:get"], "request": { "kind": "objects", "root": "window", "op": "get" }, "permitted": true, "hosts": ["node"] },
|
|
158
|
+
{ "name": "objects: that operation allows walking toward something", "capabilities": ["objects:window:get"], "request": { "kind": "objects", "root": "window", "op": "walk" }, "permitted": true, "hosts": ["node"] },
|
|
159
|
+
{ "name": "objects: get does not give call", "capabilities": ["objects:window:get"], "request": { "kind": "objects", "root": "window", "op": "call" }, "permitted": false, "capability": "objects:window:call", "hosts": ["node"] },
|
|
160
|
+
{ "name": "objects: get does not give set", "capabilities": ["objects:window:get"], "request": { "kind": "objects", "root": "window", "op": "set" }, "permitted": false, "capability": "objects:window:set", "hosts": ["node"] },
|
|
161
|
+
{ "name": "objects: get does not give on", "capabilities": ["objects:window:get"], "request": { "kind": "objects", "root": "window", "op": "on" }, "permitted": false, "capability": "objects:window:on", "hosts": ["node"] },
|
|
162
|
+
{ "name": "objects: on does not give get", "capabilities": ["objects:window:on"], "request": { "kind": "objects", "root": "window", "op": "get" }, "permitted": false, "capability": "objects:window:get", "hosts": ["node"] },
|
|
163
|
+
{ "name": "objects: on is its own operation", "capabilities": ["objects:window:on"], "request": { "kind": "objects", "root": "window", "op": "on" }, "permitted": true, "hosts": ["node"] },
|
|
164
|
+
{ "name": "objects: another root", "capabilities": ["objects:window:get"], "request": { "kind": "objects", "root": "store", "op": "get" }, "permitted": false, "capability": "objects:store:get", "hosts": ["node"] },
|
|
165
|
+
{ "name": "objects: a root that merely starts like it", "capabilities": ["objects:window"], "request": { "kind": "objects", "root": "windows", "op": "get" }, "permitted": false, "capability": "objects:windows:get", "hosts": ["node"] },
|
|
166
|
+
{ "name": "objects: root names are case sensitive", "capabilities": ["objects:Window"], "request": { "kind": "objects", "root": "window", "op": "get" }, "permitted": false, "capability": "objects:window:get", "hosts": ["node"] },
|
|
167
|
+
{ "name": "objects: a root without an operation allows each of the four", "capabilities": ["objects:window"], "request": { "kind": "objects", "root": "window", "op": "call" }, "permitted": true, "hosts": ["node"] },
|
|
168
|
+
{ "name": "objects: a root without an operation allows on", "capabilities": ["objects:window"], "request": { "kind": "objects", "root": "window", "op": "on" }, "permitted": true, "hosts": ["node"] },
|
|
169
|
+
{ "name": "objects: a root without an operation allows set", "capabilities": ["objects:window"], "request": { "kind": "objects", "root": "window", "op": "set" }, "permitted": true, "hosts": ["node"] },
|
|
170
|
+
{ "name": "objects: a root without an operation allows walking", "capabilities": ["objects:window"], "request": { "kind": "objects", "root": "window", "op": "walk" }, "permitted": true, "hosts": ["node"] },
|
|
171
|
+
{ "name": "objects: * names every root, for the operation it names", "capabilities": ["objects:*:call"], "request": { "kind": "objects", "root": "anything", "op": "call" }, "permitted": true, "hosts": ["node"] },
|
|
172
|
+
{ "name": "objects: *:call does not give get", "capabilities": ["objects:*:call"], "request": { "kind": "objects", "root": "anything", "op": "get" }, "permitted": false, "capability": "objects:anything:get", "hosts": ["node"] },
|
|
173
|
+
{ "name": "objects: * with no operation is everything", "capabilities": ["objects:*"], "request": { "kind": "objects", "root": "anything", "op": "set" }, "permitted": true, "hosts": ["node"] },
|
|
174
|
+
{ "name": "objects: the second entry is enough", "capabilities": ["objects:window:get", "objects:store:set"], "request": { "kind": "objects", "root": "store", "op": "set" }, "permitted": true, "hosts": ["node"] },
|
|
175
|
+
{ "name": "objects: one entry's root with another's operation", "capabilities": ["objects:window:get", "objects:store:set"], "request": { "kind": "objects", "root": "window", "op": "set" }, "permitted": false, "capability": "objects:window:set", "hosts": ["node"] },
|
|
176
|
+
{ "name": "objects: rpc:wsh-objects alone is every root and operation", "capabilities": ["rpc:wsh-objects"], "request": { "kind": "objects", "root": "window", "op": "set" }, "permitted": true, "hosts": ["node"] },
|
|
177
|
+
{ "name": "objects: once a list names roots it is limited to them, whatever rpc:wsh-objects says", "capabilities": ["rpc:wsh-objects", "objects:store:get"], "request": { "kind": "objects", "root": "window", "op": "get" }, "permitted": false, "capability": "objects:window:get", "hosts": ["node"] },
|
|
178
|
+
{ "name": "objects: a list with neither", "capabilities": ["exec"], "request": { "kind": "objects", "root": "window", "op": "get" }, "permitted": false, "capability": "rpc:wsh-objects", "hosts": ["node"] },
|
|
179
|
+
{ "name": "objects: the channel of a handler that narrows by root is open to a key that names one", "capabilities": ["objects:window:get"], "request": { "kind": "open", "channel": "rpc", "protocol": "wsh-objects", "scoped": true }, "permitted": true, "hosts": ["node"] },
|
|
180
|
+
{ "name": "objects: that channel is not open to a key with neither", "capabilities": ["exec"], "request": { "kind": "open", "channel": "rpc", "protocol": "wsh-objects", "scoped": true }, "permitted": false, "capability": "rpc:wsh-objects", "hosts": ["node"] },
|
|
181
|
+
{ "name": "objects: a handler that does not narrow by root needs rpc:wsh-objects", "capabilities": ["objects:window:get"], "request": { "kind": "open", "channel": "rpc", "protocol": "wsh-objects" }, "permitted": false, "capability": "rpc:wsh-objects", "hosts": ["node"] },
|
|
182
|
+
|
|
183
|
+
{ "name": "expires: before it", "capabilities": ["exec"], "expires": "2030-01-01T00:00:00Z", "now": 1893455999, "request": { "kind": "open", "channel": "exec" }, "permitted": true },
|
|
184
|
+
{ "name": "expires: at it", "capabilities": ["exec"], "expires": "2030-01-01T00:00:00Z", "now": 1893456000, "request": { "kind": "open", "channel": "exec" }, "permitted": false, "code": "key-expired" },
|
|
185
|
+
{ "name": "expires: after it", "capabilities": ["exec"], "expires": "2030-01-01T00:00:00Z", "now": 1893456001, "request": { "kind": "relay" }, "permitted": false, "code": "key-expired" },
|
|
186
|
+
{ "name": "expires: an offset is honoured", "capabilities": ["exec"], "expires": "2030-01-01T00:00:00+01:00", "now": 1893452400, "request": { "kind": "open", "channel": "exec" }, "permitted": false, "code": "key-expired" },
|
|
187
|
+
{ "name": "expires: an offset is honoured, before it", "capabilities": ["exec"], "expires": "2030-01-01T00:00:00+01:00", "now": 1893452399, "request": { "kind": "open", "channel": "exec" }, "permitted": true },
|
|
188
|
+
{ "name": "expires: fractional seconds are dropped", "capabilities": ["exec"], "expires": "2030-01-01T00:00:00.999Z", "now": 1893456000, "request": { "kind": "open", "channel": "exec" }, "permitted": false, "code": "key-expired" },
|
|
189
|
+
{ "name": "expires beats a capability that would grant", "capabilities": ["objects:window"], "expires": "2030-01-01T00:00:00Z", "now": 1893456000, "request": { "kind": "objects", "root": "window", "op": "get" }, "permitted": false, "code": "key-expired", "hosts": ["node"] },
|
|
190
|
+
{ "name": "no expiry: any time", "capabilities": ["exec"], "now": 99999999999, "request": { "kind": "open", "channel": "exec" }, "permitted": true },
|
|
191
|
+
|
|
192
|
+
{ "name": "restrict grants nothing, so the capability does not help", "options": "restrict", "capabilities": ["exec"], "request": { "kind": "open", "channel": "exec" }, "permitted": false, "code": "exec-not-permitted" },
|
|
193
|
+
{ "name": "restrict,permit-exec with a list that names exec", "options": "restrict,permit-exec", "capabilities": ["exec"], "request": { "kind": "open", "channel": "exec" }, "permitted": true },
|
|
194
|
+
{ "name": "the options win: restrict refuses what the list names", "options": "restrict,permit-exec", "capabilities": ["exec", "pty"], "request": { "kind": "open", "channel": "pty" }, "permitted": false, "code": "pty-not-permitted" },
|
|
195
|
+
{ "name": "the list wins where the options allow: permit-pty does not give a file", "options": "restrict,permit-pty", "capabilities": ["pty", "exec"], "request": { "kind": "open", "channel": "file", "direction": "download" }, "permitted": false, "code": "file-transfer-not-permitted" },
|
|
196
|
+
{ "name": "options that allow and a list that does not", "options": "restrict,permit-exec,permit-pty", "capabilities": ["exec"], "request": { "kind": "open", "channel": "pty" }, "permitted": false, "code": "capability-missing", "capability": "pty" },
|
|
197
|
+
{ "name": "a forced command is not a shell, whatever the list says", "options": "command=\"uptime\"", "capabilities": ["exec", "pty"], "request": { "kind": "open", "channel": "pty" }, "permitted": false, "code": "forced-command" },
|
|
198
|
+
{ "name": "max-sessions and the list", "options": "max-sessions=1", "capabilities": ["exec"], "request": { "kind": "open", "channel": "exec" }, "activeSessions": 1, "permitted": false, "code": "max-sessions" }
|
|
199
|
+
]
|
|
200
|
+
}
|