Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Security

- Database paths with `..` traversal sequences are now rejected in `DatabaseConnection.initialize` and `DatabaseConnection.open`, and non-`.db` extensions are blocked, so a caller cannot be tricked into opening an arbitrary file as a SQLite database.
- Every MCP tool call is now logged to stderr with a timestamp, process PID, and tool name, making unexpected tool invocations visible in daemon logs.
- The daemon socket `chmod 0600` failure is now surfaced as a warning to stderr instead of being silently swallowed, so permission issues on shared filesystems don't go unnoticed.

### New Features

- Cross-file impact and blast-radius coverage now spans **all 22 supported languages and 14 web frameworks**, each validated on a real-world repo — see the new coverage table in the README. This release ships the cross-file resolution behind it, including Lua and Luau `require`, Shopify OS 2.0 Liquid section templates, Delphi form code-behind, Rust cross-module calls and Rocket route macros, Swift Fluent relationships, and the SvelteKit / Nuxt / Vapor / Axum route conventions. The residual everywhere is genuine static-analysis frontiers (runtime dispatch, reflection / DI, framework-convention entry points), never hidden.
Expand Down
11 changes: 11 additions & 0 deletions src/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ import { runMigrations, getCurrentVersion, CURRENT_SCHEMA_VERSION } from './migr

export { SqliteDatabase, SqliteBackend } from './sqlite-adapter';

function validateDbPath(dbPath: string): void {
if (dbPath.includes('..')) {
throw new Error(`Invalid database path: path traversal not allowed`);
}
if (path.extname(path.resolve(dbPath)) !== '.db') {
throw new Error(`Invalid database path: must have .db extension`);
}
}

/**
* Apply connection-level PRAGMAs. Shared by `initialize` and `open` so the two
* paths can't drift.
Expand Down Expand Up @@ -54,6 +63,7 @@ export class DatabaseConnection {
* Initialize a new database at the given path
*/
static initialize(dbPath: string): DatabaseConnection {
validateDbPath(dbPath);
// Ensure parent directory exists
const dir = path.dirname(dbPath);
if (!fs.existsSync(dir)) {
Expand Down Expand Up @@ -85,6 +95,7 @@ export class DatabaseConnection {
* Open an existing database
*/
static open(dbPath: string): DatabaseConnection {
validateDbPath(dbPath);
if (!fs.existsSync(dbPath)) {
throw new Error(`Database not found: ${dbPath}`);
}
Expand Down
4 changes: 3 additions & 1 deletion src/mcp/daemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ export class Daemon {
// POSIX: tighten permissions to user-only — the socket lives under
// `.codegraph/`, which is git-ignored but may be on a shared FS.
if (process.platform !== 'win32') {
try { fs.chmodSync(this.socketPath, 0o600); } catch { /* best-effort */ }
try { fs.chmodSync(this.socketPath, 0o600); } catch (err) {
process.stderr.write(`[CodeGraph daemon] warning: failed to restrict socket permissions: ${err instanceof Error ? err.message : String(err)}\n`);
}
}
this.server = server;
resolve();
Expand Down
1 change: 1 addition & 0 deletions src/mcp/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ export class MCPSession {

await this.retryInitIfNeeded();

process.stderr.write(`[CodeGraph MCP] ${new Date().toISOString()} tool_call pid=${process.pid} tool=${toolName}\n`);
const result = await this.engine.getToolHandler().execute(toolName, toolArgs);
this.transport.sendResult(request.id, result);
}
Expand Down