Skip to content

Commit a625f53

Browse files
Add comprehensive DTS connection string validation
Co-authored-by: alexweininger <12476526+alexweininger@users.noreply.github.com>
1 parent 3aa6962 commit a625f53

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ let perfStats = {
1616

1717
Object.defineProperty(exports, "__esModule", { value: true });
1818

19-
const extension = require('./out/src/extension');
19+
const extension = require('./dist/extension.bundle');
2020

2121
async function activate(ctx) {
22-
return await extension.activateInternal(ctx, perfStats, true /* ignoreBundle */);
22+
return await extension.activateInternal(ctx, perfStats);
2323
}
2424

2525
async function deactivate(ctx) {

src/commands/appSettings/connectionSettings/durableTaskScheduler/custom/DTSConnectionCustomPromptStep.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,37 @@ export class DTSConnectionCustomPromptStep<T extends IDTSConnectionWizardContext
2020
return !context.newDTSConnectionSetting && context.dtsConnectionType === ConnectionType.Custom;
2121
}
2222

23-
private validateInput(name: string | undefined): string | undefined {
24-
name = name ? name.trim() : '';
25-
if (!validationUtils.hasValidCharLength(name)) {
23+
private validateInput(connectionString: string | undefined): string | undefined {
24+
connectionString = connectionString ? connectionString.trim() : '';
25+
26+
// Check for basic character length validation
27+
if (!validationUtils.hasValidCharLength(connectionString)) {
2628
return validationUtils.getInvalidCharLengthMessage();
2729
}
30+
31+
// Check if the connection string contains the required "Endpoint=" pattern
32+
const endpointMatch = connectionString.match(/Endpoint=([^;]+)/);
33+
if (!endpointMatch) {
34+
return localize('invalidDTSConnectionStringFormat', 'DTS connection string must contain an "Endpoint=" parameter. Expected format: "Endpoint=<URL>;Authentication=<AuthType>"');
35+
}
36+
37+
// Validate that the endpoint URL is properly formatted
38+
const endpoint = endpointMatch[1];
39+
try {
40+
const url = new URL(endpoint);
41+
// Ensure it's using a valid protocol
42+
if (!['http:', 'https:'].includes(url.protocol)) {
43+
return localize('invalidDTSEndpointProtocol', 'DTS endpoint must use HTTP or HTTPS protocol. Found: {0}', url.protocol);
44+
}
45+
} catch (error) {
46+
return localize('invalidDTSEndpointURL', 'DTS endpoint is not a valid URL: {0}', endpoint);
47+
}
48+
49+
// Check if the connection string contains an Authentication parameter
50+
if (!connectionString.match(/Authentication=/)) {
51+
return localize('missingDTSAuthentication', 'DTS connection string must contain an "Authentication=" parameter. Expected format: "Endpoint=<URL>;Authentication=<AuthType>"');
52+
}
53+
2854
return undefined;
2955
}
3056
}

0 commit comments

Comments
 (0)