From 78b5e755fde5b5da8819cce44b5a03fc34d77140 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra <13396919+cheenamalhotra@users.noreply.github.com> Date: Tue, 11 Jul 2023 17:29:50 -0700 Subject: [PATCH 1/2] Fix connection string related issues (#17737) --- src/models/connectionCredentials.ts | 16 +++++++++++++--- src/models/connectionInfo.ts | 25 +++++++------------------ src/models/connectionStore.ts | 4 ++-- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/models/connectionCredentials.ts b/src/models/connectionCredentials.ts index 3fd1474f9..dbca77250 100644 --- a/src/models/connectionCredentials.ts +++ b/src/models/connectionCredentials.ts @@ -252,7 +252,17 @@ export class ConnectionCredentials implements IConnectionInfo { } } }, - default: defaultProfileValues ? await connectionStore.lookupPassword(defaultProfileValues) : undefined + default: async (value) => { + if (value.connectionString) { + if ((value as IConnectionProfile).savePassword) { + // look up connection string + let connectionString = await connectionStore.lookupPassword(value, true); + value.connectionString = connectionString; + } + } else { + return await connectionStore.lookupPassword(value); + } + } } ]; return questions; @@ -298,8 +308,8 @@ export class ConnectionCredentials implements IConnectionInfo { public static isPasswordBasedConnectionString(connectionString: string): boolean { const connString = connectionString.toLowerCase(); - return connString.includes('user') && - connString.includes('password') && + return (connString.includes('user') || connString.includes('uid') || connString.includes('userid')) && + (connString.includes('password') || connString.includes('pwd')) && !connString.includes('Integrated Security'); } diff --git a/src/models/connectionInfo.ts b/src/models/connectionInfo.ts index 9d9d60b48..e3b3a5cb2 100644 --- a/src/models/connectionInfo.ts +++ b/src/models/connectionInfo.ts @@ -6,7 +6,7 @@ import { IConnectionInfo, IServerInfo } from 'vscode-mssql'; import * as Constants from '../constants/constants'; import * as LocalizedConstants from '../constants/localizedConstants'; -import { EncryptOptions, IConnectionProfile } from '../models/interfaces'; +import { EncryptOptions } from '../models/interfaces'; import * as Interfaces from './interfaces'; import * as Utils from './utils'; @@ -137,25 +137,14 @@ export function getPicklistDetails(connCreds: IConnectionInfo): string { */ export function getConnectionDisplayString(creds: IConnectionInfo): string { // Update the connection text - let text: string; - if (creds.connectionString) { - // If a connection string is present, try to display the profile name - if ((creds).profileName) { - text = (creds).profileName; - text = appendIfNotEmpty(text, creds.connectionString); - } else { - text = creds.connectionString; - } + let text: string = creds.server; + if (creds.database !== '') { + text = appendIfNotEmpty(text, creds.database); } else { - text = creds.server; - if (creds.database !== '') { - text = appendIfNotEmpty(text, creds.database); - } else { - text = appendIfNotEmpty(text, LocalizedConstants.defaultDatabaseLabel); - } - let user: string = getUserNameOrDomainLogin(creds); - text = appendIfNotEmpty(text, user); + text = appendIfNotEmpty(text, LocalizedConstants.defaultDatabaseLabel); } + let user: string = getUserNameOrDomainLogin(creds); + text = appendIfNotEmpty(text, user); // Limit the maximum length of displayed text if (text.length > Constants.maxDisplayedStatusTextLength) { diff --git a/src/models/connectionStore.ts b/src/models/connectionStore.ts index cc1cf9dcb..59ed1fcb4 100644 --- a/src/models/connectionStore.ts +++ b/src/models/connectionStore.ts @@ -72,7 +72,7 @@ export class ConnectionStore { * @returns {string} formatted string with server, DB and username */ public static formatCredentialId(server: string, database?: string, user?: string, itemType?: string, isConnectionString?: boolean): string { - if (Utils.isEmpty(server)) { + if (Utils.isEmpty(server) && !isConnectionString) { throw new ValidationException('Missing Server Name, which is required'); } let cred: string[] = [ConnectionStore.CRED_PREFIX]; @@ -116,7 +116,7 @@ export class ConnectionStore { * @returns {Promise} */ public getPickListItems(): IConnectionCredentialsQuickPickItem[] { - let pickListItems: IConnectionCredentialsQuickPickItem[] = this.loadAllConnections(true); + let pickListItems: IConnectionCredentialsQuickPickItem[] = this.loadAllConnections(false); pickListItems.push({ label: `$(add) ${LocalizedConstants.CreateProfileFromConnectionsListLabel}`, connectionCreds: undefined, From e299ccfe5cd0ec5cb15ae44853ccb1c3098b31c1 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Wed, 12 Jul 2023 00:16:37 -0700 Subject: [PATCH 2/2] Bump STS --- src/configurations/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/configurations/config.json b/src/configurations/config.json index 5309ce835..79c07e27e 100644 --- a/src/configurations/config.json +++ b/src/configurations/config.json @@ -1,7 +1,7 @@ { "service": { "downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/{#version#}/microsoft.sqltools.servicelayer-{#fileName#}", - "version": "4.8.0.39", + "version": "4.8.1.2", "downloadFileNames": { "Windows_86": "win-x86-net7.0.zip", "Windows_64": "win-x64-net7.0.zip",