* Validate permissionUpdates from external sources (mailbox IPC, disk polling). * Malformed entries from buggy/old teammate processes are filtered out rather * than propagated unchecked into callback.onAllow().
(raw: unknown)
| 33 | * than propagated unchecked into callback.onAllow(). |
| 34 | */ |
| 35 | function parsePermissionUpdates(raw: unknown): PermissionUpdate[] { |
| 36 | if (!Array.isArray(raw)) { |
| 37 | return [] |
| 38 | } |
| 39 | const schema = permissionUpdateSchema() |
| 40 | const valid: PermissionUpdate[] = [] |
| 41 | for (const entry of raw) { |
| 42 | const result = schema.safeParse(entry) |
| 43 | if (result.success) { |
| 44 | valid.push(result.data) |
| 45 | } else { |
| 46 | logForDebugging( |
| 47 | `[SwarmPermissionPoller] Dropping malformed permissionUpdate entry: ${result.error.message}`, |
| 48 | { level: 'warn' }, |
| 49 | ) |
| 50 | } |
| 51 | } |
| 52 | return valid |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Callback signature for handling permission responses |
no test coverage detected