INNER CODE UNIT · JavaScript

extractTarGzToScratch

agent-sh/agentsys · lib/binary/index.js:408

async function extractTarGzToScratch(buf) {
  const entries = await listTarGzEntries(buf);
  for (let i = 0; i < entries.length; i++) {
    assertSafeArchiveEntry(entries[i]);
  }

  const scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-analyzer-tar-'));

  try {
    await new Promise(function(resolve, reject) {
      const tar = cp.spawn('tar', ['xz', '-C', scratch], { stdio: ['pipe', 'pipe', 'pipe'] });
      let stderr = '';
      tar.stderr.on('data', function(d) { stderr += d; });
      tar.on('error', reject);
      tar.on('close', function(code) {
        if (code !== 0) {
          reject(new Error('tar extraction failed (code ' + code + '): ' + stderr));
        } else {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…