// CI-only dependency: Moby profiles, Apache-2.0. See ADR-0020. import { createHash } from 'node:crypto'; import { writeFile } from 'node:fs/promises'; const revision = '245180c51918481c0525424b3ee025d2b435d46c'; const expectedHash = '785b2429264afba4d594320337cb17f144f3c7d51585f9805eef72e28f4f9334'; const destination = process.argv[2]; if (!destination) throw new Error('Expected output seccomp profile path'); const response = await fetch( `https://raw.githubusercontent.com/moby/profiles/${revision}/seccomp/default.json`, { signal: AbortSignal.timeout(30000) }, ); if (!response.ok) throw new Error(`Profile download failed: ${response.status}`); const bytes = Buffer.from(await response.arrayBuffer()); if (createHash('sha256').update(bytes).digest('hex') !== expectedHash) { throw new Error('Pinned seccomp profile checksum mismatch'); } const profile = JSON.parse(bytes.toString('utf8')); if (profile.defaultAction !== 'SCMP_ACT_ERRNO' || !Array.isArray(profile.syscalls)) { throw new Error('Unexpected upstream profile structure'); } // Only PER_LINUX | ADDR_NO_RANDOMIZE, not arbitrary execution personalities. // Changes the test process address layout; does not change a host sysctl. profile.syscalls.push({ names: ['personality'], action: 'SCMP_ACT_ALLOW', args: [{ index: 0, value: 0x40000, op: 'SCMP_CMP_EQ' }], }); await writeFile(destination, `${JSON.stringify(profile, null, 2)}\n`); console.log(`Verified Moby ${revision}; added only personality(0x40000) for TSan`);