(value: unknown, canary: string)
| 295 | * structure — including tool call arguments, URLs embedded in strings, etc. |
| 296 | */ |
| 297 | export function checkCanaryInStructure(value: unknown, canary: string): boolean { |
| 298 | if (value == null) return false; |
| 299 | if (typeof value === 'string') return value.includes(canary); |
| 300 | if (typeof value === 'number' || typeof value === 'boolean') return false; |
| 301 | if (Array.isArray(value)) { |
| 302 | return value.some((v) => checkCanaryInStructure(v, canary)); |
| 303 | } |
| 304 | if (typeof value === 'object') { |
| 305 | return Object.values(value as Record<string, unknown>).some((v) => |
| 306 | checkCanaryInStructure(v, canary), |
| 307 | ); |
| 308 | } |
| 309 | return false; |
| 310 | } |
| 311 | |
| 312 | // ─── Attack logging ────────────────────────────────────────── |
| 313 |
no outgoing calls
no test coverage detected