From 64a7490364491ce5647bc8adc48fc51ceecf1beb Mon Sep 17 00:00:00 2001 From: Stuart Padley Date: Thu, 18 Jan 2024 04:26:48 -0800 Subject: [PATCH 1/2] Update nugets to latest (due to CVEs) --- Samples/Dapper/ElasticDapper.csproj | 4 ++-- .../EFCodeFirst/EntityFrameworkCodeFirst.csproj | 4 ++-- .../EntityFrameworkMultiTenant.csproj | 2 +- .../ElasticScaleStarterKit.csproj | 2 +- ...ft.Azure.SqlDatabase.ElasticScale.Client.csproj | 2 +- ...qlDatabase.ElasticScale.ClientTestCommon.csproj | 4 ++-- ...SqlDatabase.ElasticScale.Query.UnitTests.csproj | 8 ++++---- .../MultiShardTestUtils.cs | 6 ++++-- .../Globals.cs | 14 +++++++------- ...e.ElasticScale.ShardManagement.UnitTests.csproj | 8 ++++---- .../ScenarioTests.cs | 10 +++++----- .../ShardMapTests.cs | 4 ++-- 12 files changed, 35 insertions(+), 33 deletions(-) diff --git a/Samples/Dapper/ElasticDapper.csproj b/Samples/Dapper/ElasticDapper.csproj index 8305c65..f8c3657 100644 --- a/Samples/Dapper/ElasticDapper.csproj +++ b/Samples/Dapper/ElasticDapper.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/Samples/EFCodeFirst/EntityFrameworkCodeFirst.csproj b/Samples/EFCodeFirst/EntityFrameworkCodeFirst.csproj index bd76408..46fbc40 100644 --- a/Samples/EFCodeFirst/EntityFrameworkCodeFirst.csproj +++ b/Samples/EFCodeFirst/EntityFrameworkCodeFirst.csproj @@ -1,4 +1,4 @@ - + net6.0 Exe @@ -8,7 +8,7 @@ - + diff --git a/Samples/EFMultiTenant/EntityFrameworkMultiTenant.csproj b/Samples/EFMultiTenant/EntityFrameworkMultiTenant.csproj index 7a49864..0a758d9 100644 --- a/Samples/EFMultiTenant/EntityFrameworkMultiTenant.csproj +++ b/Samples/EFMultiTenant/EntityFrameworkMultiTenant.csproj @@ -8,7 +8,7 @@ - + diff --git a/Samples/ElasticScaleStarterKit/ElasticScaleStarterKit.csproj b/Samples/ElasticScaleStarterKit/ElasticScaleStarterKit.csproj index a523329..6114913 100644 --- a/Samples/ElasticScaleStarterKit/ElasticScaleStarterKit.csproj +++ b/Samples/ElasticScaleStarterKit/ElasticScaleStarterKit.csproj @@ -8,7 +8,7 @@ - + diff --git a/Src/ElasticScale.Client/Microsoft.Azure.SqlDatabase.ElasticScale.Client.csproj b/Src/ElasticScale.Client/Microsoft.Azure.SqlDatabase.ElasticScale.Client.csproj index 93282d5..b4c28bc 100644 --- a/Src/ElasticScale.Client/Microsoft.Azure.SqlDatabase.ElasticScale.Client.csproj +++ b/Src/ElasticScale.Client/Microsoft.Azure.SqlDatabase.ElasticScale.Client.csproj @@ -24,7 +24,7 @@ - + diff --git a/Test/ElasticScale.ClientTestCommon/Microsoft.Azure.SqlDatabase.ElasticScale.ClientTestCommon.csproj b/Test/ElasticScale.ClientTestCommon/Microsoft.Azure.SqlDatabase.ElasticScale.ClientTestCommon.csproj index cfb54d1..fbcc499 100644 --- a/Test/ElasticScale.ClientTestCommon/Microsoft.Azure.SqlDatabase.ElasticScale.ClientTestCommon.csproj +++ b/Test/ElasticScale.ClientTestCommon/Microsoft.Azure.SqlDatabase.ElasticScale.ClientTestCommon.csproj @@ -6,7 +6,7 @@ - - + + \ No newline at end of file diff --git a/Test/ElasticScale.Query.UnitTests/Microsoft.Azure.SqlDatabase.ElasticScale.Query.UnitTests.csproj b/Test/ElasticScale.Query.UnitTests/Microsoft.Azure.SqlDatabase.ElasticScale.Query.UnitTests.csproj index 97b9f29..e7623fb 100644 --- a/Test/ElasticScale.Query.UnitTests/Microsoft.Azure.SqlDatabase.ElasticScale.Query.UnitTests.csproj +++ b/Test/ElasticScale.Query.UnitTests/Microsoft.Azure.SqlDatabase.ElasticScale.Query.UnitTests.csproj @@ -7,10 +7,10 @@ - - - - + + + + diff --git a/Test/ElasticScale.Query.UnitTests/MultiShardTestUtils.cs b/Test/ElasticScale.Query.UnitTests/MultiShardTestUtils.cs index e012536..e16cb1b 100644 --- a/Test/ElasticScale.Query.UnitTests/MultiShardTestUtils.cs +++ b/Test/ElasticScale.Query.UnitTests/MultiShardTestUtils.cs @@ -47,12 +47,12 @@ internal static class MultiShardTestUtils /// /// Connection string for local shard user. /// - internal static string ShardConnectionString = @"Integrated Security=SSPI;"; + internal static string ShardConnectionString = @"Integrated Security=SSPI;TrustServerCertificate=True;"; /// /// Connection string for global shard map manager operations. /// - internal static string ShardMapManagerConnectionString = @"Data Source=localhost;Initial Catalog=ShardMapManager;Integrated Security=SSPI;"; + internal static string ShardMapManagerConnectionString = @"Data Source=localhost;Initial Catalog=ShardMapManager;Integrated Security=SSPI;TrustServerCertificate=True;"; /// /// Name of the database where the ShardMapManager persists its data. @@ -214,6 +214,8 @@ private static string GetTestConnectionString(string database) builder.DataSource = s_serverLocation; builder.IntegratedSecurity = true; builder.InitialCatalog = database; + builder.TrustServerCertificate = true; + return builder.ConnectionString; } diff --git a/Test/ElasticScale.ShardManagement.UnitTests/Globals.cs b/Test/ElasticScale.ShardManagement.UnitTests/Globals.cs index c706ca2..c66bb09 100644 --- a/Test/ElasticScale.ShardManagement.UnitTests/Globals.cs +++ b/Test/ElasticScale.ShardManagement.UnitTests/Globals.cs @@ -22,22 +22,22 @@ internal static class Globals /// /// Connection string for global shard map manager for Integrated Auth /// - private const string ShardMapManagerConnString = ShardMapManagerConnStringBase + "Integrated Security=SSPI;"; + private const string ShardMapManagerConnString = ShardMapManagerConnStringBase + "Integrated Security=SSPI;TrustServerCertificate=True;"; /// /// Connection string for global shard map manager for Sql Auth /// - private const string ShardMapManagerConnStringForSqlAuth = ShardMapManagerConnStringBase + "Integrated Security=False;"; + private const string ShardMapManagerConnStringForSqlAuth = ShardMapManagerConnStringBase + "Integrated Security=False;TrustServerCertificate=True;"; /// /// Connect string for local shard user. /// - private const string ShardUserConnString = @"Integrated Security=SSPI;"; + private const string ShardUserConnString = @"Integrated Security=SSPI;TrustServerCertificate=True;"; /// /// Connect string for local shard user. /// - private const string ShardUserConnStringForSqlAuth = @"User={0};Password={1}"; + private const string ShardUserConnStringForSqlAuth = @"User={0};Password={1};TrustServerCertificate=True;"; /// /// shardMapManager datasource name for unit tests. @@ -57,7 +57,7 @@ internal static class Globals /// /// Connection string for connecting to test server. /// - internal const string ShardMapManagerTestConnectionString = @"Data Source=" + Globals.ShardMapManagerTestsDatasourceName + ";Integrated Security=SSPI;"; + internal const string ShardMapManagerTestConnectionString = @"Data Source=" + Globals.ShardMapManagerTestsDatasourceName + ";Integrated Security=SSPI;TrustServerCertificate=True;"; /// /// Query to create database. @@ -111,13 +111,13 @@ internal static string ShardMapManagerConnectionString /// /// SMM shard connection string. /// - internal static string ShardUserConnectionStringForSqlAuth(string username) => + internal static string ShardUserConnectionStringForSqlAuth(string username) => string.Format(Globals.ShardUserConnStringForSqlAuth, username, SqlLoginTestPassword); /// /// The shard user credential for sql auth. /// - internal static SqlCredential ShardUserCredentialForSqlAuth(string username) => + internal static SqlCredential ShardUserCredentialForSqlAuth(string username) => new SqlCredential(username, GenerateSecureString(SqlLoginTestPassword)); /// diff --git a/Test/ElasticScale.ShardManagement.UnitTests/Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.UnitTests.csproj b/Test/ElasticScale.ShardManagement.UnitTests/Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.UnitTests.csproj index d755f90..a48a72e 100644 --- a/Test/ElasticScale.ShardManagement.UnitTests/Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.UnitTests.csproj +++ b/Test/ElasticScale.ShardManagement.UnitTests/Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.UnitTests.csproj @@ -1,4 +1,4 @@ - + net6.0 false @@ -8,9 +8,9 @@ - - - + + + diff --git a/Test/ElasticScale.ShardManagement.UnitTests/ScenarioTests.cs b/Test/ElasticScale.ShardManagement.UnitTests/ScenarioTests.cs index 26a1067..d24ebd1 100644 --- a/Test/ElasticScale.ShardManagement.UnitTests/ScenarioTests.cs +++ b/Test/ElasticScale.ShardManagement.UnitTests/ScenarioTests.cs @@ -308,14 +308,14 @@ public void BasicScenarioDefaultShardMaps() { // Also verify we can connect to the shard with Sql Auth, and Sql Auth using a secure credential using (shardForConnection.OpenConnectionAsync( - string.Empty, + "TrustServerCertificate=True;", Globals.ShardUserCredentialForSqlAuth(sqlAuthLogin.UniquifiedUserName), ConnectionOptions.None).Result) { } using (shardForConnection.OpenConnectionAsync( - string.Empty, + "TrustServerCertificate=True;", Globals.ShardUserCredentialForSqlAuth(sqlAuthLogin.UniquifiedUserName)).Result) { } @@ -1142,7 +1142,7 @@ public void BasicScenarioRangeShardMaps() // Cover the OpenConnectionForKey overloads using (SqlConnection conn = newMultiTenantShardMap.OpenConnectionForKey( 20, - string.Empty, + "TrustServerCertificate=True;", Globals.ShardUserCredentialForSqlAuth(sqlAuthLogin.UniquifiedUserName))) { } @@ -1237,7 +1237,7 @@ public void BasicScenarioRangeShardMaps() // Cover the OpenConnectionForKeyAsync overloads using (SqlConnection conn = multiTenantShardMap.OpenConnectionForKeyAsync( 20, - string.Empty, + "TrustServerCertificate=True;", Globals.ShardUserCredentialForSqlAuth(sqlAuthLogin.UniquifiedUserName), ConnectionOptions.None).Result) { @@ -1245,7 +1245,7 @@ public void BasicScenarioRangeShardMaps() using (SqlConnection conn = multiTenantShardMap.OpenConnectionForKeyAsync( 20, - string.Empty, + "TrustServerCertificate=True;", Globals.ShardUserCredentialForSqlAuth(sqlAuthLogin.UniquifiedUserName)).Result) { } diff --git a/Test/ElasticScale.ShardManagement.UnitTests/ShardMapTests.cs b/Test/ElasticScale.ShardManagement.UnitTests/ShardMapTests.cs index a1ee56a..a2bf280 100644 --- a/Test/ElasticScale.ShardManagement.UnitTests/ShardMapTests.cs +++ b/Test/ElasticScale.ShardManagement.UnitTests/ShardMapTests.cs @@ -221,12 +221,12 @@ public void CreateShardDefault() } // Validate that we can connect to the shard using a secure Sql Auth Credential - using (sNew.OpenConnection(string.Empty, Globals.ShardUserCredentialForSqlAuth(sqlAuthLogin.UniquifiedUserName))) + using (sNew.OpenConnection("TrustServerCertificate=True;", Globals.ShardUserCredentialForSqlAuth(sqlAuthLogin.UniquifiedUserName))) { } using (sNew.OpenConnection( - string.Empty, + "TrustServerCertificate=True;", Globals.ShardUserCredentialForSqlAuth(sqlAuthLogin.UniquifiedUserName), ConnectionOptions.Validate)) { From a91f82ea3ea6f76f9d3590cd4f813e5a515b17af Mon Sep 17 00:00:00 2001 From: Stuart Padley Date: Thu, 18 Jan 2024 04:29:26 -0800 Subject: [PATCH 2/2] Update nugets to latest (due to CVEs) --- .../Microsoft.Azure.SqlDatabase.ElasticScale.Client.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/ElasticScale.Client/Microsoft.Azure.SqlDatabase.ElasticScale.Client.csproj b/Src/ElasticScale.Client/Microsoft.Azure.SqlDatabase.ElasticScale.Client.csproj index b4c28bc..6900f98 100644 --- a/Src/ElasticScale.Client/Microsoft.Azure.SqlDatabase.ElasticScale.Client.csproj +++ b/Src/ElasticScale.Client/Microsoft.Azure.SqlDatabase.ElasticScale.Client.csproj @@ -5,7 +5,7 @@ © Microsoft Corporation. All rights reserved. Microsoft Azure SQL Database: Elastic Database Client Library en-US - 2.4.0 + 2.4.1-preview1 Microsoft net6.0 Microsoft;Elastic;Scale;Azure;SQL;DB;Database;Shard;Sharding;Management;Query;azureofficial