feat: migrate opencode storage from JSON files to SQLite #60
Annotations
1 error and 9 warnings
|
SQL Injection vulnerability in DELETE operation:
src/sessions/agents/opencode-storage.ts#L135
The DELETE query uses string interpolation without parameterization. While sessionId comes from function params, lack of consistent parameterization creates injection risk.
|
|
Missing sessionId validation in CLI delete operation:
src/index.ts#L1289
sessionId from CLI is passed directly to deleteOpencodeSession without validation or sanitization. Unlike claude-code sessions (line 1416 in router.ts), no input filtering is applied, allowing arbitrary session IDs to be targeted.
|
|
Path traversal via unchecked homeDir parameter:
src/sessions/agents/opencode-storage.ts#L27
homeDir parameter is used in path construction without validation, allowing potential access to arbitrary database files via path traversal (e.g., '../../malicious').
|
|
Unsafe type assertion after JSON parse:
src/sessions/agents/opencode-storage.ts#L153
safeParse uses 'as T' without validation. Malformed database content could cause runtime errors when code assumes properties exist.
|
|
Silent error handling masks database failures:
src/sessions/agents/opencode-storage.ts#L71
Empty catch blocks in listOpencodeSessions and getOpencodeSessionMessages return empty results without logging, making database errors invisible and hard to debug.
|
|
Silent error handling masks database failures:
src/sessions/agents/opencode-storage.ts#L124
Empty catch blocks in listOpencodeSessions and getOpencodeSessionMessages return empty results without logging, making database errors invisible and hard to debug.
|
|
Database connection leak on error:
src/sessions/agents/opencode-storage.ts#L32
If withDb callback throws before queries execute, database connection may not close properly. While finally block exists, exceptions during db.close() could mask original error.
|
|
Stale hardcoded OpenCode storage paths in parser.ts:
src/shared/constants.ts#L456
parser.ts lines 456 and 519 still reference old path '.local/share/opencode/storage' while constants.ts was updated to '.local/share/opencode'. These appear to be unused dead code functions, but if called will fail to find sessions.
|
|
DELETE operation does not cascade to child tables:
src/worker/session-index.ts#L135
deleteOpencodeSession only deletes from the session table but leaves orphaned records in message and part tables. Without CASCADE constraints or explicit cleanup, deleted sessions leak data.
|
|
Potential orphaned data from incomplete cascade deletion:
src/worker/session-index.ts#L135
DELETE FROM session WHERE id = ? only deletes the session row but doesn't explicitly delete related messages and parts. If DB lacks CASCADE constraints, orphaned data remains.
|