Skip to content
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

Add new Attestation Protocol "None" - phase 2 #1425

Merged
merged 38 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b1d3720
Add test coverage to SqlCollation for FirstSupportedCollationVersion …
lcheunglci Oct 25, 2021
92897eb
Merge branch 'main' into Test-CodeCoverage
lcheunglci Oct 25, 2021
02a65c6
Add tests to SqlConnectionStringBuilder to all properties that throws…
lcheunglci Oct 26, 2021
16c0a64
Add a test cases for SqlClientLogger for code coverage
lcheunglci Oct 26, 2021
60172e4
Add code coverage for SqlClientFactory covering CreateDataSourceEnume…
lcheunglci Oct 26, 2021
296049b
Add tests to SqlParameterCollection for code coverage
lcheunglci Oct 27, 2021
2d57ffe
Add missing code coverage to SqlCommandSet
lcheunglci Oct 29, 2021
dfd6457
Merge branch 'main' into Test-CodeCoverage-part1
lcheunglci Nov 1, 2021
8b5ee21
remove unnecessary asserts
Nov 17, 2021
b0ba491
Update Microsoft.Data.SqlClient.csproj
Nov 17, 2021
7bce454
Merge remote-tracking branch 'upstream/main'
Nov 18, 2021
cd4aea7
Merge remote-tracking branch 'upstream/main'
Nov 23, 2021
2c09672
Merge remote-tracking branch 'upstream/main'
Nov 24, 2021
965ce94
Merge remote-tracking branch 'upstream/main'
Nov 24, 2021
7179deb
Merge remote-tracking branch 'upstream/main'
Nov 25, 2021
5fcaab3
rename simulator enclave provider
Dec 2, 2021
a39aa88
Update EnclaveDelegate.Crypto.cs
Dec 2, 2021
7d95c36
Update EnclaveDelegate.Crypto.cs
Dec 2, 2021
a4d148a
use Array.Empty<byte>()
Dec 2, 2021
0be73d5
docs
Dec 2, 2021
b4fc190
use enum for protocol id fields
Dec 3, 2021
b22043f
Merge branch 'rename-sim' into none-attest
Dec 3, 2021
d0e204d
netcore
Dec 3, 2021
7860792
tests
Dec 7, 2021
89e4932
Update SqlDbManager.cs
Dec 7, 2021
b91f065
netfx changes
Dec 8, 2021
b269df6
Update SqlDbManager.cs
Dec 8, 2021
8ef2990
Update ExceptionTest.cs
Dec 8, 2021
e67ad3f
Merge remote-tracking branch 'upstream/main'
Jan 4, 2022
a81882b
Merge branch 'main' into none-attest
Jan 5, 2022
a46a7e7
Update src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ExceptionTe…
Jan 5, 2022
7e86666
Merge branch 'main' into none-attest
Jan 17, 2022
b435719
Merge remote-tracking branch 'upstream/main'
Jan 17, 2022
1da26b1
Merge branch 'main' into none-attest
Jan 17, 2022
806eca7
address feedback
Jan 19, 2022
6c1e080
address feedback
Jan 21, 2022
019200c
update tests
Jan 21, 2022
f226666
Update src/Microsoft.Data.SqlClient/tests/FunctionalTests/AlwaysEncry…
Jan 24, 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
2 changes: 1 addition & 1 deletion doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ End Module
|Application Intent<br /><br /> -or-<br /><br />ApplicationIntent|ReadWrite|Declares the application workload type when connecting to a server. Possible values are `ReadOnly` and `ReadWrite`. For example:<br /><br /> `ApplicationIntent=ReadOnly`<br /><br /> For more information about SqlClient support for Always On Availability Groups, see [SqlClient Support for High Availability, Disaster Recovery](/sql/connect/ado-net/sql/sqlclient-support-high-availability-disaster-recovery).|
|Application Name|N/A|The name of the application. If no application name is provided, 'Framework Microsoft SqlClient Data Provider' when running on .NET Framework and 'Core Microsoft SqlClient Data Provider' otherwise.<br /><br /> An application name can be 128 characters or less.|
|AttachDBFilename<br /><br /> -or-<br /><br /> Extended Properties<br /><br /> -or-<br /><br /> Initial File Name|N/A|The name of the primary database file, including the full path name of an attachable database. AttachDBFilename is only supported for primary data files with an .mdf extension.<br /><br /> If the value of the AttachDBFileName key is specified in the connection string, the database is attached and becomes the default database for the connection.<br /><br /> If this key is not specified and if the database was previously attached, the database will not be reattached. The previously attached database will be used as the default database for the connection.<br /><br /> If this key is specified together with the AttachDBFileName key, the value of this key will be used as the alias. However, if the name is already used in another attached database, the connection will fail.<br /><br /> The path may be absolute or relative by using the DataDirectory substitution string. If DataDirectory is used, the database file must exist within a subdirectory of the directory pointed to by the substitution string. **Note:** Remote server, HTTP, and UNC path names are not supported. <br /><br /> The database name must be specified with the keyword 'database' (or one of its aliases) as in the following:<br /><br /> <code>"AttachDbFileName=&#124;DataDirectory&#124;\data\YourDB.mdf;integrated security=true;database=YourDatabase"</code><br /><br /> An error will be generated if a log file exists in the same directory as the data file and the 'database' keyword is used when attaching the primary data file. In this case, remove the log file. Once the database is attached, a new log file will be automatically generated based on the physical path.|
|Attestation Protocol|N/A|Gets or sets the value of Attestation Protocol.<br /><br />Valid values are:<br />`AAS`<br />`HGS`|
|Attestation Protocol|N/A|Gets or sets the value of Attestation Protocol.<br /><br />Valid values are:<br />`AAS`<br />`HGS`<br />`None`|
|Authentication|N/A|The authentication method used for [Connecting to SQL Database By Using Azure Active Directory Authentication](https://azure.microsoft.com/documentation/articles/sql-database-aad-authentication/#7-connect-to-your-database-by-using-azure-active-directory-identities).<br /><br /> Valid values are:<br /><br /> `Active Directory Integrated`, `Active Directory Interactive`, `Active Directory Password`, `Active Directory Service Principal`, `Active Directory Device Code Flow`, `Active Directory Managed Identity`, `Active Directory MSI`, `Active Directory Default`, `Sql Password`.|
|Column Encryption Setting|disabled|Enables or disables [Always Encrypted](/sql/relational-databases/security/encryption/always-encrypted-database-engine) functionality for the connection. Supported values are: `enabled` and `disabled`|
|Command Timeout|30|The default wait time (in seconds) before terminating the attempt to execute a command and generating an error.<br /><br /> Valid values are greater than or equal to 0 and less than or equal to 2147483647.|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<summary>Attestation portocol for Azure Attestation Service</summary>
<value>1</value>
</AAS>
<SIM>
<summary>Attestation protocol for Simulator</summary>
<None>
<summary>Attestation protocol for no attestation. Only compatible with Virtualization-based security (VBS) enclaves. An Enclave Attestation Url is not required when using this protocol.</summary>
<value>2</value>
</SIM>
</None>
<HGS>
<summary>Attestation protocol for Host Guardian Service</summary>
<value>3</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,8 @@ public enum SqlConnectionAttestationProtocol
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/AAS/*' />
AAS = 1,

#if ENCLAVE_SIMULATOR
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/SIM/*' />
SIM = 2,
#endif
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/None/*' />
None = 2,

/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/HGS/*' />
HGS = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ internal bool IsColumnEncryptionEnabled

internal bool ShouldUseEnclaveBasedWorkflow
{
get { return !string.IsNullOrWhiteSpace(_activeConnection.EnclaveAttestationUrl) && IsColumnEncryptionEnabled; }
get { return (!string.IsNullOrWhiteSpace(_activeConnection.EnclaveAttestationUrl) || Connection.AttestationProtocol == SqlConnectionAttestationProtocol.None) &&
IsColumnEncryptionEnabled; }
}

/// <summary>
Expand Down Expand Up @@ -4211,7 +4212,7 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi

if (isRequestedByEnclave)
{
if (string.IsNullOrWhiteSpace(this.Connection.EnclaveAttestationUrl))
if (string.IsNullOrWhiteSpace(this.Connection.EnclaveAttestationUrl) && Connection.AttestationProtocol != SqlConnectionAttestationProtocol.None)
{
throw SQL.NoAttestationUrlSpecifiedForEnclaveBasedQuerySpDescribe(this._activeConnection.Parser.EnclaveType);
}
Expand Down Expand Up @@ -4636,8 +4637,11 @@ private void GenerateEnclavePackage()
return;
}

if (string.IsNullOrWhiteSpace(this._activeConnection.EnclaveAttestationUrl))
if (string.IsNullOrWhiteSpace(this._activeConnection.EnclaveAttestationUrl) &&
Connection.AttestationProtocol != SqlConnectionAttestationProtocol.None)
{
throw SQL.NoAttestationUrlSpecifiedForEnclaveBasedQueryGeneratingEnclavePackage(this._activeConnection.Parser.EnclaveType);
}

string enclaveType = this._activeConnection.Parser.EnclaveType;
if (string.IsNullOrWhiteSpace(enclaveType))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1070,10 +1070,8 @@ public enum SqlConnectionAttestationProtocol
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/AAS/*' />
AAS = 1,

#if ENCLAVE_SIMULATOR
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/SIM/*' />
SIM = 2,
#endif
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/None/*' />
None = 2,

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/HGS/*' />
HGS = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3167,22 +3167,22 @@ private bool TryProcessFeatureExtAck(TdsParserStateObject stateObj)
if (TceVersionSupported < TdsEnums.MIN_TCE_VERSION_WITH_ENCLAVE_SUPPORT)
{
// Check if enclave attestation url was specified and server does not support enclave computations and we aren't going to be routed to another server.
if (!string.IsNullOrWhiteSpace(_connHandler.ConnectionOptions.EnclaveAttestationUrl) && SqlConnectionAttestationProtocol.NotSpecified != attestationProtocol)
if (!string.IsNullOrWhiteSpace(_connHandler.ConnectionOptions.EnclaveAttestationUrl) && attestationProtocol != SqlConnectionAttestationProtocol.NotSpecified)
{
throw SQL.EnclaveComputationsNotSupported();
}
else if (!string.IsNullOrWhiteSpace(_connHandler.ConnectionOptions.EnclaveAttestationUrl))
{
throw SQL.AttestationURLNotSupported();
}
else if (SqlConnectionAttestationProtocol.NotSpecified != _connHandler.ConnectionOptions.AttestationProtocol)
else if (_connHandler.ConnectionOptions.AttestationProtocol != SqlConnectionAttestationProtocol.NotSpecified)
{
throw SQL.AttestationProtocolNotSupported();
}
}

// Check if enclave attestation url was specified and server does not return an enclave type and we aren't going to be routed to another server.
if (!string.IsNullOrWhiteSpace(_connHandler.ConnectionOptions.EnclaveAttestationUrl))
if (!string.IsNullOrWhiteSpace(_connHandler.ConnectionOptions.EnclaveAttestationUrl) || attestationProtocol == SqlConnectionAttestationProtocol.None)
{
if (string.IsNullOrWhiteSpace(EnclaveType))
{
Expand All @@ -3208,10 +3208,8 @@ private bool IsValidAttestationProtocol(SqlConnectionAttestationProtocol attesta
{
case TdsEnums.ENCLAVE_TYPE_VBS:
if (attestationProtocol != SqlConnectionAttestationProtocol.AAS
#if ENCLAVE_SIMULATOR
&& attestationProtocol != SqlConnectionAttestationProtocol.SIM
#endif
&& attestationProtocol != SqlConnectionAttestationProtocol.HGS)
&& attestationProtocol != SqlConnectionAttestationProtocol.HGS
&& attestationProtocol != SqlConnectionAttestationProtocol.None)
{
return false;
}
Expand All @@ -3220,7 +3218,7 @@ private bool IsValidAttestationProtocol(SqlConnectionAttestationProtocol attesta
case TdsEnums.ENCLAVE_TYPE_SGX:
#if ENCLAVE_SIMULATOR
if (attestationProtocol != SqlConnectionAttestationProtocol.AAS
&& attestationProtocol != SqlConnectionAttestationProtocol.SIM)
&& attestationProtocol != SqlConnectionAttestationProtocol.None)
#else
if (attestationProtocol != SqlConnectionAttestationProtocol.AAS)
#endif
Expand All @@ -3231,7 +3229,7 @@ private bool IsValidAttestationProtocol(SqlConnectionAttestationProtocol attesta

#if ENCLAVE_SIMULATOR
case TdsEnums.ENCLAVE_TYPE_SIMULATOR:
if (attestationProtocol != SqlConnectionAttestationProtocol.SIM)
if (attestationProtocol != SqlConnectionAttestationProtocol.None)
{
return false;
}
Expand All @@ -3255,10 +3253,8 @@ private string ConvertAttestationProtocolToString(SqlConnectionAttestationProtoc
case SqlConnectionAttestationProtocol.HGS:
return "HGS";

#if ENCLAVE_SIMULATOR
case SqlConnectionAttestationProtocol.SIM:
return "SIM";
#endif
case SqlConnectionAttestationProtocol.None:
johnnypham marked this conversation as resolved.
Show resolved Hide resolved
return "None";

default:
return "NotSpecified";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -889,10 +889,8 @@ public enum SqlConnectionAttestationProtocol
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/AAS/*' />
AAS = 1,

#if ENCLAVE_SIMULATOR
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/SIM/*' />
SIM = 2,
#endif
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/None/*' />
None = 2,

/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/HGS/*' />
HGS = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ internal bool IsColumnEncryptionEnabled

internal bool ShouldUseEnclaveBasedWorkflow
{
get { return !string.IsNullOrWhiteSpace(_activeConnection.EnclaveAttestationUrl) && IsColumnEncryptionEnabled; }
get
{
return (!string.IsNullOrWhiteSpace(_activeConnection.EnclaveAttestationUrl) || Connection.AttestationProtocol == SqlConnectionAttestationProtocol.None) &&
IsColumnEncryptionEnabled;
}
johnnypham marked this conversation as resolved.
Show resolved Hide resolved
}

internal ConcurrentDictionary<int, SqlTceCipherInfoEntry> keysToBeSentToEnclave;
Expand Down Expand Up @@ -4780,7 +4784,7 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi

if (isRequestedByEnclave)
{
if (string.IsNullOrWhiteSpace(this.Connection.EnclaveAttestationUrl))
if (string.IsNullOrWhiteSpace(this.Connection.EnclaveAttestationUrl) && Connection.AttestationProtocol != SqlConnectionAttestationProtocol.None)
{
throw SQL.NoAttestationUrlSpecifiedForEnclaveBasedQuerySpDescribe(this._activeConnection.Parser.EnclaveType);
}
Expand Down Expand Up @@ -5244,8 +5248,11 @@ private void GenerateEnclavePackage()
return;
}

if (string.IsNullOrWhiteSpace(this._activeConnection.EnclaveAttestationUrl))
if (string.IsNullOrWhiteSpace(this._activeConnection.EnclaveAttestationUrl) &&
Connection.AttestationProtocol != SqlConnectionAttestationProtocol.None)
{
throw SQL.NoAttestationUrlSpecifiedForEnclaveBasedQueryGeneratingEnclavePackage(this._activeConnection.Parser.EnclaveType);
}

string enclaveType = this._activeConnection.Parser.EnclaveType;
if (string.IsNullOrWhiteSpace(enclaveType))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1069,10 +1069,8 @@ public enum SqlConnectionAttestationProtocol
/// <include file='..\..\..\..\..\..\..\doc\snippets\Microsoft.Data.SqlClient\SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/AAS/*' />
AAS = 1,

#if ENCLAVE_SIMULATOR
/// <include file='..\..\..\..\..\..\..\doc\snippets\Microsoft.Data.SqlClient\SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/SIM/*' />
SIM = 2,
#endif
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/None/*' />
johnnypham marked this conversation as resolved.
Show resolved Hide resolved
None = 2,

/// <include file='..\..\..\..\..\..\..\doc\snippets\Microsoft.Data.SqlClient\SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/HGS/*' />
HGS = 3
Expand Down
Loading