mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-19 11:22:21 +02:00
fix(browse): portable temp paths — TEMP_DIRS allowlist, tmpdir()-based test files
Local path validation now accepts os.tmpdir() alongside the classic /tmp (new TEMP_DIRS in platform.ts): on macOS os.tmpdir() is /var/folders/..., and TMPDIR-honoring CI/sandbox environments point it elsewhere entirely — both are legitimate scratch space. Remote file serving (TEMP_ONLY) stays pinned to TEMP_DIR alone; no change to the exfil boundary. commands.test.ts drops 41 hardcoded /tmp literals for a tmpp() helper on os.tmpdir() (two message assertions now reference the same variable), and path-validation's symlink-escape test targets /etc/hosts instead of /etc/crontab — the target must EXIST for realpath to resolve the link (a dangling target falls back to the link's own path and passes vacuously), and /etc/crontab is absent on Amazon Linux. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
626ebc1ba9
commit
97d33a90ad
@@ -115,7 +115,11 @@ describe('validateOutputPath — symlink resolution', () => {
|
||||
it('blocks symlink inside /tmp pointing outside safe dirs', () => {
|
||||
const linkPath = join(tmpdir(), 'test-output-symlink-' + Date.now() + '.png');
|
||||
try {
|
||||
symlinkSync('/etc/crontab', linkPath);
|
||||
// /etc/hosts, not /etc/crontab: the target must EXIST for realpath to
|
||||
// resolve the link (a dangling target falls back to the link's own
|
||||
// path, which is inside tmp and passes) — and /etc/crontab is absent
|
||||
// on Amazon Linux while /etc/hosts exists everywhere.
|
||||
symlinkSync('/etc/hosts', linkPath);
|
||||
expect(() => validateOutputPath(linkPath)).toThrow(/Path must be within/);
|
||||
} finally {
|
||||
try { unlinkSync(linkPath); } catch {}
|
||||
|
||||
Reference in New Issue
Block a user