Skip to content
Astera Technology

Why would an archive entry leave its designated import folder?

Check the resolved destination against the supplied root before accepting an entry.

Download complete case notes and answer keys ↓

Read the source and its declared rule

This original in-memory entry contract allows relative file destinations strictly below /import. Resolving ../outside.txt against that root yields /outside.txt, so it is held. Absolute entry names are prohibited even if their spelling points inside the root. No host extraction occurs.

Filled synthetic input
RecordInput JSON
Base input{"name":"../outside.txt"}
Download editable CSV ↓

Compare the actual paths

Correct output retains the source name and path-escape decision. A safe-looking concatenation is not sufficient when relative segments can resolve above the intended root.

Misleading and corrected outputs
PathOutput JSON
Misleading path{"accepted":true,"source":"../outside.txt","destination":"/outside.txt"}
Corrected path{"accepted":false,"error":"path-escape","source":"../outside.txt"}
Download editable CSV ↓
Local Node.js program: 22.23.3 or 24.14.1
import {DatabaseSync} from 'node:sqlite';
import {TextDecoder} from 'node:util';
import {inflateSync} from 'node:zlib';
import {posix} from 'node:path';
import {createHash} from 'node:crypto';
const rows=(db,sql)=>db.prepare(sql).all().map(r=>({...r}));
const failed=(action)=>{try{action();return null;}catch(e){return {code:e.errcode??e.code??e.name};}};

import assert from 'node:assert/strict';
const run=function run(i,corrected=true){
    const destination=posix.resolve('/import',i.name);
    if(corrected&&(posix.isAbsolute(i.name)||!destination.startsWith('/import/')))return {accepted:false,error:posix.isAbsolute(i.name)?'absolute-entry':'path-escape',source:i.name};
    return {accepted:true,source:i.name,destination};
  };
const cases=[{"label":"misleading base","input":{"name":"../outside.txt"},"expected":{"accepted":true,"source":"../outside.txt","destination":"/outside.txt"},"corrected":false},{"label":"corrected base","input":{"name":"../outside.txt"},"expected":{"accepted":false,"error":"path-escape","source":"../outside.txt"},"corrected":true},{"label":"ordinary contained entry","input":{"name":"docs/a.txt"},"expected":{"accepted":true,"source":"docs/a.txt","destination":"/import/docs/a.txt"},"corrected":true},{"label":"absolute source entry rejected","input":{"name":"/import/a.txt"},"expected":{"accepted":false,"error":"absolute-entry","source":"/import/a.txt"},"corrected":true}];
for(const test of cases){
  const actual=run(test.input,test.corrected);
  assert.deepEqual(actual,test.expected,test.label);
  console.log(test.label,actual);
}
Download runnable example ↓

Check boundaries before the next load

docs/a.txt resolves inside /import. An absolute /import/a.txt is rejected by the explicit relative-entry contract.

Editable boundary records and expected outputs
CaseInput JSONExpected output JSON
Contained relative destination{"name":"docs/a.txt"}{"accepted":true,"source":"docs/a.txt","destination":"/import/docs/a.txt"}
Absolute entry prohibited{"name":"/import/a.txt"}{"accepted":false,"error":"absolute-entry","source":"/import/a.txt"}
Download editable CSV ↓

Where does ../outside.txt resolve, and should it proceed?

Show the worked answer

It resolves to /outside.txt and must be held. Accept contained relative docs/a.txt instead under this contract.

Related resources