fix(jdbc): keep local plugin installation fully offline

This commit is contained in:
Melody Ruch authored and GitHub committed 2026-08-20 21:39:00 +08:00
1 parent be9f8e72e4
commit c030835acf
11 files changed
+89 -9

No files matched your search

@@ -1875,10 +1875,17 @@ watch(driverStoreTab, (tab) => {
<Button v-else type="button" variant="default" class="rounded-md" :disabled="isInstallingJdbcPlugin" @click="installJdbcPlugin"> <Button v-else type="button" variant="default" class="rounded-md" :disabled="isInstallingJdbcPlugin" @click="installJdbcPlugin">
{{ isInstallingJdbcPlugin ? t("common.loading") : t("settings.jdbcPluginInstall") }} {{ isInstallingJdbcPlugin ? t("common.loading") : t("settings.jdbcPluginInstall") }}
</Button> </Button>
<Button type="button" variant="outline" class="rounded-md" :disabled="isInstallingJdbcPlugin || isUninstallingJdbcPlugin" @click="installJdbcPluginLocal"> <Tooltip>
<FolderOpen class="h-3.5 w-3.5 mr-1" /> <TooltipTrigger as-child>
{{ t("driverStore.localInstall") }} <Button type="button" variant="outline" class="rounded-md" :disabled="isInstallingJdbcPlugin || isUninstallingJdbcPlugin" @click="installJdbcPluginLocal">
</Button> <FolderOpen class="h-3.5 w-3.5 mr-1" />
{{ t("driverStore.localInstall") }}
</Button>
</TooltipTrigger>
<TooltipContent side="bottom" class="max-w-100 break-all text-xs">
{{ t("driverStore.localInstallHint") }}
</TooltipContent>
</Tooltip>
</div> </div>
</div> </div>
</div> </div>
+1
View File
@@ -6660,6 +6660,7 @@ export default {
updating: "Updating", updating: "Updating",
update: "Update", update: "Update",
localInstall: "Local install", localInstall: "Local install",
localInstallHint: "For air-gapped machines: on another computer with internet access, download the official dbx-jdbc-plugin-*.zip from the DBX GitHub Releases page, transfer it here, and select it — no network access is needed on this machine.",
runtimeDrivers: "Runtime", runtimeDrivers: "Runtime",
storageTab: "Storage", storageTab: "Storage",
runtimeTitle: "Driver runtime", runtimeTitle: "Driver runtime",
+1
View File
@@ -6371,6 +6371,7 @@ export default withEnglishFallback({
updating: "Actualizando", updating: "Actualizando",
update: "Actualizar", update: "Actualizar",
localInstall: "Instalación local", localInstall: "Instalación local",
localInstallHint: "Para entornos sin acceso a internet: en otro equipo con conexión, descarga el dbx-jdbc-plugin-*.zip oficial desde la página de Releases de DBX en GitHub, transfiérelo a esta máquina y selecciónalo; no se necesita acceso a la red en este equipo.",
runtimeDrivers: "Runtime", runtimeDrivers: "Runtime",
storageTab: "Almacenamiento", storageTab: "Almacenamiento",
runtimeTitle: "Runtime de drivers", runtimeTitle: "Runtime de drivers",
+2
View File
@@ -6371,6 +6371,8 @@ export default withEnglishFallback({
updating: "Aggiornamento in corso", updating: "Aggiornamento in corso",
update: "Aggiorna", update: "Aggiorna",
localInstall: "Installazione locale", localInstall: "Installazione locale",
localInstallHint:
"Per ambienti completamente isolati: su un altro computer con accesso a internet, scarica il pacchetto ufficiale dbx-jdbc-plugin-*.zip dalla pagina Releases di DBX su GitHub, trasferiscilo su questa macchina e selezionalo: non è richiesto alcun accesso alla rete su questa macchina.",
runtimeDrivers: "Runtime", runtimeDrivers: "Runtime",
storageTab: "Archiviazione", storageTab: "Archiviazione",
runtimeTitle: "Runtime del driver", runtimeTitle: "Runtime del driver",
+1
View File
@@ -6424,6 +6424,7 @@ export default withEnglishFallback({
updating: "更新中", updating: "更新中",
update: "更新", update: "更新",
localInstall: "ローカルインストール", localInstall: "ローカルインストール",
localInstallHint: "完全に隔離されたネットワーク環境の場合:インターネットに接続できる別のコンピューターで DBX の GitHub Releases ページから公式の dbx-jdbc-plugin-*.zip をダウンロードし、このマシンに転送して選択してください。このマシンはネットワークに接続する必要はありません。",
runtimeDrivers: "ランタイム", runtimeDrivers: "ランタイム",
storageTab: "ストレージ", storageTab: "ストレージ",
runtimeTitle: "ドライバーランタイム", runtimeTitle: "ドライバーランタイム",
+1
View File
@@ -6065,6 +6065,7 @@ export default withEnglishFallback({
updating: "업데이트 중", updating: "업데이트 중",
update: "업데이트", update: "업데이트",
localInstall: "로컬 설치", localInstall: "로컬 설치",
localInstallHint: "완전한 폐쇄망 환경의 경우: 인터넷에 연결된 다른 컴퓨터에서 DBX GitHub Releases 페이지의 공식 dbx-jdbc-plugin-*.zip을 다운로드한 뒤 이 기기로 옮겨 선택하세요. 이 기기는 네트워크에 연결할 필요가 없습니다.",
runtimeDrivers: "런타임", runtimeDrivers: "런타임",
storageTab: "저장 공간", storageTab: "저장 공간",
runtimeTitle: "드라이버 런타임", runtimeTitle: "드라이버 런타임",
+1
View File
@@ -6373,6 +6373,7 @@ export default withEnglishFallback({
updating: "Atualizando", updating: "Atualizando",
update: "Atualizar", update: "Atualizar",
localInstall: "Instalação local", localInstall: "Instalação local",
localInstallHint: "Para ambientes sem acesso à internet: em outro computador com internet, baixe o dbx-jdbc-plugin-*.zip oficial na página de Releases do DBX no GitHub, transfira-o para esta máquina e selecione-o — nenhum acesso à rede é necessário aqui.",
runtimeDrivers: "Runtime", runtimeDrivers: "Runtime",
storageTab: "Armazenamento", storageTab: "Armazenamento",
runtimeTitle: "Runtime do driver", runtimeTitle: "Runtime do driver",
+1
View File
@@ -6645,6 +6645,7 @@ export default withEnglishFallback({
updating: "更新中", updating: "更新中",
update: "更新", update: "更新",
localInstall: "本地安装", localInstall: "本地安装",
localInstallHint: "适用于完全内网环境:在另一台可联网的电脑上,从 DBX 的 GitHub Releases 页面下载官方 dbx-jdbc-plugin-*.zip 安装包,拷贝到本机后在此选择该文件——本机无需联网即可完成安装。",
runtimeDrivers: "运行时", runtimeDrivers: "运行时",
storageTab: "存储", storageTab: "存储",
runtimeTitle: "驱动运行时", runtimeTitle: "驱动运行时",
+1
View File
@@ -5683,6 +5683,7 @@ export default withEnglishFallback({
updating: "更新中", updating: "更新中",
update: "更新", update: "更新",
localInstall: "本機安裝", localInstall: "本機安裝",
localInstallHint: "適用於完全內網環境:在另一台可連網的電腦上,從 DBX 的 GitHub Releases 頁面下載官方 dbx-jdbc-plugin-*.zip 安裝包,傳輸到本機後在此選取該檔案——本機不需要連網即可完成安裝。",
runtimeDrivers: "執行環境", runtimeDrivers: "執行環境",
storageTab: "儲存", storageTab: "儲存",
runtimeTitle: "驅動程式執行環境", runtimeTitle: "驅動程式執行環境",
+63 -5
View File
@@ -374,7 +374,9 @@ pub async fn install_jdbc_plugin_from_file(plugins_root: &Path, file_path: &str)
}) })
.await .await
.map_err(|err| err.to_string())??; .map_err(|err| err.to_string())??;
jdbc_plugin_status_from_dir(&status_dir).await // Local install must stay fully offline: build status from the local
// manifest only, do not check for a newer release over the network.
jdbc_plugin_status_from_dir_local(&status_dir)
} }
pub fn uninstall_jdbc_plugin(plugins_root: &Path) -> Result<JdbcPluginStatus, String> { pub fn uninstall_jdbc_plugin(plugins_root: &Path) -> Result<JdbcPluginStatus, String> {
@@ -390,14 +392,20 @@ pub fn uninstall_jdbc_plugin(plugins_root: &Path) -> Result<JdbcPluginStatus, St
std::fs::remove_file(path).map_err(|err| err.to_string())?; std::fs::remove_file(path).map_err(|err| err.to_string())?;
} }
} }
// synchronous version: check local manifest only, no network call jdbc_plugin_status_from_dir_local(&plugin_dir)
}
/// Builds plugin status from the local manifest only, no network call.
/// Used by install/uninstall paths that must stay fully offline (uninstall,
/// and installing a plugin package the user already has on disk).
fn jdbc_plugin_status_from_dir_local(plugin_dir: &Path) -> Result<JdbcPluginStatus, String> {
let manifest_path = plugin_dir.join("manifest.json"); let manifest_path = plugin_dir.join("manifest.json");
let manifest = match std::fs::read_to_string(&manifest_path) { let manifest = match std::fs::read_to_string(&manifest_path) {
Ok(raw) => Some(serde_json::from_str::<PluginManifest>(&raw).map_err(|err| err.to_string())?), Ok(raw) => Some(serde_json::from_str::<PluginManifest>(&raw).map_err(|err| err.to_string())?),
Err(err) if err.kind() == std::io::ErrorKind::NotFound => None, Err(err) if err.kind() == std::io::ErrorKind::NotFound => None,
Err(err) => return Err(err.to_string()), Err(err) => return Err(err.to_string()),
}; };
Ok(build_plugin_status(&manifest, None, &plugin_dir)) Ok(build_plugin_status(&manifest, None, plugin_dir))
} }
// ---- System Fonts ---- // ---- System Fonts ----
@@ -451,13 +459,25 @@ fn jdbc_maven_resolver_executable(plugin_dir: &Path) -> PathBuf {
} }
async fn jdbc_plugin_status_from_dir(plugin_dir: &Path) -> Result<JdbcPluginStatus, String> { async fn jdbc_plugin_status_from_dir(plugin_dir: &Path) -> Result<JdbcPluginStatus, String> {
jdbc_plugin_status_from_dir_after(plugin_dir, latest_jdbc_plugin()).await
}
/// Waits on `latest` before reading the manifest, so a slow/offline network
/// check can never race ahead of a concurrent local install and report a
/// stale pre-install snapshot back to the caller. `latest` is a parameter
/// (rather than calling `latest_jdbc_plugin()` directly) so tests can
/// simulate a delayed network response without a real network call.
async fn jdbc_plugin_status_from_dir_after(
plugin_dir: &Path,
latest: impl std::future::Future<Output = Option<JdbcPluginLatest>>,
) -> Result<JdbcPluginStatus, String> {
let latest = latest.await;
let manifest_path = plugin_dir.join("manifest.json"); let manifest_path = plugin_dir.join("manifest.json");
let manifest = match std::fs::read_to_string(&manifest_path) { let manifest = match std::fs::read_to_string(&manifest_path) {
Ok(raw) => Some(serde_json::from_str::<PluginManifest>(&raw).map_err(|err| err.to_string())?), Ok(raw) => Some(serde_json::from_str::<PluginManifest>(&raw).map_err(|err| err.to_string())?),
Err(err) if err.kind() == std::io::ErrorKind::NotFound => None, Err(err) if err.kind() == std::io::ErrorKind::NotFound => None,
Err(err) => return Err(err.to_string()), Err(err) => return Err(err.to_string()),
}; };
let latest = latest_jdbc_plugin().await;
Ok(build_plugin_status(&manifest, latest.as_ref(), plugin_dir)) Ok(build_plugin_status(&manifest, latest.as_ref(), plugin_dir))
} }
@@ -553,7 +573,10 @@ fn install_jdbc_plugin_zip(bytes: &[u8], plugin_dir: &Path) -> Result<(), String
if !temp_dir.join("manifest.json").exists() { if !temp_dir.join("manifest.json").exists() {
let _ = std::fs::remove_dir_all(&temp_dir); let _ = std::fs::remove_dir_all(&temp_dir);
return Err("Downloaded JDBC plugin package is missing manifest.json".to_string()); return Err(format!(
"This ZIP is not a valid DBX JDBC plugin package (missing manifest.json). \
The correct package is available at: {JDBC_PLUGIN_DOWNLOAD_URL}"
));
} }
let manifest_path = temp_dir.join("manifest.json"); let manifest_path = temp_dir.join("manifest.json");
let manifest = std::fs::read_to_string(&manifest_path) let manifest = std::fs::read_to_string(&manifest_path)
@@ -1447,4 +1470,39 @@ mod tests {
let _ = std::fs::remove_dir_all(root); let _ = std::fs::remove_dir_all(root);
} }
#[tokio::test]
async fn delayed_network_status_check_does_not_revert_a_concurrent_local_install() {
let root = std::env::temp_dir().join(format!("dbx-jdbc-status-race-test-{}", uuid::Uuid::new_v4()));
let plugin_dir = root.join("jdbc");
std::fs::create_dir_all(&plugin_dir).unwrap();
// Mirrors DriverStoreDialog's mount-time status check: it starts
// before the local install and only finishes its (simulated)
// network wait after the local install has already written the
// new manifest to disk.
let status_plugin_dir = plugin_dir.clone();
let status_task = tokio::spawn(async move {
jdbc_plugin_status_from_dir_after(&status_plugin_dir, async {
tokio::time::sleep(std::time::Duration::from_millis(80)).await;
None
})
.await
});
tokio::time::sleep(std::time::Duration::from_millis(20)).await;
// Local install completes fully offline while the status check
// above is still waiting on its simulated network round-trip.
std::fs::write(
plugin_dir.join("manifest.json"),
r#"{"id":"jdbc","name":"DBX JDBC Plugin","version":"0.1.30","protocol_version":1,"executable":"bin/dbx-jdbc-plugin","drivers":[]}"#,
)
.unwrap();
let status = status_task.await.unwrap().unwrap();
assert!(status.installed, "stale pre-install snapshot must not overwrite the completed local install");
assert_eq!(status.version.as_deref(), Some("0.1.30"));
let _ = std::fs::remove_dir_all(root);
}
} }
+6
View File
@@ -93,6 +93,12 @@ Download `dbx-agent-kingbase-<version>-windows-x64.zip` for Windows x64 or `dbx-
The ZIP contains the version metadata and native agent for that platform. DBX installs it as `%USERPROFILE%\.dbx\agents\drivers\kingbase\agent.exe`, without requiring users to unblock or manually copy the executable. The ZIP contains the version metadata and native agent for that platform. DBX installs it as `%USERPROFILE%\.dbx\agents\drivers\kingbase\agent.exe`, without requiring users to unblock or manually copy the executable.
### Importing the JDBC plugin offline
Generic JDBC connections (custom JDBC URL + imported driver JAR) run through a separate **DBX JDBC plugin**, released as its own `dbx-jdbc-plugin-*.zip` asset — not bundled into any per-database Agent ZIP. Install it with **Local install** in the **JDBC Drivers** tab (not **Import offline package** in Built-in Drivers, which is for Agent ZIPs).
Importing the actual driver JAR (e.g. an Oracle `ojdbc*.jar`) is always local and does not require this plugin package or any network access — use **Import JAR** in the same tab, regardless of whether the JDBC plugin itself is installed.
## Plugin Updates ## Plugin Updates
For databases supported by the [JDBC Plugin](/en/docs/plugins), DBX shows update notices when a new plugin version is available. Plugin updates follow the same install flow as built-in agent drivers. For databases supported by the [JDBC Plugin](/en/docs/plugins), DBX shows update notices when a new plugin version is available. Plugin updates follow the same install flow as built-in agent drivers.