Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(desktop): add raw password item to copy connection info

Jinpy97686fbc7c80
diff --git a/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue b/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue
index 0cae18cb03..34c11fbd66 100644
--- a/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue
+++ b/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue
@@ -2837,6 +2837,7 @@ const CONNECTION_URL_COPY_LABEL_KEYS: Record<ConnectionUrlCopyFormat, string> =
dsn: "contextMenu.copyDsn",
dsnWithPassword: "contextMenu.copyDsnWithPassword",
psqlCommand: "contextMenu.copyPsqlCommand",
+ password: "contextMenu.copyPasswordText",
};
/**
diff --git a/apps/desktop/src/i18n/locales/az.ts b/apps/desktop/src/i18n/locales/az.ts
index 9c9d3142cb..fe1bffbca6 100644
--- a/apps/desktop/src/i18n/locales/az.ts
+++ b/apps/desktop/src/i18n/locales/az.ts
@@ -4096,6 +4096,7 @@ export default withEnglishFallback({
copyDsn: "DSN (key=value)",
copyDsnWithPassword: "DSN (parol ilə)",
copyPsqlCommand: "psql əmri",
+ copyPasswordText: "Parol (düz mətn)",
copyPasswordConfirmTitle: "Parol ilə kopyala",
copyPasswordConfirmMessage: "Kopyalanan mətndə saxlanılan parol açıq şəkildə olacaq. Davam edilsin?",
copyPasswordConfirmAction: "Kopyala",
diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts
index 58726f358c..5afd7640a8 100644
--- a/apps/desktop/src/i18n/locales/en.ts
+++ b/apps/desktop/src/i18n/locales/en.ts
@@ -5053,6 +5053,7 @@ export default {
copyDsn: "DSN (key=value)",
copyDsnWithPassword: "DSN (with password)",
copyPsqlCommand: "psql Command",
+ copyPasswordText: "Password (plain)",
copyPasswordConfirmTitle: "Copy with Password",
copyPasswordConfirmMessage: "The copied text will contain the stored password in plain text. Continue?",
copyPasswordConfirmAction: "Copy",
diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts
index e549034f15..acc3ef227b 100644
--- a/apps/desktop/src/i18n/locales/es.ts
+++ b/apps/desktop/src/i18n/locales/es.ts
@@ -5127,6 +5127,7 @@ export default withEnglishFallback({
copyPasswordConfirmTitle: "Copiar con contraseña",
copyPasswordConfirmMessage: "El texto copiado contendrá la contraseña guardada en texto sin formato. ¿Continuar?",
copyPasswordConfirmAction: "Copiar",
+ copyPasswordText: "Contraseña (texto original)",
},
visibleDatabases: {
title: "Bases de datos visibles",
diff --git a/apps/desktop/src/i18n/locales/id.ts b/apps/desktop/src/i18n/locales/id.ts
index 03602109e2..3535ff4918 100644
--- a/apps/desktop/src/i18n/locales/id.ts
+++ b/apps/desktop/src/i18n/locales/id.ts
@@ -4066,6 +4066,7 @@ export default withEnglishFallback({
copyDsn: "DSN (key=value)",
copyDsnWithPassword: "DSN (dengan kata sandi)",
copyPsqlCommand: "Perintah psql",
+ copyPasswordText: "Kata sandi (teks biasa)",
copyPasswordConfirmTitle: "Salin dengan Kata Sandi",
copyPasswordConfirmMessage: "Teks yang disalin akan berisi kata sandi tersimpan dalam teks biasa. Lanjutkan?",
copyPasswordConfirmAction: "Salin",
diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.ts
index 4258a98021..3750ecc932 100644
--- a/apps/desktop/src/i18n/locales/it.ts
+++ b/apps/desktop/src/i18n/locales/it.ts
@@ -4947,6 +4947,7 @@ export default withEnglishFallback({
disableTrigger: "Disabilita trigger",
enableTriggerSuccess: "Trigger «{name}» abilitato",
disableTriggerSuccess: "Trigger «{name}» disabilitato",
+ copyPasswordText: "Password (testo originale)",
},
visibleDatabases: {
title: "Database Visibili",
diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.ts
index 67ed42bd63..56052e4f4e 100644
--- a/apps/desktop/src/i18n/locales/ja.ts
+++ b/apps/desktop/src/i18n/locales/ja.ts
@@ -4970,6 +4970,7 @@ export default withEnglishFallback({
disableTrigger: "トリガーを無効化",
enableTriggerSuccess: "トリガー「{name}」を有効化しました",
disableTriggerSuccess: "トリガー「{name}」を無効化しました",
+ copyPasswordText: "パスワード(原文)",
},
visibleDatabases: {
title: "表示するデータベース",
diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.ts
index 7129832b59..04c96f7f12 100644
--- a/apps/desktop/src/i18n/locales/ko.ts
+++ b/apps/desktop/src/i18n/locales/ko.ts
@@ -4882,6 +4882,7 @@ export default withEnglishFallback({
disableTrigger: "트리거 비활성화",
enableTriggerSuccess: "트리거 '{name}'을(를) 활성화했습니다",
disableTriggerSuccess: "트리거 '{name}'을(를) 비활성화했습니다",
+ copyPasswordText: "비밀번호(원문)",
},
visibleDatabases: {
title: "표시할 데이터베이스",
diff --git a/apps/desktop/src/i18n/locales/pl.ts b/apps/desktop/src/i18n/locales/pl.ts
index af4e53886c..3091457c5a 100644
--- a/apps/desktop/src/i18n/locales/pl.ts
+++ b/apps/desktop/src/i18n/locales/pl.ts
@@ -4128,6 +4128,7 @@ export default withEnglishFallback({
copyDsn: "DSN (klucz=wartość)",
copyDsnWithPassword: "DSN (z hasłem)",
copyPsqlCommand: "Polecenie psql",
+ copyPasswordText: "Hasło (jawny tekst)",
copyPasswordConfirmTitle: "Kopiuj z hasłem",
copyPasswordConfirmMessage: "Skopiowany tekst będzie zawierał zapisane hasło w postaci jawnej. Kontynuować?",
copyPasswordConfirmAction: "Kopiuj",
diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.ts
index fbd876e3a7..25fa843c56 100644
--- a/apps/desktop/src/i18n/locales/pt-BR.ts
+++ b/apps/desktop/src/i18n/locales/pt-BR.ts
@@ -4947,6 +4947,7 @@ export default withEnglishFallback({
disableTrigger: "Desativar trigger",
enableTriggerSuccess: 'Trigger "{name}" ativado',
disableTriggerSuccess: 'Trigger "{name}" desativado',
+ copyPasswordText: "Senha (texto original)",
},
visibleDatabases: {
title: "Bancos de dados visíveis",
diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.ts
index f55a4115e3..40eb94c357 100644
--- a/apps/desktop/src/i18n/locales/ru.ts
+++ b/apps/desktop/src/i18n/locales/ru.ts
@@ -5067,6 +5067,7 @@ export default withEnglishFallback({
disableTrigger: "Отключить триггер",
enableTriggerSuccess: "Триггер «{name}» включён",
disableTriggerSuccess: "Триггер «{name}» отключён",
+ copyPasswordText: "Пароль (исходный текст)",
},
visibleDatabases: {
title: "Видимые базы данных",
diff --git a/apps/desktop/src/i18n/locales/th.ts b/apps/desktop/src/i18n/locales/th.ts
index fc1781c383..21efe0b449 100644
--- a/apps/desktop/src/i18n/locales/th.ts
+++ b/apps/desktop/src/i18n/locales/th.ts
@@ -5242,6 +5242,7 @@ export default withEnglishFallback({
disableTrigger: "ปิดใช้งานทริกเกอร์",
enableTriggerSuccess: 'เปิดใช้งานทริกเกอร์ "{name}" แล้ว',
disableTriggerSuccess: 'ปิดใช้งานทริกเกอร์ "{name}" แล้ว',
+ copyPasswordText: "รหัสผ่าน (ข้อความต้นฉบับ)",
},
visibleDatabases: {
title: "ฐานข้อมูลที่มองเห็นได้",
diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.ts
index cbc8055b4e..bc28c29c0e 100644
--- a/apps/desktop/src/i18n/locales/tr.ts
+++ b/apps/desktop/src/i18n/locales/tr.ts
@@ -4065,6 +4065,7 @@ export default withEnglishFallback({
copyDsn: "DSN (key=value)",
copyDsnWithPassword: "DSN (parolalı)",
copyPsqlCommand: "psql komutu",
+ copyPasswordText: "Parola (düz metin)",
copyPasswordConfirmTitle: "Parolayla kopyala",
copyPasswordConfirmMessage: "Kopyalanan metin depolanan parolayı düz metin olarak içerecek. Devam edilsin mi?",
copyPasswordConfirmAction: "Kopyala",
diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts
index 289015097f..bb1e0e4f68 100644
--- a/apps/desktop/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/src/i18n/locales/zh-CN.ts
@@ -4980,6 +4980,7 @@ export default withEnglishFallback({
copyDsn: "DSN(key=value)",
copyDsnWithPassword: "DSN(含密码)",
copyPsqlCommand: "psql 命令",
+ copyPasswordText: "密码(原文)",
copyPasswordConfirmTitle: "复制含密码的连接信息",
copyPasswordConfirmMessage: "复制的内容将包含明文密码,任何能读取剪贴板的程序或用户都可以看到。是否继续?",
copyPasswordConfirmAction: "继续复制",
diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.ts
index 717446d725..a96cc78a79 100644
--- a/apps/desktop/src/i18n/locales/zh-TW.ts
+++ b/apps/desktop/src/i18n/locales/zh-TW.ts
@@ -4925,6 +4925,7 @@ export default withEnglishFallback({
copyPasswordConfirmTitle: "複製含密碼的連線資訊",
copyPasswordConfirmMessage: "複製的內容將包含明文密碼,任何能存取剪貼簿的程式或使用者都可以看到。是否繼續?",
copyPasswordConfirmAction: "繼續複製",
+ copyPasswordText: "密碼(原文)",
},
visibleDatabases: {
title: "顯示資料庫",
diff --git a/apps/desktop/src/lib/__tests__/connection/connectionUrlBuilder.spec.ts b/apps/desktop/src/lib/__tests__/connection/connectionUrlBuilder.spec.ts
index 5aece482df..60c2298fe6 100644
--- a/apps/desktop/src/lib/__tests__/connection/connectionUrlBuilder.spec.ts
+++ b/apps/desktop/src/lib/__tests__/connection/connectionUrlBuilder.spec.ts
@@ -31,7 +31,7 @@ describe("OceanBase copy readability and compatibility", () => {
expect(buildConnectionUrlCopy(connection, "urlWithPassword")).toBe("oceanbase://admin@tenant@cluster:[email protected]:2881/appdb");
expect(buildConnectionUrlCopy(connection, "jdbcUrl")).toBe("jdbc:oceanbase://db.example.com:2881/appdb");
expect(buildConnectionUrlCopy(connection, "jdbcUrlWithCredentials")).toBe("jdbc:oceanbase://db.example.com:2881/appdb?user=admin@tenant@cluster&password=secret");
- expect(connectionUrlCopyFormats(connection)).toEqual(["url", "urlWithPassword", "jdbcUrl", "jdbcUrlWithCredentials", "hostPort"]);
+ expect(connectionUrlCopyFormats(connection)).toEqual(["url", "urlWithPassword", "jdbcUrl", "jdbcUrlWithCredentials", "hostPort", "password"]);
for (const format of ["url", "urlWithPassword", "jdbcUrlWithCredentials"] as const) {
const parsed = parseConnectionUrl(buildConnectionUrlCopy(connection, format)!);
expect(parsed.username).toBe(connection.username);
@@ -90,7 +90,7 @@ describe("OceanBase copy readability and compatibility", () => {
describe("connectionUrlCopyFormats", () => {
it("lists all formats for a PostgreSQL connection with a stored password", () => {
- expect(connectionUrlCopyFormats(config({}))).toEqual(["url", "urlWithPassword", "jdbcUrl", "jdbcUrlWithCredentials", "hostPort", "dsn", "dsnWithPassword", "psqlCommand"]);
+ expect(connectionUrlCopyFormats(config({}))).toEqual(["url", "urlWithPassword", "jdbcUrl", "jdbcUrlWithCredentials", "hostPort", "dsn", "dsnWithPassword", "psqlCommand", "password"]);
});
it("drops every password-inclusive format when no password is stored", () => {
@@ -116,7 +116,7 @@ describe("connectionUrlCopyFormats", () => {
it("keeps H2 server mode available through its explicit connection string", () => {
const formats = connectionUrlCopyFormats(config({ db_type: "h2", host: "db.example.com", port: 9092, connection_string: "jdbc:h2:tcp://db.example.com:9092/~/test" }));
- expect(formats).toEqual(["url", "hostPort"]);
+ expect(formats).toEqual(["url", "hostPort", "password"]);
});
it("hides URL copy for service-registry and message-queue connections", () => {
@@ -126,7 +126,7 @@ describe("connectionUrlCopyFormats", () => {
it("offers only JDBC formats for hive-family connections", () => {
const formats = connectionUrlCopyFormats(config({ db_type: "hive", host: "hive.example.com", port: 10000, database: "dw" }));
- expect(formats).toEqual(["jdbcUrl", "jdbcUrlWithCredentials", "hostPort"]);
+ expect(formats).toEqual(["jdbcUrl", "jdbcUrlWithCredentials", "hostPort", "password"]);
});
it("uses semicolon options when copying an Inceptor JDBC URL", () => {
@@ -438,3 +438,16 @@ describe("Elasticsearch API key connection URL copies", () => {
expect(connectionUrlCopyFormats(search)).toEqual(["url", "hostPort"]);
});
});
+
+describe("raw password copy format", () => {
+ it("copies the stored password verbatim instead of the percent-encoded URL fragment", () => {
+ const password = "Jv@S#2I^x%40";
+ expect(buildConnectionUrlCopy(config({ password }), "password")).toBe(password);
+ expect(connectionUrlCopyFormats(config({ password }))).toContain("password");
+ });
+
+ it("omits the raw password item when no password is stored", () => {
+ expect(buildConnectionUrlCopy(config({ password: "" }), "password")).toBeNull();
+ expect(connectionUrlCopyFormats(config({ password: "" }))).not.toContain("password");
+ });
+});
diff --git a/apps/desktop/src/lib/connection/connectionUrlBuilder.ts b/apps/desktop/src/lib/connection/connectionUrlBuilder.ts
index c03dc990a2..4dc85d3078 100644
--- a/apps/desktop/src/lib/connection/connectionUrlBuilder.ts
+++ b/apps/desktop/src/lib/connection/connectionUrlBuilder.ts
@@ -13,16 +13,16 @@ import { redactConnectionStringSecrets } from "@/lib/connection/connectionString
* from the menu instead of guessing a wrong URL.
*
* Password safety: the primary formats (`url`, `jdbcUrl`, `dsn`) never embed
- * the stored password. Formats that do (`urlWithPassword`,
+ * the stored password. Formats that do (`password`, `urlWithPassword`,
* `jdbcUrlWithCredentials`, `dsnWithPassword`) are only offered when a
* password is actually available, and the caller gates them behind an
* explicit confirmation.
*/
-export type ConnectionUrlCopyFormat = "url" | "urlWithPassword" | "jdbcUrl" | "jdbcUrlWithCredentials" | "hostPort" | "dsn" | "dsnWithPassword" | "psqlCommand";
+export type ConnectionUrlCopyFormat = "url" | "urlWithPassword" | "jdbcUrl" | "jdbcUrlWithCredentials" | "hostPort" | "dsn" | "dsnWithPassword" | "psqlCommand" | "password";
/** Formats whose output embeds the stored password; callers should confirm before copying. */
-export const CONNECTION_URL_COPY_WITH_PASSWORD_FORMATS: ReadonlySet<ConnectionUrlCopyFormat> = new Set(["urlWithPassword", "jdbcUrlWithCredentials", "dsnWithPassword"]);
+export const CONNECTION_URL_COPY_WITH_PASSWORD_FORMATS: ReadonlySet<ConnectionUrlCopyFormat> = new Set(["urlWithPassword", "jdbcUrlWithCredentials", "dsnWithPassword", "password"]);
export type ConnectionUrlCopyConfig = Pick<ConnectionConfig, "db_type" | "host" | "port" | "username" | "password" | "database" | "url_params" | "ssl" | "connection_string"> & Partial<Pick<ConnectionConfig, "driver_profile" | "oracle_connection_type" | "external_config">>;
@@ -578,6 +578,13 @@ export function connectionUrlCopyFormats(config: ConnectionUrlCopyConfig | undef
if (dsnWithPassword && hasSecret && dsnWithPassword !== dsn) formats.push("dsnWithPassword");
if (buildPsqlCommand(candidate, {})) formats.push("psqlCommand");
}
+ // The URL variants must percent-encode credentials to keep the URL parseable
+ // (`@` in a password becomes `%40`), so clients that never percent-decode —
+ // or simply pasting into another app's password field — need this verbatim
+ // escape hatch (issue #13388). Skipped for Elasticsearch API-key connections,
+ // where the stored secret is not a password.
+ const usesApiKey = candidate.db_type === "elasticsearch" && elasticsearchAuthTypeFromConfig(candidate.external_config) === "apiKey";
+ if (candidate.password && !usesApiKey) formats.push("password");
return formats;
}
@@ -601,6 +608,8 @@ export function buildConnectionUrlCopy(config: ConnectionUrlCopyConfig | undefin
return isPostgresWireFamily(candidate) ? buildKeyvalueDsn(candidate, { ...options, includePassword: true }) : null;
case "psqlCommand":
return isPostgresWireFamily(candidate) ? buildPsqlCommand(candidate, options ?? {}) : null;
+ case "password":
+ return candidate.password || null;
default:
return null;
}