MCPcopy Index your code
hub / github.com/garrytan/gstack / checkCanaryInStructure

Function checkCanaryInStructure

browse/src/security.ts:297–310  ·  view source on GitHub ↗
(value: unknown, canary: string)

Source from the content-addressed store, hash-verified

295 * structure — including tool call arguments, URLs embedded in strings, etc.
296 */
297export 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

Calls

no outgoing calls

Tested by

no test coverage detected