Skip to content

Commit 4010203

Browse files
committed
refactor(gateway): unify node admin policy
1 parent 7ef1b10 commit 4010203

4 files changed

Lines changed: 57 additions & 49 deletions

File tree

‎apps/.i18n/native-source.json‎

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,79 +1755,79 @@
17551755
},
17561756
{
17571757
"kind": "ui-call",
1758-
"line": 3152,
1758+
"line": 3173,
17591759
"path": "apps/android/app/src/main/java/ai/openclaw/app/chat/ChatController.kt",
17601760
"source": "Could not stage an attachment for sending.",
17611761
"surface": "android",
17621762
"id": "native.android.2db6d419791ce6a7"
17631763
},
17641764
{
17651765
"kind": "ui-call",
1766-
"line": 3185,
1766+
"line": 3206,
17671767
"path": "apps/android/app/src/main/java/ai/openclaw/app/chat/ChatController.kt",
17681768
"source": "Offline queue is full ($OUTBOX_MAX_QUEUED messages); delete queued items first.",
17691769
"surface": "android",
17701770
"id": "native.android.c3899241029d152c"
17711771
},
17721772
{
17731773
"kind": "ui-call",
1774-
"line": 3191,
1774+
"line": 3212,
17751775
"path": "apps/android/app/src/main/java/ai/openclaw/app/chat/ChatController.kt",
17761776
"source": "Attachments are too large to queue for one message; remove some and try again.",
17771777
"surface": "android",
17781778
"id": "native.android.4cf5774e212e307d"
17791779
},
17801780
{
17811781
"kind": "ui-call",
1782-
"line": 3197,
1782+
"line": 3218,
17831783
"path": "apps/android/app/src/main/java/ai/openclaw/app/chat/ChatController.kt",
17841784
"source": "Offline attachment storage is full; delete queued items first.",
17851785
"surface": "android",
17861786
"id": "native.android.d8724124bd4a3719"
17871787
},
17881788
{
17891789
"kind": "ui-call",
1790-
"line": 3202,
1790+
"line": 3223,
17911791
"path": "apps/android/app/src/main/java/ai/openclaw/app/chat/ChatController.kt",
17921792
"source": "Gateway health not OK; cannot send",
17931793
"surface": "android",
17941794
"id": "native.android.84af66e78ec02fa3"
17951795
},
17961796
{
17971797
"kind": "ui-call",
1798-
"line": 3209,
1798+
"line": 3230,
17991799
"path": "apps/android/app/src/main/java/ai/openclaw/app/chat/ChatController.kt",
18001800
"source": "Could not queue message for later delivery.",
18011801
"surface": "android",
18021802
"id": "native.android.0b29275eefad9863"
18031803
},
18041804
{
18051805
"kind": "ui-call",
1806-
"line": 3926,
1806+
"line": 3947,
18071807
"path": "apps/android/app/src/main/java/ai/openclaw/app/chat/ChatController.kt",
18081808
"source": "Chat failed",
18091809
"surface": "android",
18101810
"id": "native.android.8c2ff49af3e78aee"
18111811
},
18121812
{
18131813
"kind": "ui-call",
1814-
"line": 4064,
1814+
"line": 4085,
18151815
"path": "apps/android/app/src/main/java/ai/openclaw/app/chat/ChatController.kt",
18161816
"source": "Event stream interrupted; try refreshing.",
18171817
"surface": "android",
18181818
"id": "native.android.e2f245e1995de5e8"
18191819
},
18201820
{
18211821
"kind": "ui-call",
1822-
"line": 4201,
1822+
"line": 4222,
18231823
"path": "apps/android/app/src/main/java/ai/openclaw/app/chat/ChatController.kt",
18241824
"source": "Timed out waiting for a reply; try again or refresh.",
18251825
"surface": "android",
18261826
"id": "native.android.2274c6848b1c098b"
18271827
},
18281828
{
18291829
"kind": "ui-call",
1830-
"line": 4411,
1830+
"line": 4432,
18311831
"path": "apps/android/app/src/main/java/ai/openclaw/app/chat/ChatController.kt",
18321832
"source": "Timed out confirming the sent message; refresh to check delivery.",
18331833
"surface": "android",
@@ -1843,15 +1843,15 @@
18431843
},
18441844
{
18451845
"kind": "conditional-branch",
1846-
"line": 1530,
1846+
"line": 1563,
18471847
"path": "apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt",
18481848
"source": "Connecting…",
18491849
"surface": "android",
18501850
"id": "native.android.1cbaba9cbffb2f97"
18511851
},
18521852
{
18531853
"kind": "conditional-branch",
1854-
"line": 1530,
1854+
"line": 1563,
18551855
"path": "apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt",
18561856
"source": "Reconnecting…",
18571857
"surface": "android",
@@ -23395,111 +23395,111 @@
2339523395
},
2339623396
{
2339723397
"kind": "ui-localized-call",
23398-
"line": 4088,
23398+
"line": 4087,
2339923399
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2340023400
"source": "Approval needed",
2340123401
"surface": "apple",
2340223402
"id": "native.apple.ce6a022159f2fb41"
2340323403
},
2340423404
{
2340523405
"kind": "ui-localized-call",
23406-
"line": 4089,
23406+
"line": 4088,
2340723407
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2340823408
"source": "Action required",
2340923409
"surface": "apple",
2341023410
"id": "native.apple.0d030e96f7738497"
2341123411
},
2341223412
{
2341323413
"kind": "ui-localized-call",
23414-
"line": 4804,
23414+
"line": 4803,
2341523415
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2341623416
"source": "Connecting...",
2341723417
"surface": "apple",
2341823418
"id": "native.apple.6504753f3621269e"
2341923419
},
2342023420
{
2342123421
"kind": "ui-localized-call",
23422-
"line": 4805,
23422+
"line": 4804,
2342323423
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2342423424
"source": "Reconnecting...",
2342523425
"surface": "apple",
2342623426
"id": "native.apple.c7fbe2a713d78714"
2342723427
},
2342823428
{
2342923429
"kind": "conditional-branch",
23430-
"line": 5157,
23430+
"line": 5156,
2343123431
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2343223432
"source": "Connected",
2343323433
"surface": "apple",
2343423434
"id": "native.apple.c0a005f81d588867"
2343523435
},
2343623436
{
2343723437
"kind": "conditional-branch",
23438-
"line": 5157,
23438+
"line": 5156,
2343923439
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2344023440
"source": "Offline",
2344123441
"surface": "apple",
2344223442
"id": "native.apple.ae33908b61c6d70b"
2344323443
},
2344423444
{
2344523445
"kind": "conditional-branch",
23446-
"line": 6327,
23446+
"line": 6326,
2344723447
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2344823448
"source": "No chat messages yet",
2344923449
"surface": "apple",
2345023450
"id": "native.apple.4a98b3a346be2662"
2345123451
},
2345223452
{
2345323453
"kind": "conditional-branch",
23454-
"line": 6526,
23454+
"line": 6525,
2345523455
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2345623456
"source": "Connecting…",
2345723457
"surface": "apple",
2345823458
"id": "native.apple.b0d9c1ba8ef7ec19"
2345923459
},
2346023460
{
2346123461
"kind": "conditional-branch",
23462-
"line": 6526,
23462+
"line": 6525,
2346323463
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2346423464
"source": "Reconnecting…",
2346523465
"surface": "apple",
2346623466
"id": "native.apple.bd98e19b49309284"
2346723467
},
2346823468
{
2346923469
"kind": "conditional-branch",
23470-
"line": 8935,
23470+
"line": 8934,
2347123471
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2347223472
"source": "Approval",
2347323473
"surface": "apple",
2347423474
"id": "native.apple.0b1eff808df04e2b"
2347523475
},
2347623476
{
2347723477
"kind": "conditional-branch",
23478-
"line": 8935,
23478+
"line": 8934,
2347923479
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2348023480
"source": "This approval was already",
2348123481
"surface": "apple",
2348223482
"id": "native.apple.c74dccc1c5d71750"
2348323483
},
2348423484
{
2348523485
"kind": "conditional-branch",
23486-
"line": 8941,
23486+
"line": 8940,
2348723487
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2348823488
"source": "This approval was already set to Always Allow.",
2348923489
"surface": "apple",
2349023490
"id": "native.apple.4e3a9dc13016600b"
2349123491
},
2349223492
{
2349323493
"kind": "conditional-branch",
23494-
"line": 8942,
23494+
"line": 8941,
2349523495
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2349623496
"source": "Approval set to Always Allow.",
2349723497
"surface": "apple",
2349823498
"id": "native.apple.4864b3b8c6ed7158"
2349923499
},
2350023500
{
2350123501
"kind": "conditional-branch",
23502-
"line": 10280,
23502+
"line": 10278,
2350323503
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2350423504
"source": "\\(urlText.prefix(500))…",
2350523505
"surface": "apple",
@@ -25635,15 +25635,15 @@
2563525635
},
2563625636
{
2563725637
"kind": "ui-localized-call",
25638-
"line": 4700,
25638+
"line": 4693,
2563925639
"path": "apps/ios/Sources/Voice/TalkModeManager.swift",
2564025640
"source": "Realtime unavailable",
2564125641
"surface": "apple",
2564225642
"id": "native.apple.7876a473b7c3c245"
2564325643
},
2564425644
{
2564525645
"kind": "ui-localized-call",
25646-
"line": 4722,
25646+
"line": 4715,
2564725647
"path": "apps/ios/Sources/Voice/TalkModeManager.swift",
2564825648
"source": "Listening (PTT)",
2564925649
"surface": "apple",

‎src/infra/node-commands.ts‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const NODE_EXEC_APPROVALS_COMMANDS = [
2424
] as const;
2525

2626
// Direct node.invoke and pairing approval share this admin-only subset.
27-
export const NODE_ADMIN_ONLY_INVOKE_COMMANDS = [
27+
const NODE_ADMIN_ONLY_INVOKE_COMMANDS = [
2828
NODE_BROWSER_PROXY_COMMAND,
2929
NODE_FS_LIST_DIR_COMMAND,
3030
NODE_TERMINAL_UPLOAD_COMMAND,
@@ -37,12 +37,5 @@ export function isAdminOnlyNodeInvokeCommand(command: unknown): boolean {
3737
return typeof command === "string" && NODE_ADMIN_ONLY_INVOKE_COMMAND_SET.has(command);
3838
}
3939

40-
// Pairing also protects commands whose execution uses a separate gated path.
41-
export const NODE_ADMIN_PAIR_APPROVAL_COMMANDS = [
42-
...NODE_SYSTEM_RUN_COMMANDS,
43-
...NODE_ADMIN_ONLY_INVOKE_COMMANDS,
44-
...NODE_EXEC_APPROVALS_COMMANDS,
45-
] as const;
46-
4740
export const NODE_MCP_TOOL_CALL_TIMEOUT_MS = 120_000;
4841
export const NODE_MCP_TOOL_CALL_GATEWAY_TIMEOUT_MS = NODE_MCP_TOOL_CALL_TIMEOUT_MS + 5_000;

‎src/infra/node-pairing-authz.test.ts‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
// Covers scope requirements for node pairing approvals.
22
import { describe, expect, it } from "vitest";
33
import {
4-
NODE_ADMIN_ONLY_INVOKE_COMMANDS,
5-
NODE_ADMIN_PAIR_APPROVAL_COMMANDS,
4+
NODE_BROWSER_PROXY_COMMAND,
65
NODE_EXEC_APPROVALS_COMMANDS,
6+
NODE_FS_LIST_DIR_COMMAND,
7+
NODE_SYSTEM_RUN_COMMANDS,
8+
NODE_TERMINAL_UPLOAD_COMMAND,
9+
isAdminOnlyNodeInvokeCommand,
710
} from "./node-commands.js";
811
import { resolveNodePairApprovalScopes } from "./node-pairing-authz.js";
912

13+
const ADMIN_ONLY_INVOKE_COMMANDS = [
14+
NODE_BROWSER_PROXY_COMMAND,
15+
NODE_FS_LIST_DIR_COMMAND,
16+
NODE_TERMINAL_UPLOAD_COMMAND,
17+
] as const;
18+
1019
describe("resolveNodePairApprovalScopes", () => {
1120
it("requires operator.admin for system.run commands", () => {
1221
expect(resolveNodePairApprovalScopes(["system.run"])).toEqual([
@@ -15,7 +24,7 @@ describe("resolveNodePairApprovalScopes", () => {
1524
]);
1625
});
1726

18-
it.each(NODE_ADMIN_PAIR_APPROVAL_COMMANDS)(
27+
it.each([...NODE_SYSTEM_RUN_COMMANDS, ...ADMIN_ONLY_INVOKE_COMMANDS])(
1928
"requires operator.admin for %s commands",
2029
(command) => {
2130
expect(resolveNodePairApprovalScopes([command])).toEqual([
@@ -25,10 +34,8 @@ describe("resolveNodePairApprovalScopes", () => {
2534
},
2635
);
2736

28-
it("keeps every direct-invoke admin command admin-gated at pairing", () => {
29-
for (const command of NODE_ADMIN_ONLY_INVOKE_COMMANDS) {
30-
expect(NODE_ADMIN_PAIR_APPROVAL_COMMANDS).toContain(command);
31-
}
37+
it.each(ADMIN_ONLY_INVOKE_COMMANDS)("classifies %s as admin-only at invocation", (command) => {
38+
expect(isAdminOnlyNodeInvokeCommand(command)).toBe(true);
3239
});
3340

3441
it("keeps dedicated exec-approval commands admin-gated at pairing", () => {

‎src/infra/node-pairing-authz.ts‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// Maps node pairing command declarations to required operator scopes.
2-
import { NODE_ADMIN_PAIR_APPROVAL_COMMANDS } from "./node-commands.js";
2+
import {
3+
NODE_EXEC_APPROVALS_COMMANDS,
4+
NODE_SYSTEM_RUN_COMMANDS,
5+
isAdminOnlyNodeInvokeCommand,
6+
} from "./node-commands.js";
37

48
/** Operator scopes required to approve a pending node pairing surface. */
59
export type NodeApprovalScope = "operator.pairing" | "operator.write" | "operator.admin";
@@ -8,16 +12,20 @@ const OPERATOR_PAIRING_SCOPE: NodeApprovalScope = "operator.pairing";
812
const OPERATOR_WRITE_SCOPE: NodeApprovalScope = "operator.write";
913
const OPERATOR_ADMIN_SCOPE: NodeApprovalScope = "operator.admin";
1014

15+
function isAdminPairApprovalCommand(command: string): boolean {
16+
return (
17+
isAdminOnlyNodeInvokeCommand(command) ||
18+
NODE_SYSTEM_RUN_COMMANDS.some((allowed) => allowed === command) ||
19+
NODE_EXEC_APPROVALS_COMMANDS.some((allowed) => allowed === command)
20+
);
21+
}
22+
1123
/** Map declared node commands to the least operator scopes needed for approval. */
1224
export function resolveNodePairApprovalScopes(commands: unknown): NodeApprovalScope[] {
1325
const normalized = Array.isArray(commands)
1426
? commands.filter((command): command is string => typeof command === "string")
1527
: [];
16-
if (
17-
normalized.some((command) =>
18-
NODE_ADMIN_PAIR_APPROVAL_COMMANDS.some((allowed) => allowed === command),
19-
)
20-
) {
28+
if (normalized.some(isAdminPairApprovalCommand)) {
2129
return [OPERATOR_PAIRING_SCOPE, OPERATOR_ADMIN_SCOPE];
2230
}
2331
if (normalized.length > 0) {

0 commit comments

Comments
 (0)