mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-08-28 05:25:25 +00:00
* Fix MCP startup transport compatibility * Preserve CLI flags in MCP startup fix * Harden MCP transport error handling * Harden transport security and improve type safety Transport hardening: - Add MAX_BUFFER_SIZE (10 MB) cap to prevent OOM from oversized Content-Length or unbounded newline-delimited input - Replace recursive readNewlineMessage with iterative loop to prevent stack overflow from consecutive empty lines - Tighten looksLikeContentLength to require 14+ bytes before matching - Add closed-state guard and error handling to send() - Simplify processReadBuffer loop to break on error - Fix loose equality (==) to strict (===) - Widen constructor param types to ReadableStream/WritableStream Type safety: - Constrain createLazyAction generics so export name is validated against the module's actual exports at compile time - Use proper type guard instead of lint suppression - Fix test tsconfig type errors Regression tests for all hardening fixes (13 tests passing). --------- Co-authored-by: Gergo Magyar <gergomagyar@icloud.com>
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import { spawnSync } from 'node:child_process';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
const testDir = path.dirname(fileURLToPath(import.meta.url));
|
|
const repoRoot = path.resolve(testDir, '../..');
|
|
const cliEntry = path.join(repoRoot, 'src/cli/index.ts');
|
|
|
|
function runHelp(command: string) {
|
|
return spawnSync(process.execPath, ['--import', 'tsx', cliEntry, command, '--help'], {
|
|
cwd: repoRoot,
|
|
encoding: 'utf8',
|
|
});
|
|
}
|
|
|
|
describe('CLI help surface', () => {
|
|
it('query help keeps advanced search options without importing analyze deps', () => {
|
|
const result = runHelp('query');
|
|
|
|
expect(result.status).toBe(0);
|
|
expect(result.stdout).toContain('--context <text>');
|
|
expect(result.stdout).toContain('--goal <text>');
|
|
expect(result.stdout).toContain('--content');
|
|
expect(result.stderr).not.toContain('tree-sitter-kotlin');
|
|
});
|
|
|
|
it('context help keeps optional name and disambiguation flags', () => {
|
|
const result = runHelp('context');
|
|
|
|
expect(result.status).toBe(0);
|
|
expect(result.stdout).toContain('context [options] [name]');
|
|
expect(result.stdout).toContain('--uid <uid>');
|
|
expect(result.stdout).toContain('--file <path>');
|
|
});
|
|
|
|
it('impact help keeps repo and include-tests flags', () => {
|
|
const result = runHelp('impact');
|
|
|
|
expect(result.status).toBe(0);
|
|
expect(result.stdout).toContain('--depth <n>');
|
|
expect(result.stdout).toContain('--include-tests');
|
|
expect(result.stdout).toContain('--repo <name>');
|
|
});
|
|
});
|