fix(gateway): classify pairing rejection events · openclaw/openclaw@3c64a57
vincentkoc
·
2026-06-17
·
via Recent Commits to openclaw:main
File tree
src/gateway/server-methods
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1193,14 +1193,35 @@ describe("deviceHandlers", () => {
|
1193 | 1193 | }), |
1194 | 1194 | }, |
1195 | 1195 | ); |
| 1196 | +const captured = captureSecurityEvents(); |
1196 | 1197 | |
1197 | | -await deviceHandlers["device.pair.reject"](opts); |
| 1198 | +try { |
| 1199 | +await deviceHandlers["device.pair.reject"](opts); |
| 1200 | +} finally { |
| 1201 | +captured.stop(); |
| 1202 | +} |
1198 | 1203 | |
1199 | 1204 | expect(rejectDevicePairingMock).toHaveBeenCalledWith("req-2"); |
1200 | 1205 | expect(opts.respond).toHaveBeenCalledWith( |
1201 | 1206 | true, |
1202 | 1207 | { requestId: "req-2", deviceId: "device-2", rejectedAtMs: 456 }, |
1203 | 1208 | undefined, |
1204 | 1209 | ); |
| 1210 | +expect(captured.events).toHaveLength(1); |
| 1211 | +expect(captured.events[0]).toMatchObject({ |
| 1212 | +action: "device.pairing.rejected", |
| 1213 | +outcome: "success", |
| 1214 | +severity: "low", |
| 1215 | +actor: { |
| 1216 | +kind: "operator", |
| 1217 | +role: "admin", |
| 1218 | +}, |
| 1219 | +target: { kind: "device", idHash: expect.stringMatching(/^sha256:[a-f0-9]{12}$/u) }, |
| 1220 | +policy: { id: "gateway.device-pairing", decision: "allow" }, |
| 1221 | +control: { id: "device.pair.reject", family: "auth" }, |
| 1222 | +}); |
| 1223 | +const serialized = JSON.stringify(captured.events); |
| 1224 | +expect(serialized).not.toContain("device-1"); |
| 1225 | +expect(serialized).not.toContain("device-2"); |
1205 | 1226 | }); |
1206 | 1227 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -256,7 +256,7 @@ function emitDevicePairingDeniedSecurityEvent(params: {
|
256 | 256 | } |
257 | 257 | |
258 | 258 | function emitDevicePairingLifecycleSecurityEvent(params: { |
259 | | -action: "device.pairing.approved" | "device.pairing.removed"; |
| 259 | +action: "device.pairing.approved" | "device.pairing.rejected" | "device.pairing.removed"; |
260 | 260 | severity: DiagnosticSecurityEventInput["severity"]; |
261 | 261 | authz: DeviceSessionAuthz; |
262 | 262 | targetDeviceId: string; |
@@ -513,11 +513,11 @@ export const deviceHandlers: GatewayRequestHandlers = {
|
513 | 513 | respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, "unknown requestId")); |
514 | 514 | return; |
515 | 515 | } |
516 | | -emitDevicePairingDeniedSecurityEvent({ |
| 516 | +emitDevicePairingLifecycleSecurityEvent({ |
| 517 | +action: "device.pairing.rejected", |
517 | 518 | authz, |
518 | 519 | targetDeviceId: rejected.deviceId, |
519 | 520 | controlId: "device.pair.reject", |
520 | | -reason: "operator-rejected", |
521 | 521 | severity: "low", |
522 | 522 | }); |
523 | 523 | context.broadcast( |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。