Skip to content

Commit 9eee761

Browse files
CopilotalexweiningerMicroFish91
authored
Add comprehensive validation for DTS connection strings including empty Authentication values (#4624)
* Initial plan * Add comprehensive DTS connection string validation Co-authored-by: alexweininger <[email protected]> * Revert main.js changes to use original extension loading mechanism Co-authored-by: MicroFish91 <[email protected]> * Add validation for empty Authentication parameter values in DTS connection strings Co-authored-by: MicroFish91 <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: alexweininger <[email protected]> Co-authored-by: MicroFish91 <[email protected]>
1 parent 8aae73a commit 9eee761

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

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

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,44 @@ export class DTSConnectionCustomPromptStep<T extends IDTSConnectionWizardContext
1919
return !context.newDTSConnectionSettingValue;
2020
}
2121

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

0 commit comments

Comments
 (0)