Skip to content

Add comprehensive validation for DTS connection strings including empty Authentication values #4624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 12, 2025
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,37 @@ export class DTSConnectionCustomPromptStep<T extends IDTSConnectionWizardContext
return !context.newDTSConnectionSetting && context.dtsConnectionType === ConnectionType.Custom;
}

private validateInput(name: string | undefined): string | undefined {
name = name ? name.trim() : '';
if (!validationUtils.hasValidCharLength(name)) {
private validateInput(connectionString: string | undefined): string | undefined {
connectionString = connectionString ? connectionString.trim() : '';

// Check for basic character length validation
if (!validationUtils.hasValidCharLength(connectionString)) {
return validationUtils.getInvalidCharLengthMessage();
}

// Check if the connection string contains the required "Endpoint=" pattern
const endpointMatch = connectionString.match(/Endpoint=([^;]+)/);
if (!endpointMatch) {
return localize('invalidDTSConnectionStringFormat', 'DTS connection string must contain an "Endpoint=" parameter. Expected format: "Endpoint=<URL>;Authentication=<AuthType>"');
}

// Validate that the endpoint URL is properly formatted
const endpoint = endpointMatch[1];
try {
const url = new URL(endpoint);
// Ensure it's using a valid protocol
if (!['http:', 'https:'].includes(url.protocol)) {
return localize('invalidDTSEndpointProtocol', 'DTS endpoint must use HTTP or HTTPS protocol. Found: {0}', url.protocol);
}
} catch (error) {
return localize('invalidDTSEndpointURL', 'DTS endpoint is not a valid URL: {0}', endpoint);
}

// Check if the connection string contains an Authentication parameter
if (!connectionString.match(/Authentication=/)) {
Copy link
Contributor

@MicroFish91 MicroFish91 Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Make sure to check after the suffix Authentication= to make sure there is actually a value on the other side of the equal sign. An empty equals value should not pass validation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added validation for empty Authentication parameter values. The validation now checks that there's a non-empty value after Authentication= and provides the error message "DTS Authentication parameter cannot be empty" when the value is missing or whitespace-only. Commit ea72aa6.

return localize('missingDTSAuthentication', 'DTS connection string must contain an "Authentication=" parameter. Expected format: "Endpoint=<URL>;Authentication=<AuthType>"');
}

return undefined;
}
}