Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ffb0965
Fix a tiny typo in RulesEngineTests
cheenamalhotra Sep 16, 2022
4d161a1
Update Microsoft.Data.SqlClient to v5.0.0
cheenamalhotra Sep 23, 2022
7c9c8b3
Merge branch 'main' into cheena/mds5
cheenamalhotra Sep 23, 2022
f3c63b1
Add comment for SmoMetadataProvider
cheenamalhotra Sep 23, 2022
2235ff9
Use compound assignment
cheenamalhotra Sep 23, 2022
594da4e
Add support for HostNameInCertificate
cheenamalhotra Sep 27, 2022
ebcb984
Update DacFx to latest
cheenamalhotra Sep 27, 2022
a88e24a
Merge branch 'main' of https://github.com/microsoft/sqltoolsservice i…
cheenamalhotra Oct 4, 2022
27b8696
Include SMO dependency
cheenamalhotra Oct 5, 2022
ff1a8bb
Address test failures
cheenamalhotra Oct 5, 2022
d451db4
Merge branch 'main' of https://github.com/microsoft/sqltoolsservice i…
cheenamalhotra Oct 11, 2022
90fa141
Update to MDS 5.0.1
cheenamalhotra Oct 12, 2022
1ea0bf7
Non breaking changes for backwards compatibility
cheenamalhotra Oct 12, 2022
9cd72bc
Update Migration Assessment NuGet to latest release
cheenamalhotra Oct 14, 2022
e4b6f8a
Touch-ups and remove asynchronous processing
cheenamalhotra Oct 14, 2022
d22f11c
Fix tests
cheenamalhotra Oct 14, 2022
c4d5b53
Update to latest SMO
cheenamalhotra Oct 18, 2022
9712a44
Review feedback
cheenamalhotra Oct 21, 2022
56505dc
Revert to TestCaseSource
cheenamalhotra Oct 21, 2022
3109939
Change back to EncryptOption for ADS compatibility
cheenamalhotra Oct 23, 2022
be04286
Review feedback
cheenamalhotra Oct 24, 2022
b4ca8e5
Update src/Microsoft.SqlTools.ManagedBatchParser/BatchParser/Executio…
cheenamalhotra Oct 24, 2022
445b9a7
Fix targets
cheenamalhotra Oct 24, 2022
0f284fa
Merge branch 'cheena/mds5' of https://github.com/microsoft/sqltoolsse…
cheenamalhotra Oct 24, 2022
4396e98
Touch ups
cheenamalhotra Oct 24, 2022
83fdaa2
Default to Optional Encrypt setting for test suite
cheenamalhotra Oct 24, 2022
90cdd43
Update to newer DacFx preview
cheenamalhotra Oct 25, 2022
56575db
Merge branch 'main' into cheena/mds5
cheenamalhotra Oct 25, 2022
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
16 changes: 8 additions & 8 deletions Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<PackageReference Update="System.IO.Packaging" Version="4.7.0" />
<PackageReference Update="System.Runtime.Loader" Version="4.3.0" />
<PackageReference Update="System.Composition" Version="1.4.1" />
<PackageReference Update="System.Security.Permissions" Version="4.7.0" />
<PackageReference Update="System.Text.Encoding.CodePages" Version="4.7.1" />
<PackageReference Update="System.Security.Permissions" Version="5.0.0" />
<PackageReference Update="System.Text.Encoding.CodePages" Version="5.0.0" />
<PackageReference Update="System.Text.Encodings.Web" Version="4.7.2" />
<PackageReference Update="System.Reactive.Core" Version="5.0.0" />

Expand All @@ -19,14 +19,14 @@
<PackageReference Update="Microsoft.Azure.Management.Sql" Version="1.41.0-preview" />

<PackageReference Update="Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider" Version="1.1.1" />
<PackageReference Update="Microsoft.Data.SqlClient" Version="3.1.1" />
<PackageReference Update="Microsoft.SqlServer.SqlManagementObjects" Version="161.47021.0" />
<PackageReference Update="Microsoft.SqlServer.Management.SmoMetadataProvider" Version="161.47008.0" />
<PackageReference Update="Microsoft.SqlServer.DACFx" Version="160.6295.0-preview" />
<PackageReference Update="Microsoft.Data.SqlClient" Version="5.0.1" />
<PackageReference Update="Microsoft.SqlServer.SqlManagementObjects" Version="170.8.0" />
<PackageReference Update="Microsoft.SqlServer.Management.SmoMetadataProvider" Version="170.8.0" />
<PackageReference Update="Microsoft.SqlServer.DacFx" Version="161.6337.0-preview" />
<PackageReference Update="Microsoft.Azure.Kusto.Data" Version="9.0.4" />
<PackageReference Update="Microsoft.Azure.Kusto.Language" Version="9.0.4" />
<PackageReference Update="Microsoft.SqlServer.Assessment" Version="[1.1.9]" />
<PackageReference Update="Microsoft.SqlServer.Migration.Assessment" Version="1.0.20220816.40" />
<PackageReference Update="Microsoft.SqlServer.Migration.Assessment" Version="1.0.20221014.16" />
<PackageReference Update="Microsoft.SqlServer.Management.SqlParser" Version="160.22519.0" />
<PackageReference Update="Microsoft.Azure.OperationalInsights" Version="1.0.0" />
<PackageReference Update="Microsoft.CodeAnalysis.CSharp" Version="3.10.0" />
Expand All @@ -45,4 +45,4 @@
<PackageReference Update="coverlet.collector" Version="3.1.2" />
<PackageReference Update="coverlet.msbuild" Version="3.1.2" />
</ItemGroup>
</Project>
</Project>
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,6 @@ internal static ConnectionProviderOptions BuildConnectionProviderOptions()
GroupName = "Initialization"
},
new ConnectionOption
{
Name = "asynchronousProcessing",
DisplayName = "Asynchronous processing enabled",
Description = "When true, enables usage of the Asynchronous functionality in the .Net Framework Data Provider",
ValueType = ConnectionOption.ValueTypeBoolean,
GroupName = "Initialization"
},
new ConnectionOption
{
Name = "connectTimeout",
DisplayName = "Connect timeout",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.OperationalInsights" />
<PackageReference Include="Microsoft.SqlServer.DACFx" />
<PackageReference Include="Microsoft.SqlServer.DacFx" />
<PackageReference Include="Microsoft.SqlServer.Management.SmoMetadataProvider" />
<PackageReference Include="Microsoft.SqlServer.SqlManagementObjects" />
<PackageReference Include="System.Text.Encoding.CodePages" />
<PackageReference Include="Microsoft.Azure.Kusto.Data" />
<PackageReference Include="System.Net.Http" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private static bool TryParseEnum<T>(Type t, string value, out object enumValue)
enumValue = Enum.Parse(t, value);
return true;
}
catch(Exception)
catch (Exception)
{
enumValue = default(T);
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,7 @@ private string GetFilePath(string fileName)
}

}
if (fullFileName == null)
{
fullFileName = Path.GetFullPath(fileName);
}

return fullFileName;
return fullFileName ?? Path.GetFullPath(fileName);
}
catch (ArgumentException)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,7 @@ internal int StartingLine

internal Dictionary<string, string> Variables
{
get
{
if (cmdVariables == null)
{
cmdVariables = new Dictionary<string, string>(StringComparer.CurrentCultureIgnoreCase);
}

return cmdVariables;
}
get => cmdVariables ??= new Dictionary<string, string>(StringComparer.CurrentCultureIgnoreCase);
}
#endregion
}
Expand Down
12 changes: 2 additions & 10 deletions src/Microsoft.SqlTools.ManagedBatchParser/BatchParser/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -608,18 +608,10 @@ private string ParsePassword()
}

internal void RaiseError(ErrorCode errorCode, string message = null)
{
RaiseError(errorCode, LookaheadToken, message);
}
=> RaiseError(errorCode, LookaheadToken, message);

internal static void RaiseError(ErrorCode errorCode, Token token, string message = null)
{
if (message == null)
{
message = string.Format(CultureInfo.CurrentCulture, SR.BatchParser_IncorrectSyntax, token.Text);
}
throw new BatchParserException(errorCode, token, message);
}
=> throw new BatchParserException(errorCode, token, message ?? string.Format(CultureInfo.CurrentCulture, SR.BatchParser_IncorrectSyntax, token.Text));

internal string ResolveVariables(Token inputToken, int offset, List<VariableReference> variableRefs)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- Targeting netstandard2.0 so that other things such as PS cmdlets can use this which need to support a wider range of machines -->
<TargetFramework>netstandard2.0</TargetFramework>
<!-- Targeting both net6.0 and net472 so that other things such as PS cmdlets can use this which need to support a wider range of machines -->
<TargetFrameworks>net6.0;net472</TargetFrameworks>
<LangVersion>9.0</LangVersion>
<Nullable>disable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,8 @@ public static object ExecuteNonQuery(
Debug.Assert(conn.State == ConnectionState.Open, "connection passed to ExecuteNonQuery should be open.");

cmd = conn.CreateCommand();
if (initializeCommand == null)
{
initializeCommand = SetCommandTimeout;
}

initializeCommand ??= SetCommandTimeout;
initializeCommand(cmd);

cmd.CommandText = commandText;
Expand Down Expand Up @@ -331,10 +329,8 @@ public static object ExecuteScalar(
Debug.Assert(conn.State == ConnectionState.Open, "connection passed to ExecuteScalar should be open.");

cmd = conn.CreateCommand();
if (initializeCommand == null)
{
initializeCommand = SetCommandTimeout;
}

initializeCommand ??= SetCommandTimeout;
initializeCommand(cmd);

cmd.CommandText = commandText;
Expand Down Expand Up @@ -384,11 +380,7 @@ public static void ExecuteReader(
{
cmd = conn.CreateCommand();

if (initializeCommand == null)
{
initializeCommand = SetCommandTimeout;
}

initializeCommand ??= SetCommandTimeout;
initializeCommand(cmd);

cmd.CommandText = commandText;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,7 @@ private void VerifyConnectionOpen(IDbCommand command)
{
// Verify whether or not the connection is valid and is open. This code may be retried therefore
// it is important to ensure that a connection is re-established should it have previously failed.
if (command.Connection == null)
{
command.Connection = this;
}
command.Connection ??= this;

if (command.Connection.State != ConnectionState.Open)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,6 @@ internal static ConnectionProviderOptions BuildConnectionProviderOptions()
GroupName = "Initialization"
},
new ConnectionOption
{
Name = "asynchronousProcessing",
DisplayName = "Asynchronous processing enabled",
Description = "When true, enables usage of the Asynchronous functionality in the .Net Framework Data Provider",
ValueType = ConnectionOption.ValueTypeBoolean,
GroupName = "Initialization"
},
new ConnectionOption
{
Name = "connectTimeout",
DisplayName = "Connect timeout",
Expand Down Expand Up @@ -152,10 +144,14 @@ internal static ConnectionProviderOptions BuildConnectionProviderOptions()
{
Name = "encrypt",
DisplayName = "Encrypt",
Description =
"When true, SQL Server uses SSL encryption for all data sent between the client and server if the servers has a certificate installed",
Description = "When set, SQL Server uses provided setting for SSL encryption for all data sent between the client and server.",
ValueType = ConnectionOption.ValueTypeCategory,
GroupName = "Security",
ValueType = ConnectionOption.ValueTypeBoolean
CategoryValues = new CategoryValue[] {
new CategoryValue { DisplayName = "Optional", Name = "Optional" },
new CategoryValue { DisplayName = "Mandatory", Name = "Mandatory" },
new CategoryValue { DisplayName = "Strict", Name = "Strict" }
}
},
new ConnectionOption
{
Expand All @@ -174,6 +170,14 @@ internal static ConnectionProviderOptions BuildConnectionProviderOptions()
ValueType = ConnectionOption.ValueTypeBoolean
},
new ConnectionOption
{
Name = "hostNameInCertificate",
DisplayName = "HostNameInCertificate",
Description = "Specifies host name in certificate to be used for certificate validation, when encryption is enabled.",
GroupName = "Security",
ValueType = ConnectionOption.ValueTypeString,
},
new ConnectionOption
{
Name = "attachedDBFileName",
DisplayName = "Attached DB file name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,8 @@ public virtual async Task<ConnectionCompleteParams> Connect(ConnectParams connec
if (response?.ErrorNumber == 40613)
{
counter++;
if(counter != MaxServerlessReconnectTries) {
if (counter != MaxServerlessReconnectTries)
{
Logger.Information($"Database for connection {connectionInfo.OwnerUri} is paused, retrying connection. Attempt #{counter}");
}
}
Expand Down Expand Up @@ -1299,14 +1300,26 @@ public static SqlConnectionStringBuilder CreateConnectionStringBuilder(Connectio

connectionBuilder.EnclaveAttestationUrl = connectionDetails.EnclaveAttestationUrl;
}
if (connectionDetails.Encrypt.HasValue)

if (!string.IsNullOrEmpty(connectionDetails.Encrypt))
{
connectionBuilder.Encrypt = connectionDetails.Encrypt.Value;
connectionBuilder.Encrypt = connectionDetails.Encrypt.ToLowerInvariant() switch
{
"optional" or "false" or "no" => SqlConnectionEncryptOption.Optional,
"mandatory" or "true" or "yes" => SqlConnectionEncryptOption.Mandatory,
"strict" => SqlConnectionEncryptOption.Strict,
_ => throw new ArgumentException(SR.ConnectionServiceConnStringInvalidEncryptOption(connectionDetails.Encrypt))
};
}

if (connectionDetails.TrustServerCertificate.HasValue)
{
connectionBuilder.TrustServerCertificate = connectionDetails.TrustServerCertificate.Value;
}
if (!string.IsNullOrEmpty(connectionDetails.HostNameInCertificate))
{
connectionBuilder.HostNameInCertificate = connectionDetails.HostNameInCertificate;
}
if (connectionDetails.PersistSecurityInfo.HasValue)
{
connectionBuilder.PersistSecurityInfo = connectionDetails.PersistSecurityInfo.Value;
Expand Down Expand Up @@ -1471,8 +1484,9 @@ public ConnectionDetails ParseConnectionString(string connectionString)
ColumnEncryptionSetting = builder.ColumnEncryptionSetting.ToString(),
EnclaveAttestationProtocol = builder.AttestationProtocol == SqlConnectionAttestationProtocol.NotSpecified ? null : builder.AttestationProtocol.ToString(),
EnclaveAttestationUrl = builder.EnclaveAttestationUrl,
Encrypt = builder.Encrypt,
Encrypt = builder.Encrypt.ToString(),
FailoverPartner = builder.FailoverPartner,
HostNameInCertificate = builder.HostNameInCertificate,
LoadBalanceTimeout = builder.LoadBalanceTimeout,
MaxPoolSize = builder.MaxPoolSize,
MinPoolSize = builder.MinPoolSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ public string EnclaveAttestationUrl
}

/// <summary>
/// Gets or sets a Boolean value that indicates whether SQL Server uses SSL encryption for all data sent between the client and server if the server has a certificate installed.
/// Gets or sets a <see cref="string"/> value that indicates encryption mode that SQL Server should use to perform SSL encryption for all the data sent between the client and server. Supported values are: Optional, Mandatory, Strict.
/// </summary>
public bool? Encrypt
public string Encrypt
{
get
{
return GetOptionValue<bool?>("encrypt");
return GetOptionValue<string>("encrypt");
}

set
Expand All @@ -178,6 +178,22 @@ public bool? TrustServerCertificate
}
}

/// <summary>
/// Gets or sets a value that indicates the host name in the certificate to be used for certificate validation when encryption is enabled.
/// </summary>
public string HostNameInCertificate
{
get
{
return GetOptionValue<string>("hostNameInCertificate");
}

set
{
SetOptionValue("hostNameInCertificate", value);
}
}

/// <summary>
/// Gets or sets a Boolean value that indicates if security-sensitive information, such as the password, is not returned as part of the connection if the connection is open or has ever been in an open state.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static ConnectionDetails Clone(this ConnectionDetails details)
EnclaveAttestationUrl = details.EnclaveAttestationUrl,
Encrypt = details.Encrypt,
TrustServerCertificate = details.TrustServerCertificate,
HostNameInCertificate = details.HostNameInCertificate,
PersistSecurityInfo = details.PersistSecurityInfo,
ConnectTimeout = details.ConnectTimeout,
ConnectRetryCount = details.ConnectRetryCount,
Expand Down
8 changes: 8 additions & 0 deletions src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9641,6 +9641,11 @@ public static string ConnectionServiceConnStringInvalidColumnEncryptionSetting(s
return Keys.GetString(Keys.ConnectionServiceConnStringInvalidColumnEncryptionSetting, columnEncryptionSetting);
}

public static string ConnectionServiceConnStringInvalidEncryptOption(string encrypt)
{
return Keys.GetString(Keys.ConnectionServiceConnStringInvalidEncryptOption, encrypt);
}

public static string ConnectionServiceConnStringInvalidEnclaveAttestationProtocol(string enclaveAttestationProtocol)
{
return Keys.GetString(Keys.ConnectionServiceConnStringInvalidEnclaveAttestationProtocol, enclaveAttestationProtocol);
Expand Down Expand Up @@ -10062,6 +10067,9 @@ public class Keys
public const string ConnectionServiceConnStringInvalidColumnEncryptionSetting = "ConnectionServiceConnStringInvalidColumnEncryptionSetting";


public const string ConnectionServiceConnStringInvalidEncryptOption = "ConnectionServiceConnStringInvalidEncryptOption";


public const string ConnectionServiceConnStringInvalidEnclaveAttestationProtocol = "ConnectionServiceConnStringInvalidEnclaveAttestationProtocol";


Expand Down
5 changes: 5 additions & 0 deletions src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@
<value>Invalid value &apos;{0}&apos; for ComlumEncryption. Valid values are &apos;Enabled&apos; and &apos;Disabled&apos;.</value>
<comment>.
Parameters: 0 - columnEncryptionSetting (string) </comment>
</data>
<data name="ConnectionServiceConnStringInvalidEncryptOption" xml:space="preserve">
<value>Invalid value &apos;{0}&apos; for Encrypt. Valid values are &apos;Optional&apos;, &apos;Mandatory&apos;, &apos;Strict&apos;, &apos;True&apos;, &apos;False&apos;, &apos;Yes&apos; and &apos;No&apos;.</value>
<comment>.
Parameters: 0 - encrypt (string) </comment>
</data>
<data name="ConnectionServiceConnStringInvalidEnclaveAttestationProtocol" xml:space="preserve">
<value>Invalid value &apos;{0}&apos; for EnclaveAttestationProtocol. Valid values are &apos;AAS&apos; and &apos;HGS&apos;.</value>
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ ConnectionServiceConnStringInvalidAuthType(string authType) = Invalid value '{0}

ConnectionServiceConnStringInvalidColumnEncryptionSetting(string columnEncryptionSetting) = Invalid value '{0}' for ComlumEncryption. Valid values are 'Enabled' and 'Disabled'.

ConnectionServiceConnStringInvalidEncryptOption(string encrypt) = Invalid value '{0}' for Encrypt. Valid values are 'Optional', 'Mandatory', 'Strict', 'True', 'False', 'Yes' and 'No'.

ConnectionServiceConnStringInvalidEnclaveAttestationProtocol(string enclaveAttestationProtocol) = Invalid value '{0}' for EnclaveAttestationProtocol. Valid values are 'AAS' and 'HGS'.

ConnectionServiceConnStringInvalidAlwaysEncryptedOptionCombination = The Attestation Protocol and Enclave Attestation URL requires Always Encrypted to be set to Enabled.
Expand Down
Loading