Import ISA Project Format 1.1.0
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createProjectManifest, parseProjectManifest, validateArchivePath, extensionDataPath } from '../src/index.js';
|
||||
|
||||
test('reject archive traversal and cross-platform unsafe paths before storage', () => {
|
||||
for (const path of ['../project.json', '/project.json', 'a/../../b', 'a\\..\\b', 'C:/x', 'a//b', './x', 'a/./b', 'a\0b', 'a\nb', 'a/NUL.txt', 'a/file.', 'a/file ']) {
|
||||
assert.throws(() => validateArchivePath(path), { name: 'TypeError' }, path);
|
||||
}
|
||||
assert.equal(validateArchivePath('assets/meeting audio.ogg'), 'assets/meeting audio.ogg');
|
||||
assert.equal(extensionDataPath('isa-quote', 'state/current.json'), 'extensions/isa-quote/state/current.json');
|
||||
assert.throws(() => extensionDataPath('../quote', 'x'));
|
||||
});
|
||||
|
||||
test('preserve unknown manifest data without sharing mutable references', () => {
|
||||
const manifest = { ...createProjectManifest({ id: 'project-1', name: 'Example' }), future: { value: 1 } };
|
||||
const parsed = parseProjectManifest(manifest);
|
||||
parsed.future.value = 2;
|
||||
assert.equal(manifest.future.value, 1);
|
||||
assert.throws(() => parseProjectManifest({ ...manifest, formatVersion: 2 }));
|
||||
assert.throws(() => parseProjectManifest({ ...manifest, createdAt: 'yesterday' }));
|
||||
assert.throws(() => parseProjectManifest({ ...manifest, createdAt: '2026-02-30T00:00:00Z' }));
|
||||
});
|
||||
Reference in New Issue
Block a user