fix(storage): retain explicit junction rejection when binding physical data roots
This commit is contained in:
@@ -25,6 +25,19 @@ test('a Windows virtual data-directory name binds new storage and credentials to
|
||||
assert.equal(fs.existsSync(path.join(physical, 'workbench.sqlite')), true); assert.deepEqual(fs.readdirSync(logical), []);
|
||||
});
|
||||
|
||||
test('physical data-root adoption still rejects explicit junctions at the directory or any ancestor', t => {
|
||||
const f = fixture(t), direct = path.join(f.root, 'direct-data-link'), parent = path.join(f.root, 'parent-link');
|
||||
const target = path.join(f.root, 'parent-target'); fs.mkdirSync(path.join(target, 'data'), { recursive: true });
|
||||
fs.symlinkSync(f.data, direct, 'junction'); fs.symlinkSync(target, parent, 'junction');
|
||||
const database = f.store.storage.database, original = f.store.directory;
|
||||
for (const alias of [direct, path.join(parent, 'data')]) {
|
||||
assert.throws(() => new Store(alias), /符号链接或目录联接/);
|
||||
f.store.directory = alias; assert.throws(() => f.store.ensureStorage(), /符号链接或目录联接/);
|
||||
assert.equal(f.store.directory, alias); assert.equal(f.store.storage.database, database);
|
||||
}
|
||||
f.store.directory = original; assert.deepEqual(fs.readdirSync(path.join(target, 'data')), []);
|
||||
});
|
||||
|
||||
test('actual Windows CurrentUser DPAPI roundtrips owned UTF-8 and rejects damaged bytes and wrong entropy', () => {
|
||||
const plain = Buffer.from('自有测试凭据 owned-key-only', 'utf8'), entropy = randomBytes(32), encrypted = protectCredential(plain, entropy);
|
||||
assert.notDeepEqual(encrypted, plain); assert.deepEqual(unprotectCredential(encrypted, entropy), plain);
|
||||
|
||||
Reference in New Issue
Block a user