(value: unknown, decision?: 'allow' | 'deny' | 'ask')
| 394 | } |
| 395 | |
| 396 | function transformPermissionRule(value: unknown, decision?: 'allow' | 'deny' | 'ask'): unknown { |
| 397 | if (!isPlainObject(value)) return value; |
| 398 | |
| 399 | const rule = transformPlainObject(value); |
| 400 | const tool = rule['tool']; |
| 401 | const match = rule['match']; |
| 402 | const pattern = rule['pattern']; |
| 403 | const out: Record<string, unknown> = {}; |
| 404 | |
| 405 | if (decision !== undefined) { |
| 406 | out['decision'] = decision; |
| 407 | } else { |
| 408 | out['decision'] = rule['decision']; |
| 409 | } |
| 410 | out['scope'] = rule['scope']; |
| 411 | out['reason'] = rule['reason']; |
| 412 | |
| 413 | if (typeof tool === 'string') { |
| 414 | const argPattern = typeof match === 'string' ? match : pattern; |
| 415 | out['pattern'] = typeof argPattern === 'string' ? `${tool}(${argPattern})` : tool; |
| 416 | } else { |
| 417 | out['pattern'] = pattern; |
| 418 | } |
| 419 | |
| 420 | return out; |
| 421 | } |
| 422 | |
| 423 | function transformServiceData(data: Record<string, unknown>): Record<string, unknown> { |
| 424 | const out: Record<string, unknown> = {}; |
no test coverage detected