{"version":3,"file":"copyTestCaseFileInput.cjs","names":["fs","copyWithoutFollowingSymlinks"],"sources":["../../src/helpers/copyTestCaseFileInput.ts"],"sourcesContent":["import fs from 'node:fs';\n\nimport { copyWithoutFollowingSymlinks } from './safeFs.js';\nimport { makeAccessibleToSandboxUser } from './sandboxUser.js';\n\nexport async function copyTestCaseFileInput(fileInputPath: string, cwd: string): Promise<void> {\n  // `readTestCases` only ever yields a real `.fin` directory here (it selects entries by\n  // `dirent.isDirectory()`, which does not follow links), and the destination is the working\n  // directory itself, so anything else would mean replacing that whole directory — with a file, or\n  // with a symlink to the problem's test cases. `lstat`, not `stat`: the latter resolves a symlink\n  // source and would report it as a directory.\n  const fileInputStats = await fs.promises.lstat(fileInputPath);\n  if (!fileInputStats.isDirectory()) {\n    throw new Error(`test case file input must be a directory, not a symlink or file: ${fileInputPath}`);\n  }\n  // A no-follow copy: a sandboxed submission may have planted a symlink at one of these\n  // destination paths to redirect this trusted-user write outside its working directory.\n  await copyWithoutFollowingSymlinks(fileInputPath, cwd);\n  // The copied files are owned by the harness user; the sandboxed submission must read them and\n  // may create outputs in the copied directories.\n  makeAccessibleToSandboxUser(cwd);\n}\n"],"mappings":"qKAKA,eAAsB,EAAsB,EAAuB,EAA4B,CAO7F,GAAI,EAAC,MADwBA,EAAAA,QAAG,SAAS,MAAM,CAAa,EAAA,CACxC,YAAY,EAC9B,MAAU,MAAM,oEAAoE,GAAe,EAIrG,MAAMC,EAAAA,6BAA6B,EAAe,CAAG,EAGrD,EAAA,4BAA4B,CAAG,CACjC"}