Commit Graph
1781 Commits
Author SHA1 Message Date
runstone a440415e86 feat(readonly): add read-only mode for all database connections
## Background
Add a read-only toggle for database connections that blocks all write
operations (INSERT, UPDATE, DELETE, DROP, etc.) when enabled, allowing
only read queries (SELECT, SHOW, EXPLAIN, etc.). Closes #889.

## Changes

### Data Model
- Added `read_only: bool` field to ConnectionConfig (Rust struct, TS
  interfaces, and ConnectionConfigData deserialization layer)
- Used `#[serde(default, skip_serializing_if = "is_false")]` for
  backward/forward compatibility with existing configs

### Frontend UI
- Added "Read Only" checkbox in connection dialog
- 7-language i18n support (en/es/it/pt-BR/zh-CN/zh-TW)

### SQL Classification (query_execution_sql.rs)
- Added `is_write_sql()` with two-layer defense:
  - Layer 1: First-keyword check (must start with known read keyword)
  - Layer 2: Embedded dangerous keyword detection (catches CTE-wrapped
    writes like `WITH ... AS (DELETE FROM ...)`)
  - `FROM` keyword supported as DuckDB SELECT-less syntax indicator
- Added `check_read_only()` returning descriptive error with connection name
- Added 16 unit tests covering: pure reads/writes, CTE, case insensitivity,
  string literal masking, comment stripping, stored procedure calls, edge cases

### SQL Execution Guards (query.rs / transfer.rs)
- Added `check_read_only_for_connection()` and `_multi()` helper functions
  with lazy name clone (only allocates when read_only is true)
- 6 interception points: `do_execute`, MySQL batch, SQL Server batch,
  DuckDB batch, transaction execution, transfer execution

### Non-SQL Write Guards — Tauri Commands
- Added `ensure_connection_writable()` helper (connection.rs)
- Mongo: 6 write entry points (insert/update/delete, single + batch)
- Redis: 15 write entry points (SET, DEL, HSET, HDEL, LPUSH, LSET, LREM,
  SADD, SREM, ZADD, ZREM, EXPIRE, FLUSHDB, delete_keys, execute_command)
  - execute_command uses RedisCommandSafety classification to allow
    safe read commands through raw command interface
- etcd: 2 write entry points (put, delete)
- sql_file: SQL file execution guarded
- MCP Bridge: 4 write entry points (Insert/Update/Delete/SQL query)

### Non-SQL Write Guards — Web API
- Local `ensure_writable()` helper in each route module
- Redis: 12 write endpoints including classified execute_command
- Mongo: 6 write endpoints
- etcd: 2 write endpoints
- sql_file, table_import, transfer: early rejection

### Test Updates
- Updated ConnectionConfig construction in 7 test files with
  `read_only: false` initialization

## Defense-in-Depth
- Layer 1: Command/Route-level early rejection (saves resources)
- Layer 2: Core SQL classifier (`is_write_sql` — first keyword + embedded scan)
- Layer 3: Core execution-time interception (do_execute/transfer/transaction)
2026-06-10 10:58:52 +08:00
二丫讲梵 7798f2231e fix(grid): 修复右键菜单选择时的单元格清理逻辑
感谢 @eryajf 的贡献!
2026-06-09 15:45:20 +08:00
t8y2 9c8a1c62b7 fix(grid): preserve transpose view state on data refresh 2026-06-09 14:56:41 +08:00
t8y2 6bc3068069 fix(grid): row detail now respects hidden column state
Row detail dialog was using displayableColumnIndexes instead of
visibleColumnIndexes, causing columns hidden via "hide null columns"
or manual hiding to still appear in the detail view.
2026-06-09 14:43:42 +08:00
t8y2 a13fcb9964 feat(redis): add JSON format/compress buttons in raw content view 2026-06-09 14:20:58 +08:00
t8y2 fdc4214bbb fix(jdbc): handle UnsupportedOperationException from Hive-based JDBC drivers
Catch UnsupportedOperationException alongside SQLFeatureNotSupportedException
and AbstractMethodError in DbxJdbcPlugin. Hive-based drivers (e.g., Transwarp
Inceptor) throw UnsupportedOperationException for unsupported optional JDBC
methods instead of the standard SQLFeatureNotSupportedException. Since it is
a RuntimeException, it previously propagated uncaught and crashed the connection.

Fixes #912
2026-06-09 14:11:33 +08:00
t8y2 29bfe3f1c3 feat(mcp): enforce visible_databases filter in MCP bridge handlers
Add check_visible_database() helper and apply it to list_tables,
describe_table, and execute_query handlers to prevent MCP tools
from accessing databases outside the user's visibility whitelist.
2026-06-09 13:28:38 +08:00
t8y2 df4d590440 fix(navicat): improve NCX connection type detection with numeric codes and port fallback
- Add Navicat numeric ConnType codes (1-9) to typeMap for correct DB type mapping
- Add port-based inference fallback (6379→Redis, 27017→MongoDB, etc.)
- Expand typeMap with ClickHouse, Snowflake, KingbaseES, GaussDB, OceanBase
- Skip unrecognized connections instead of silently falling back to MySQL
2026-06-09 13:20:29 +08:00
t8y2 ada58dd88f fix(redis): enhance hash value text extraction for search
Extract field names and values from hash-type arrays in
redis_search_value_text() instead of serializing the whole JSON,
so that value search can match individual hash fields and values.
2026-06-09 13:15:20 +08:00
t8y2 b2b1a7365b feat(connection): add custom color picker for connection editing (#913)
- Extend hexToRgba() to handle rgba/rgb input passthrough
- Add pipette button with native color picker + text input in popover
- Custom color and preset colors are mutually exclusive
2026-06-09 13:03:11 +08:00
t8y2 403681e1ed fix: prevent SQL autocomplete popup overlap 2026-06-09 12:43:57 +08:00
t8y2 727a0a06e0 docs: add Product Hunt badge and dbx-agents link 2026-06-09 12:41:12 +08:00
Holata Seminole 70dad4e00b fix(mysql): require TLS for TiDB Cloud connections (#911)
Thanks!
2026-06-09 12:06:38 +08:00
SuLea-IT 5138c1a702 Add configurable SQL formatter settings (#908)
Thanks!
2026-06-09 12:05:17 +08:00
二丫讲梵 f8834aee09 feat(grid): 添加多行转置功能和相关界面支持 (#909)
- 新增多行转置状态管理
- 更新转置记录索引计算逻辑
- 增加多行转置切换开关及提示信息
- 更新国际化文件以支持多语言
2026-06-09 12:02:45 +08:00
Yong Studtandt8y2 98342184af feat(elasticsearch): translate SELECT * WHERE to ES DSL in-process (#910)
* feat(elasticsearch): translate SELECT * WHERE to ES DSL in-process

`SELECT *` with clauses our hand-written parser doesn't cover (WHERE, IN, BETWEEN, LIKE, IS NULL, ...) is now parsed with sqlparser-rs and translated to a /_search body locally — we no longer hand it off to ES's _sql endpoint.

Why: _sql refuses several common shapes — LIKE on a text field with no .keyword sub-field (the typical filebeat / log-shipper mapping), and SELECT * over docs containing an array field like host.ip. Both translate cleanly to raw DSL. Going through _sql/translate doesn't help either — that lives in the same ES SQL engine and inherits the same restrictions.

Translation:
- field = 'v'                  → term
- field LIKE 'prefix%'         → prefix (optimised)
- field LIKE '%x%'             → wildcard, case_insensitive
- field IN ('a','b')           → terms
- field BETWEEN a AND b        → range gte/lte
- field >/<>=/<=               → range
- field IS NULL / IS NOT NULL  → bool.must_not.exists / exists
- A AND B AND C                → flattened bool.must
- A OR B                       → bool.should, minimum_should_match: 1
- NOT A                        → bool.must_not
- ORDER BY f ASC|DESC          → sort
- LIMIT N OFFSET M             → size / from

SQL LIKE patterns: % → *, _ → ?, backslash escapes preserved, user-written * / ? in patterns escaped back to literals.

Input runs through the existing adapt_elasticsearch_sql_query first so hyphenated indices (filebeat-7.17.1-…) and @timestamp-style identifiers reach sqlparser as double-quoted identifiers.

Also: 0-hit _search bodies now surface as an empty grid (with an _id column placeholder) instead of falling back to the raw status/response JSON view — `.filter(|h| !h.is_empty())` was masking the empty-result case.

Adds docs/screenshot-es-sql-where.png demonstrating SELECT * with WHERE log.offset = N on a long field — would 400 through _sql, works through the in-process translator.

Follows up on #874.

* chore(test): fill ConnectionConfig::idle_timeout_secs in test fixtures

After the new pub idle_timeout_secs: u64 field was added to ConnectionConfig, 11 #[cfg(test)] / tests fixture constructors still built the struct without it, so `cargo test --workspace --locked` and `cargo clippy --all-targets` would fail with E0063 against the test profile. `cargo check` alone passed because the lib path doesn't compile tests.

Filled in with default_idle_timeout_secs() (matches the field's own #[serde(default = …)]) so future bumps to the default flow through automatically.

---------

Co-authored-by: t8y2 <1156263951@qq.com>
2026-06-09 11:59:49 +08:00
t8y2 2a7b26baad fix: add missing idle_timeout_secs in ConnectionConfig constructors and fix clippy warnings 2026-06-09 11:56:39 +08:00
t8y2 e76a223e8a fix(redis): allow resizing zset score column 2026-06-09 11:56:25 +08:00
t8y2 41c696ef22 perf(editor): optimize sql completion metadata lookup 2026-06-09 11:09:12 +08:00
t8y2 d4c87f5a4c fix(ui): increase shortcut pill width to prevent text clipping on Windows 2026-06-09 10:41:19 +08:00
t8y2 def1cacf77 feat(ui): add Mod+B shortcut to toggle sidebar 2026-06-09 10:38:03 +08:00
James-LeongandClaude Opus 4.7 171c7cd8d7 fix(ssh): prevent duplicate SSH tunnels from concurrent pool creation (#891)
start_tunnel() and start_chain() had a check-then-act race condition:
multiple concurrent callers could all see an empty cache and each
spawn a new SSH tunnel. The tunnel that lost the insert race was
orphaned, causing queries routed through it to fail.

Use double-check locking with stale entry eviction: hold the lock for
the cache lookup, release it during the slow SSH handshake, then
re-check under the lock before inserting. If another caller already
created the tunnel, abort the duplicate and return the existing port.

Also check handle liveness on cache hits so that callers don't get a
dead port back when the background tunnel task has exited.

Add a matching re-check in the MongoDB connection pool creation path.

Add idle_timeout_secs connection option (default 60s) to preempt
server-side connection idle timeouts that cause "unexpected end of
file" errors on pooled MongoDB connections.

Reject MongoDB queries in the generic SQL execution path before any
pool or session-key creation. Previously, a typo in a MongoDB shell
command would fall through to executeMulti / execute_sql_statement,
which called get_or_create_pool_for_session and leaked a session-scoped
MongoDB Client (and SSH tunnel resources) before eventually returning
"Use MongoDB-specific commands".

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-09 10:29:42 +08:00
DengQingNiananddqn 32164d5aea feat(grid): add layer preview for geometry columns with Leaflet map (#892)
* feat(grid): add layer preview for geometry columns with Leaflet map

* fix: restore dev:backend script with env vars and cargo watch

* chore: update pnpm-lock.yaml for leaflet and dom-to-image-more dependencies

---------

Co-authored-by: dqn <someonegdeng@qq.com>
2026-06-09 10:12:56 +08:00
DengQingNiananddqn 65d7a0ab8f feat(structure): add DDL tab to table structure editor (#893)
Closes #836

Co-authored-by: dqn <someonegdeng@qq.com>
2026-06-09 10:12:22 +08:00
t8y2 80895fe273 fix(mongodb): support replica set connection URL parsing and timeout
Frontend: add regex-based MongoDB URL parser to handle multi-host URIs
that the WHATWG URL parser rejects. Backend: separate
server_selection_timeout from connect_timeout for multi-host URIs to
prevent topology discovery from being cancelled by tokio timeout.
2026-06-09 01:02:11 +08:00
t8y2 0ce6fde347 fix(grid): unify selected cell border thickness in DOM and canvas mode
DOM mode: replace box-shadow with outline to avoid stacking with row border-b.
Canvas mode: draw row border before selected cell overlay so selection uses
uniform color on all four sides; clamp top edge to prevent canvas clipping.
2026-06-09 01:01:50 +08:00
t8y2 45a6bb8a58 fix: parse PG brace-style array text in cell coercion to prevent false dirty
coercePostgresArrayValue() only handled JSON [...] format but editor
outputs PG {...} format.  When the user entered and exited edit mode
without changes, the string "{1,2,3}" failed to parse back to an
array, creating a false dirty detection via strict equality.

Add parsePostgresArrayText() recursive descent parser and return
oldValue reference when parsed result is equivalent.
2026-06-09 01:00:19 +08:00
t8y2 619573a69d fix(oracle): skip SQL pagination clauses for Oracle 11g compatibility
Oracle 11g does not support FETCH FIRST / LIMIT syntax. Skip appending
pagination clauses at SQL level and rely on JDBC setMaxRows for row
limiting, which already works across all Oracle versions.
2026-06-09 00:44:20 +08:00
t8y2 025a4fdcce fix: support tree-schema default DB selection in AI assistant 2026-06-09 00:44:04 +08:00
t8y2 03ade2ebba fix: allow custom theme editor to scroll 2026-06-09 00:25:11 +08:00
t8y2 c35929da7c fix(connection): clear errors after disconnect 2026-06-08 23:52:16 +08:00
t8y2 a414183ff0 fix(editor): scope SQL formatting to active tab 2026-06-08 23:08:50 +08:00
t8y2 befee2fd4c feat(postgres): support sequence objects 2026-06-08 22:54:14 +08:00
二丫讲梵 178a800ce8 ✨ feat(shortcuts): 添加打开设置的键盘快捷键
新增 openSettings 快捷键,默认绑定 Mod+,,用于触发设置对话框。

包含所有语言包的翻译、键盘快捷键文档更新,以及测试用例。
2026-06-08 21:52:26 +08:00
t8y2 19139a9b34 feat(docs): add offline driver downloads 2026-06-08 21:50:00 +08:00
t8y2 87b8f1f462 fix(ai): support proxied API channels 2026-06-08 20:32:54 +08:00
二丫讲梵 2db46f10ff 🐛 fix(connectionStore): 修复分组连接时树节点的更新逻辑
确保连接到分组中的连接时,原地更新现有节点属性,避免添加重复的根节点。

使用 findNode 递归搜索替代 findIndex 只搜索根级别。原地修改节点属性而非替换整个对象,保留父子引用关系。
2026-06-08 20:10:08 +08:00
t8y2 9dfc2ba294 feat: support H2 file connections 2026-06-08 20:09:27 +08:00
t8y2 7a2ed233be ci(release): add Windows ARM64 build target
- Add aarch64-pc-windows-msvc to release build matrix
- Make portable ZIP arch dynamic (x64/arm64)
- Update Scoop manifest for arm64 architecture
2026-06-08 19:18:53 +08:00
t8y2 a3f045822c fix(dialog): adjust layout for DialogContent component 2026-06-08 18:45:30 +08:00
t8y2 5ec50ba15b fix(postgres): support editing array cells 2026-06-08 18:31:05 +08:00
Yong Studt 2628fb8374 feat(elasticsearch): add SQL-model execution with mapping-aware completion
- Route SELECT * FROM <index> through /_search for simple browses; aggregates/projections stay on /_sql
- Drive completion columns from /_mapping (flattened dotted fields, multi-fields)
- Switch editor completion to SQL when the active statement starts with SELECT/WITH on ES
- Skip generic SQL semantic diagnostics for ES (hyphenated wildcard indices caused 500s)
- Wire ES into server-side pagination plan; derive completion context from line blocks
- Fix result-grid pagination exceeding in-memory result sets (allRowsLoaded)
2026-06-08 17:53:05 +08:00
t8y2 465ed195cf fix(sql): decode opened SQL files with charset fallback 2026-06-08 17:45:09 +08:00
t8y2 3fc6c0eaba fix(ai): use local provider icons 2026-06-08 17:11:12 +08:00
t8y2 531634d9b6 fix(import): accept JSON files with UTF-8 BOM 2026-06-08 17:07:17 +08:00
t8y2 433c38473a fix(goldendb): quote identifiers with backticks 2026-06-08 16:42:45 +08:00
t8y2 83c3be5a67 fix(trino): pass SSL options to agent JDBC URL 2026-06-08 16:25:56 +08:00
t8y2 90a1316037 fix(jdbc): avoid IRIS max rows SQL rewrite 2026-06-08 16:17:27 +08:00
t8y2 ab739e9dcb fix(duckdb): render complex values as json 2026-06-08 14:45:26 +08:00
t8y2 2b0af57be8 fix(mysql): handle common connection URL params 2026-06-08 14:34:56 +08:00