// Container/polyglot rejection contract. // // The requirement is malformed/polyglot REJECTION, not "the re-encoder happens // to drop the tail". Rejection must come from canonical parsing of the image // container — the declared structure must consume exactly the supplied bytes — // so it cannot be evaded by changing keyword casing or archive flavour, and it // must not fire on arbitrary compressed bytes that merely contain those // sequences inside legal image structure. import test from 'node:test'; import assert from 'node:assert/strict'; import { readFile } from 'node:fs/promises'; import { fileURLToPath } from 'node:url'; import { validateImageIngress } from '../src/image-ingress.js'; import { analyzePhoto } from '../src/vision-service.js'; const fixture = (name) => fileURLToPath(new URL(`../tests/fixtures/${name}`, import.meta.url)); const readFixture = (name) => readFile(fixture(name)); const dataUrl = (bytes, mime = 'image/jpeg') => `data:${mime};base64,${bytes.toString('base64')}`; const TRAILING_DATA_FIXTURES = [ ['ingress-tail-upper-script.jpg', 'uppercase