mirror of
https://github.com/qwibitai/nanoclaw.git
synced 2026-06-04 10:14:47 +08:00
9486d56b01
- Move all v1 files (index, router, container-runner, db, ipc, types, logger, channels/registry, and all utilities) to src/v1/ as a fully self-contained archive with no shared dependencies - Rename v2 files to remove -v2 suffix (index-v2.ts → index.ts, etc.) - Update all imports across v2 source, tests, and setup files - Migrate shared utilities (config, env, container-runtime, mount-security, timezone, group-folder) from pino logger to v2 log module - Migrate setup/ files from logger to log with argument order swap - Container agent-runner: move v1 entry to v1/, rename v2 to index.ts - Update setup skill to offer all 13 v2 channels - Install all Chat SDK adapter packages - dist/index.js now runs v2; dist/v1/index.js runs v1 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import path from 'path';
|
|
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
import { isValidGroupFolder, resolveGroupFolderPath, resolveGroupIpcPath } from './group-folder.js';
|
|
|
|
describe('group folder validation', () => {
|
|
it('accepts normal group folder names', () => {
|
|
expect(isValidGroupFolder('main')).toBe(true);
|
|
expect(isValidGroupFolder('family-chat')).toBe(true);
|
|
expect(isValidGroupFolder('Team_42')).toBe(true);
|
|
});
|
|
|
|
it('rejects traversal and reserved names', () => {
|
|
expect(isValidGroupFolder('../../etc')).toBe(false);
|
|
expect(isValidGroupFolder('/tmp')).toBe(false);
|
|
expect(isValidGroupFolder('global')).toBe(false);
|
|
expect(isValidGroupFolder('')).toBe(false);
|
|
});
|
|
|
|
it('resolves safe paths under groups directory', () => {
|
|
const resolved = resolveGroupFolderPath('family-chat');
|
|
expect(resolved.endsWith(`${path.sep}groups${path.sep}family-chat`)).toBe(true);
|
|
});
|
|
|
|
it('resolves safe paths under data ipc directory', () => {
|
|
const resolved = resolveGroupIpcPath('family-chat');
|
|
expect(resolved.endsWith(`${path.sep}data${path.sep}ipc${path.sep}family-chat`)).toBe(true);
|
|
});
|
|
|
|
it('throws for unsafe folder names', () => {
|
|
expect(() => resolveGroupFolderPath('../../etc')).toThrow();
|
|
expect(() => resolveGroupIpcPath('/tmp')).toThrow();
|
|
});
|
|
});
|