Security: Hardcoded absolute path in drizzle.config.ts database URL#948
Security: Hardcoded absolute path in drizzle.config.ts database URL#948tomaioo wants to merge 6 commits into
Conversation
The SQLite database configuration contains a hardcoded absolute path '/home/thdxr/.local/share/opencode/opencode.db' pointing to a specific user's home directory. This will cause failures on any other machine and may leak a developer's username. The path should be configurable via environment variable or derived from a standard location like XDG directories. Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
📝 WalkthroughWalkthroughThe Drizzle config in ChangesDynamic DB URL in Drizzle config
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/opencode/drizzle.config.ts`:
- Line 9: The drizzle.config.ts file uses os.homedir() on line 9 but does not
import the os module, causing a ReferenceError at runtime. Add the missing
import statement for the os module at the top of the file (alongside the
existing path import) so that os.homedir() can be properly resolved.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e63e57f2-9e67-408e-8633-95a824e4fc12
📒 Files selected for processing (1)
packages/opencode/drizzle.config.ts
dev-punia-altimate
left a comment
There was a problem hiding this comment.
🤖 Code Review — OpenCodeReview (Gemini) — 1 finding(s)
- 1 anchored to a line (posted inline when the comment stream is on)
- 0 without a line anchor
All findings (full text)
1. packages/opencode/drizzle.config.ts (L1)
[🔴 HIGH] The os module is missing an import. Please add import os from "os" since os.homedir() is used below.
Suggested change:
import os from "os"
import path from "path"
| @@ -1,10 +1,11 @@ | |||
| import path from "path" | |||
There was a problem hiding this comment.
[🔴 HIGH] The os module is missing an import. Please add import os from "os" since os.homedir() is used below.
Suggested change:
| import path from "path" | |
| import os from "os" | |
| import path from "path" |
<!-- bf-key:packages/opencode/ Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
2 similar comments
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
🤖 Code Review — OpenCodeReview (Gemini) — No Issues FoundNo comments generated. Looks good to me. |
<!-- bf-key:packages/opencode/ Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
2 similar comments
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/opencode/drizzle.config.ts`:
- Around line 1-3: Remove the invalid plain text content from the beginning of
the drizzle.config.ts file (lines 1-3). This non-TypeScript content is causing
all 17 Biome parse errors. Delete the metadata or commentary text and ensure the
file starts directly with the import statements like import os from "os" and
import path from "path", so the file begins with valid TypeScript code.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 06b27565-8054-4aa5-9171-aaa9116ba79d
📒 Files selected for processing (1)
packages/opencode/drizzle.config.ts
<!-- bf-key:packages/opencode/ Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
2 similar comments
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
<!-- bf-key:packages/opencode/ Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
1 similar comment
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
❌ Tests — Failures DetectedTypeScript — 15 failure(s)
Next StepPlease address the failing cases above and re-run verification. cc @tomaioo |
<!-- bf-key:packages/opencode/ Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
1 similar comment
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
Summary
Security: Hardcoded absolute path in drizzle.config.ts database URL
Problem
Severity:
Medium| File:packages/opencode/drizzle.config.ts:L7The SQLite database configuration contains a hardcoded absolute path '/home/thdxr/.local/share/opencode/opencode.db' pointing to a specific user's home directory. This will cause failures on any other machine and may leak a developer's username. The path should be configurable via environment variable or derived from a standard location like XDG directories.
Solution
Replace hardcoded path with environment variable or XDG-compliant path resolution:
url: process.env.OPENCODE_DB_URL || path.join(os.homedir(), '.local', 'share', 'opencode', 'opencode.db')Changes
packages/opencode/drizzle.config.ts(modified)Summary by cubic
Replaced the hardcoded SQLite DB path in
packages/opencode/drizzle.config.tswith a configurable URL. Prevents machine-specific failures and username leaks, defaulting to a standard local path.Bug Fixes
dbCredentials.urlnow usesprocess.env.OPENCODE_DB_URLor falls back topath.join(os.homedir(), ".local", "share", "opencode", "opencode.db").Migration
OPENCODE_DB_URLto customize DB location, or ensure~/.local/share/opencodeexists and is writable.Written for commit 259217b. Summary will update on new commits.
Summary by CodeRabbit
OPENCODE_DB_URLwhen available.OPENCODE_DB_URLisn’t set.