Registry Mirror
Skip to content

File tree

‎packages/databricks-vscode/package.json‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1856,6 +1856,14 @@
18561856
"type": "number",
18571857
"default": 5,
18581858
"description": "The interval in minutes at which the remote state of the bundle is refreshed."
1859+
},
1860+
"databricks.proxy.strictSSL": {
1861+
"type": "boolean",
1862+
"markdownDescription": "Controls whether TLS certificates are verified for the extension's Databricks SDK calls. When unset, the built-in `#http.proxyStrictSSL#` value is used. Set to `false` only when a corporate CA certificate cannot be resolved from the system trust store."
1863+
},
1864+
"databricks.proxy.caCert": {
1865+
"type": "string",
1866+
"markdownDescription": "Absolute path to a PEM bundle of additional CA certificates to trust for the extension's Databricks SDK calls, merged with the OS trust store and Node's built-in roots. Use when a corporate CA cannot be read from the system store — in particular on Windows, where the extension does not read the system certificate store and relies on this setting for internal CAs."
18591867
}
18601868
}
18611869
}
@@ -1893,7 +1901,7 @@
18931901
"package:copy-webview-toolkit": "cp ./node_modules/@vscode/webview-ui-toolkit/dist/toolkit.js ./out/toolkit.js",
18941902
"package:copy-markdown-it": "cp ./node_modules/markdown-it/dist/browser/markdown-it.umd.min.js ./out/markdown-it.min.js",
18951903
"package:copy-highlight": "esbuild ./node_modules/highlight.js/lib/common.js --bundle --format=iife --global-name=hljs --outfile=out/highlight.min.js --minify",
1896-
"esbuild:base": "esbuild ./src/extension.ts --bundle --outfile=out/extension.js --external:vscode --format=cjs --platform=node --sourcemap --target=es2019",
1904+
"esbuild:base": "esbuild ./src/extension.ts --bundle --outfile=out/extension.js --external:vscode --external:@vscode/windows-ca-certs --format=cjs --platform=node --sourcemap --target=es2019",
18971905
"build": "yarn run package:wrappers:write && yarn run package:jupyter-init-script:write && tsc --build --force",
18981906
"watch": "yarn run package:wrappers:write && yarn run package:jupyter-init-script:write && yarn run package:copy-webview-toolkit && yarn run package:copy-markdown-it && yarn run package:copy-highlight && tsc --build --watch --verbose",
18991907
"fix": "eslint src --fix && prettier . --write",
@@ -1918,11 +1926,14 @@
19181926
"@types/shell-quote": "^1.7.5",
19191927
"@vscode/debugadapter": "^1.64.0",
19201928
"@vscode/extension-telemetry": "^1.5.2",
1929+
"@vscode/proxy-agent": "^0.28.0",
19211930
"@vscode/webview-ui-toolkit": "^1.4.0",
19221931
"add": "^2.0.6",
19231932
"ansi-to-html": "^0.7.2",
19241933
"bcryptjs": "^3.0.3",
19251934
"highlight.js": "^11.10.0",
1935+
"http-proxy-agent": "^7.0.2",
1936+
"https-proxy-agent": "^7.0.6",
19261937
"lodash": "^4.18.1",
19271938
"markdown-it": "^15.0.0",
19281939
"minimatch": "^10.2.3",

‎packages/databricks-vscode/scripts/package-vsix.sh‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,5 @@ if [ $ARCH != "win32-arm64" ]; then
6363
fi
6464

6565
yarn run prettier package.json --write
66+
6667
TAG="release-v$(cat package.json | jq -r .version)" yarn run package -t $VSXI_ARCH

‎packages/databricks-vscode/src/configuration/auth/AuthProvider.ts‎

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
/* eslint-disable @typescript-eslint/naming-convention */
2-
import {
3-
Config,
4-
ProductVersion,
5-
WorkspaceClient,
6-
logging,
7-
} from "@databricks/sdk-experimental";
2+
import {Config, WorkspaceClient, logging} from "@databricks/sdk-experimental";
83
import {CancellationToken, ProgressLocation, window} from "vscode";
94
import {normalizeHost} from "../../utils/urlUtils";
105
import {workspaceConfigs} from "../../vscode-objs/WorkspaceConfigs";
116

12-
// eslint-disable-next-line @typescript-eslint/no-require-imports
13-
const extensionVersion = require("../../../package.json")
14-
.version as ProductVersion;
15-
167
import {AzureCliCheck} from "./AzureCliCheck";
178
import {DatabricksCliCheck} from "./DatabricksCliCheck";
189
import {Loggers} from "../../logger";
1910
import {CliWrapper} from "../../cli/CliWrapper";
11+
import {ProxyAgent} from "../../utils";
2012

2113
// TODO: Resolve this with SDK's AuthType.
2214
export type AuthType =
@@ -52,11 +44,7 @@ export abstract class AuthProvider {
5244

5345
async getWorkspaceClient(): Promise<WorkspaceClient> {
5446
const config = await this.getSdkConfig();
55-
56-
return new WorkspaceClient(config, {
57-
product: "databricks-vscode",
58-
productVersion: extensionVersion,
59-
});
47+
return ProxyAgent.createWorkspaceClient(config, this.host);
6048
}
6149

6250
/**

‎packages/databricks-vscode/src/configuration/auth/AzureCliCheck.ts‎

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
import {
2-
Context,
3-
ProductVersion,
4-
WorkspaceClient,
5-
logging,
6-
} from "@databricks/sdk-experimental";
1+
import {Context, logging} from "@databricks/sdk-experimental";
72
import {CancellationToken, commands, Disposable, Uri, window} from "vscode";
83
import {Loggers} from "../../logger";
94
import {AzureCliAuthProvider} from "./AuthProvider";
105
import {orchestrate, OrchestrationLoopError, Step} from "./orchestrate";
11-
import {ShellUtils} from "../../utils";
6+
import {ProxyAgent, ShellUtils} from "../../utils";
127
import {cancellableExecFile} from "../../cli/CliWrapper";
138
import {
149
FileNotFoundException,
@@ -18,10 +13,6 @@ import {
1813
// eslint-disable-next-line @typescript-eslint/naming-convention
1914
const {NamedLogger} = logging;
2015

21-
// eslint-disable-next-line @typescript-eslint/no-require-imports
22-
const extensionVersion = require("../../../package.json")
23-
.version as ProductVersion;
24-
2516
type AzureCloud = "AzureCloud" | "AzureChinaCloud" | "AzureUSGovernment";
2617

2718
type AzureStepName =
@@ -212,16 +203,13 @@ export class AzureCliCheck implements Disposable {
212203
expired: boolean;
213204
error?: Error;
214205
}> {
215-
const workspaceClient = new WorkspaceClient(
206+
const workspaceClient = await ProxyAgent.createWorkspaceClient(
216207
{
217208
host: host.toString(),
218209
authType: "azure-cli",
219210
azureLoginAppId: this.azureLoginAppId,
220211
},
221-
{
222-
product: "databricks-vscode",
223-
productVersion: extensionVersion,
224-
}
212+
host
225213
);
226214
try {
227215
await workspaceClient.currentUser.me(

‎packages/databricks-vscode/src/configuration/auth/DatabricksCliCheck.ts‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import {
22
CancellationToken,
33
Context,
4-
ProductVersion,
5-
WorkspaceClient,
64
logging,
75
} from "@databricks/sdk-experimental";
86
import {
@@ -14,10 +12,7 @@ import {DatabricksCliAuthProvider} from "./AuthProvider";
1412
import {orchestrate, OrchestrationLoopError, Step} from "./orchestrate";
1513
import {Loggers} from "../../logger";
1614
import {execFile} from "../../cli/CliWrapper";
17-
18-
// eslint-disable-next-line @typescript-eslint/no-require-imports
19-
const extensionVersion = require("../../../package.json")
20-
.version as ProductVersion;
15+
import {ProxyAgent} from "../../utils";
2116

2217
type StepName = "tryLogin" | "login";
2318

@@ -111,7 +106,7 @@ export class DatabricksCliCheck implements Disposable {
111106
private async tryLogin(
112107
cancellationToken?: CancellationToken
113108
): Promise<boolean> {
114-
const workspaceClient = new WorkspaceClient(
109+
const workspaceClient = await ProxyAgent.createWorkspaceClient(
115110
{
116111
host: this.authProvider.host.toString(),
117112
authType: "databricks-cli",
@@ -121,10 +116,7 @@ export class DatabricksCliCheck implements Disposable {
121116
? {workspaceId: this.authProvider.workspaceId}
122117
: {}),
123118
},
124-
{
125-
product: "databricks-vscode",
126-
productVersion: extensionVersion,
127-
}
119+
this.authProvider.host
128120
);
129121

130122
try {

‎packages/databricks-vscode/src/extension.ts‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {workspaceConfigs} from "./vscode-objs/WorkspaceConfigs";
3434
import {
3535
FileUtils,
3636
PackageJsonUtils,
37+
ProxyAgent,
3738
TerraformUtils,
3839
UrlUtils,
3940
UtilsCommands,
@@ -675,20 +676,16 @@ export async function activate(
675676
customWhenContext.updateShowClusterView();
676677
}
677678

678-
function updateStrictSSLEnv() {
679-
const httpConfig = workspace.getConfiguration("http");
680-
const proxyStrictSSL = httpConfig.get<boolean>("proxyStrictSSL");
681-
process.env["DATABRICKS_SDK_PROXY_STRICT_SSL"] = proxyStrictSSL
682-
? "true"
683-
: "false";
684-
}
685-
686679
updateFeatureContexts();
687-
updateStrictSSLEnv();
680+
// Resolve TLS strict-SSL through the same layered setting the SDK client
681+
// path uses (databricks.proxy.strictSSL -> http.proxyStrictSSL -> true), so
682+
// both writers of DATABRICKS_SDK_PROXY_STRICT_SSL agree and verification
683+
// stays on by default when nothing is configured.
684+
ProxyAgent.applyProxyStrictSSLEnv();
688685
context.subscriptions.push(
689686
workspace.onDidChangeConfiguration(() => {
690687
updateFeatureContexts();
691-
updateStrictSSLEnv();
688+
ProxyAgent.applyProxyStrictSSLEnv();
692689
})
693690
);
694691

‎packages/databricks-vscode/src/utils/envVarGenerators.test.ts‎

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable @typescript-eslint/naming-convention */
2-
import {anything, instance, mock, when} from "ts-mockito";
2+
import {anything, instance, mock, reset, spy, when} from "ts-mockito";
33
import {ConnectionManager} from "../configuration/ConnectionManager";
44
import {DatabricksWorkspace} from "../configuration/DatabricksWorkspace";
55
import {ApiClient, Config} from "@databricks/sdk-experimental";
@@ -13,6 +13,7 @@ import {
1313
import {Uri} from "vscode";
1414
import assert from "assert";
1515
import {AuthProvider} from "../configuration/auth/AuthProvider";
16+
import {workspaceConfigs} from "../vscode-objs/WorkspaceConfigs";
1617

1718
describe(__filename, () => {
1819
let mockConnectionManager: ConnectionManager;
@@ -22,8 +23,14 @@ describe(__filename, () => {
2223
const mockHost = "http://example.com";
2324
let mockApiClient: ApiClient;
2425
let existingEnv: any;
26+
let configsSpy: typeof workspaceConfigs;
2527

2628
beforeEach(() => {
29+
configsSpy = spy(workspaceConfigs);
30+
// Default: no proxy configured via VS Code settings, so getProxyEnvVars
31+
// falls back to the process env vars the tests set explicitly.
32+
when(configsSpy.httpProxy).thenReturn(undefined);
33+
when(configsSpy.httpNoProxy).thenReturn([]);
2734
mockConnectionManager = mock(ConnectionManager);
2835
mockDatabricksWorkspace = mock(DatabricksWorkspace);
2936
mockCluster = mock(Cluster);
@@ -45,6 +52,7 @@ describe(__filename, () => {
4552
});
4653

4754
afterEach(() => {
55+
reset(configsSpy);
4856
process.env = existingEnv;
4957
});
5058

@@ -86,6 +94,51 @@ describe(__filename, () => {
8694
});
8795
});
8896

97+
it("should use the http.proxy setting for both schemes when set", () => {
98+
delete process.env.HTTP_PROXY;
99+
delete process.env.HTTPS_PROXY;
100+
delete process.env.http_proxy;
101+
delete process.env.https_proxy;
102+
when(configsSpy.httpProxy).thenReturn("http://proxy.local:8080");
103+
104+
const actual = getProxyEnvVars();
105+
assert.deepEqual(actual, {
106+
HTTP_PROXY: "http://proxy.local:8080",
107+
HTTPS_PROXY: "http://proxy.local:8080",
108+
NO_PROXY: undefined,
109+
});
110+
});
111+
112+
it("should let the http.proxy setting win over env vars", () => {
113+
process.env.HTTP_PROXY = "http://env-proxy.local:1";
114+
process.env.HTTPS_PROXY = "http://env-proxy.local:1";
115+
when(configsSpy.httpProxy).thenReturn("http://setting-proxy.local:2");
116+
117+
const actual = getProxyEnvVars();
118+
assert.deepEqual(actual, {
119+
HTTP_PROXY: "http://setting-proxy.local:2",
120+
HTTPS_PROXY: "http://setting-proxy.local:2",
121+
NO_PROXY: undefined,
122+
});
123+
});
124+
125+
it("should merge http.noProxy setting with the NO_PROXY env var", () => {
126+
delete process.env.no_proxy;
127+
process.env.NO_PROXY = "shared.example.com,env.example.com";
128+
when(configsSpy.httpNoProxy).thenReturn([
129+
"setting.example.com",
130+
"shared.example.com",
131+
]);
132+
133+
const actual = getProxyEnvVars();
134+
assert.deepEqual(actual, {
135+
HTTP_PROXY: undefined,
136+
HTTPS_PROXY: undefined,
137+
// Deduped: "shared.example.com" appears in both sources but once here.
138+
NO_PROXY: "setting.example.com,shared.example.com,env.example.com",
139+
});
140+
});
141+
89142
it("should generate env vars with expected cluster id", () => {
90143
const actual = getCommonDatabricksEnvVars(
91144
instance(mockConnectionManager),

‎packages/databricks-vscode/src/utils/envVarGenerators.ts‎

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {ExtensionContext, Uri} from "vscode";
44
import {logging, Headers} from "@databricks/sdk-experimental";
55
import {ConnectionManager} from "../configuration/ConnectionManager";
66
import {TerraformMetadata} from "./terraformUtils";
7+
import {workspaceConfigs} from "../vscode-objs/WorkspaceConfigs";
8+
import {mergeNoProxy} from "./network/proxyAgent";
79

810
// eslint-disable-next-line @typescript-eslint/no-require-imports
911
const packageJson = require("../../package.json");
@@ -140,12 +142,41 @@ export async function getDbConnectEnvVars(
140142
/* eslint-enable @typescript-eslint/naming-convention */
141143
}
142144

145+
/**
146+
* Proxy env vars forwarded to the bundled Databricks CLI (and any other
147+
* subprocess). The Go CLI does no proxy handling of its own — it relies on Go's
148+
* `http.ProxyFromEnvironment`, which reads only these env vars — so this is the
149+
* only way to route CLI traffic through a proxy.
150+
*
151+
* Precedence mirrors the in-process SDK path (`proxyAgent.ts`
152+
* `getProxyAgentParams`): the VS Code `http.proxy` setting wins over the OS
153+
* `http(s)_proxy` env vars. That keeps the CLI and the SDK resolving the same
154+
* proxy from the same inputs, so a user who configures the proxy purely through
155+
* the VS Code setting gets it applied to both. `no_proxy` is the exception — the
156+
* `http.noProxy` setting and the env var are *unioned* (not overridden), since a
157+
* bypass list is only ever safer when it's broader.
158+
*
159+
* Absent values stay `undefined` so `removeUndefinedKeys(...)` at the call sites
160+
* strips them, leaving the CLI's own env untouched when nothing is configured.
161+
*/
143162
export function getProxyEnvVars() {
163+
// The `http.proxy` setting is a single URL used for both schemes.
164+
const settingProxy = workspaceConfigs.httpProxy;
165+
const httpProxy =
166+
settingProxy || process.env.HTTP_PROXY || process.env.http_proxy;
167+
const httpsProxy =
168+
settingProxy || process.env.HTTPS_PROXY || process.env.https_proxy;
169+
170+
// Merge the `http.noProxy` setting with the NO_PROXY env var (shared with
171+
// the in-process SDK proxy resolver), then join back to the comma-separated
172+
// form the CLI expects.
173+
const noProxy = mergeNoProxy().join(",") || undefined;
174+
144175
return {
145176
/* eslint-disable @typescript-eslint/naming-convention */
146-
HTTP_PROXY: process.env.HTTP_PROXY || process.env.http_proxy,
147-
HTTPS_PROXY: process.env.HTTPS_PROXY || process.env.https_proxy,
148-
NO_PROXY: process.env.NO_PROXY || process.env.no_proxy,
177+
HTTP_PROXY: httpProxy,
178+
HTTPS_PROXY: httpsProxy,
179+
NO_PROXY: noProxy,
149180
/* eslint-enable @typescript-eslint/naming-convention */
150181
};
151182
}

‎packages/databricks-vscode/src/utils/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ export * as EnvVarGenerators from "./envVarGenerators";
77
export * as DateUtils from "./DateUtils";
88
export * as TerraformUtils from "./terraformUtils";
99
export * as HostUtils from "./hostUtils";
10+
export {ProxyAgent} from "./network";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * as ProxyAgent from "./proxyAgent";

0 commit comments

Comments
 (0)