diff --git a/doc/snippets/Microsoft.Data.SqlClient.DataClassification/ColumnSensitivity.xml b/doc/snippets/Microsoft.Data.SqlClient.DataClassification/ColumnSensitivity.xml index 8f1fcfeb99..2c43af620c 100644 --- a/doc/snippets/Microsoft.Data.SqlClient.DataClassification/ColumnSensitivity.xml +++ b/doc/snippets/Microsoft.Data.SqlClient.DataClassification/ColumnSensitivity.xml @@ -3,15 +3,14 @@ Represents the Data Classification Sensitivity Information for columns as configured in Database. - To be added. Initializes a new instance of the class. + List of sensitivity properties. Returns the list of sensitivity properties as received from Server for this 'ColumnSensitivity' information List of sensitivity properties. - To be added. diff --git a/doc/snippets/Microsoft.Data.SqlClient.DataClassification/InformationType.xml b/doc/snippets/Microsoft.Data.SqlClient.DataClassification/InformationType.xml index db93a31054..ff2dca0c3c 100644 --- a/doc/snippets/Microsoft.Data.SqlClient.DataClassification/InformationType.xml +++ b/doc/snippets/Microsoft.Data.SqlClient.DataClassification/InformationType.xml @@ -3,20 +3,19 @@ Represents the Data Classification Information Types as received from SQL Server for the active 'SqlDataReader' - To be added. Initializes a new instance of the class. + Name of Information Type. + ID of Information Type. Gets the ID for this 'InformationType' object - ID of InformationType. - To be added. + ID of Information Type. Gets the name for this 'InformationType' object - Name of InformationType. - To be added. + Name of Information Type. diff --git a/doc/snippets/Microsoft.Data.SqlClient.DataClassification/Label.xml b/doc/snippets/Microsoft.Data.SqlClient.DataClassification/Label.xml index 6ccdecde4d..7d75923abe 100644 --- a/doc/snippets/Microsoft.Data.SqlClient.DataClassification/Label.xml +++ b/doc/snippets/Microsoft.Data.SqlClient.DataClassification/Label.xml @@ -3,20 +3,19 @@ Initializes a new instance of the class. + Name of label. + ID of label. Gets the ID for this 'Label' object ID of label. - To be added. Gets the name for this 'Label' object Name of label. - To be added. diff --git a/doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityClassification.xml b/doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityClassification.xml index e9c6e90b2e..83707533b1 100644 --- a/doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityClassification.xml +++ b/doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityClassification.xml @@ -3,26 +3,47 @@ Provides the functionlity to retrieve Sensitivity Classification data as received from SQL Server for the active 'SqlDataReader' - To be added. Returns the column sensitivity for this 'SensitivityClassification' Object List of column sensitivities. - To be added. Returns the information types collection for this 'SensitivityClassification' Object List of information types. - To be added. Returns the labels collection for this 'SensitivityClassification' Object List of labels. - To be added. + + Returns the relative sensitivity rank for the query associated with the active 'SqlDataReader'. + Relative sensitivity ranking for this query. + + + + + + - Initializes a new instance of the - class. + Initializes a new instance of the class. + List of labels. + List of information types. + List of column sensitivities. + Relative sensitivity rank for the query associated with the active 'SqlDataReader'. diff --git a/doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityProperty.xml b/doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityProperty.xml index b54c8384b9..5fb61f161c 100644 --- a/doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityProperty.xml +++ b/doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityProperty.xml @@ -3,20 +3,42 @@ Represents the Data Classification Sensitivity Information for columns as configured in Database. - To be added. Initializes a new instance of the class. + Label for this SensitivityProperty. + Information type for this SensitivityProperty. + Sensitivity rank for this SensitivityProperty. Returns the information type for this 'SensitivityProperty' Object Information type for this SensitivityProperty. - To be added. + + Returns the sensitivity rank for this 'SensitivityProperty' Object + Sensitivity rank for this SensitivityProperty. + + + + + + diff --git a/doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml b/doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml new file mode 100644 index 0000000000..41e215e29e --- /dev/null +++ b/doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml @@ -0,0 +1,17 @@ + + + + + + A relative ranking of the sensitivity of a query or of a column that is part of percolumn data. + It is an identifier based on a predefined set of values which define sensitivity rank. Used by other services like Advanced Threat Protection to detect anomalies based on their rank. + + + No sensitivity rank defined. + Corresponds to rank value of 0. + Corresponds to rank value of 10. + Corresponds to rank value 20. + Corresponds to rank value 30. + Corresponds to rank value 40. + + diff --git a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs index 8b53ecfdf6..514a35ad36 100644 --- a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs +++ b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs @@ -1895,26 +1895,46 @@ public Label(string name, string id) { } /// public string Name { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } } } + /// + public enum SensitivityRank + { + /// + NOT_DEFINED = -1, + /// + NONE = 0, + /// + LOW = 10, + /// + MEDIUM = 20, + /// + HIGH = 30, + /// + CRITICAL = 40 + } /// public partial class SensitivityClassification { /// - public SensitivityClassification(System.Collections.Generic.IList labels, System.Collections.Generic.IList informationTypes, System.Collections.Generic.IList columnSensitivity) { } + public SensitivityClassification(System.Collections.Generic.IList labels, System.Collections.Generic.IList informationTypes, System.Collections.Generic.IList columnSensitivity, SensitivityRank sensitivityRank) { } /// public System.Collections.ObjectModel.ReadOnlyCollection ColumnSensitivities { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } } /// public System.Collections.ObjectModel.ReadOnlyCollection InformationTypes { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } } /// public System.Collections.ObjectModel.ReadOnlyCollection Labels { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } } + /// + public SensitivityRank SensitivityRank { get { throw null; } } } /// public partial class SensitivityProperty { /// - public SensitivityProperty(Microsoft.Data.SqlClient.DataClassification.Label label, Microsoft.Data.SqlClient.DataClassification.InformationType informationType) { } + public SensitivityProperty(Microsoft.Data.SqlClient.DataClassification.Label label, Microsoft.Data.SqlClient.DataClassification.InformationType informationType, SensitivityRank sensitivityRank) { } /// public Microsoft.Data.SqlClient.DataClassification.InformationType InformationType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } } /// public Microsoft.Data.SqlClient.DataClassification.Label Label { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } } + /// + public SensitivityRank SensitivityRank { get { throw null; } } } } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs index 4525d4c75d..ccf7853165 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs @@ -129,7 +129,6 @@ sealed internal class SqlInternalConnectionTds : SqlInternalConnection, IDisposa private readonly SqlAuthenticationProviderManager _sqlAuthenticationProviderManager; internal bool _cleanSQLDNSCaching = false; - private bool _serverSupportsDNSCaching = false; /// @@ -2610,7 +2609,7 @@ internal void OnFeatureExtAck(int featureId, byte[] data) throw SQL.ParsingError(ParsingErrorState.CorruptedTdsStream); } byte supportedDataClassificationVersion = data[0]; - if ((0 == supportedDataClassificationVersion) || (supportedDataClassificationVersion > TdsEnums.MAX_SUPPORTED_DATA_CLASSIFICATION_VERSION)) + if ((0 == supportedDataClassificationVersion) || (supportedDataClassificationVersion > TdsEnums.DATA_CLASSIFICATION_VERSION_MAX_SUPPORTED)) { SqlClientEventSource.Log.TraceEvent(" {0}, Invalid version number for DATACLASSIFICATION", ObjectID); throw SQL.ParsingErrorValue(ParsingErrorState.DataClassificationInvalidVersion, supportedDataClassificationVersion); diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsEnums.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsEnums.cs index 25dbb5dd76..043a70669d 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsEnums.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsEnums.cs @@ -933,7 +933,8 @@ internal enum FedAuthInfoId : byte // Data Classification constants internal const byte DATA_CLASSIFICATION_NOT_ENABLED = 0x00; - internal const byte MAX_SUPPORTED_DATA_CLASSIFICATION_VERSION = 0x01; + internal const byte DATA_CLASSIFICATION_VERSION_WITHOUT_RANK_SUPPORT = 0x01; + internal const byte DATA_CLASSIFICATION_VERSION_MAX_SUPPORTED = 0x02; // Needed for UapAot, since we cannot use Enum.GetName() on SniContext. // Enum.GetName() uses reflection, which is blocked on UapAot for internal types diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs index 9070b88fa6..a1d424120e 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs @@ -471,13 +471,13 @@ internal void Connect( uint result = _physicalStateObj.SniGetConnectionId(ref _connHandler._clientConnectionId); Debug.Assert(result == TdsEnums.SNI_SUCCESS, "Unexpected failure state upon calling SniGetConnectionId"); - + if (null == _connHandler.pendingSQLDNSObject) { // for DNS Caching phase 1 _physicalStateObj.AssignPendingDNSInfo(serverInfo.UserProtocol, FQDNforDNSCahce, ref _connHandler.pendingSQLDNSObject); } - + SqlClientEventSource.Log.TraceEvent(" Sending prelogin handshake", "SEC"); SendPreLoginHandshake(instanceName, encrypt); @@ -3136,7 +3136,7 @@ private bool TryProcessFeatureExtAck(TdsParserStateObject stateObj) ret = SQLFallbackDNSCache.Instance.DeleteDNSInfo(FQDNforDNSCahce); } - if ( _connHandler.IsSQLDNSCachingSupported && _connHandler.pendingSQLDNSObject != null + if (_connHandler.IsSQLDNSCachingSupported && _connHandler.pendingSQLDNSObject != null && !SQLFallbackDNSCache.Instance.IsDuplicate(_connHandler.pendingSQLDNSObject)) { ret = SQLFallbackDNSCache.Instance.AddDNSInfo(_connHandler.pendingSQLDNSObject); @@ -3313,7 +3313,7 @@ private bool TryReadSensitivityInformationType(TdsParserStateObject stateObj, ou private bool TryProcessDataClassification(TdsParserStateObject stateObj, out SensitivityClassification sensitivityClassification) { - if (this.DataClassificationVersion == 0) + if (DataClassificationVersion == 0) { throw SQL.ParsingError(ParsingErrorState.DataClassificationNotExpected); } @@ -3321,17 +3321,14 @@ private bool TryProcessDataClassification(TdsParserStateObject stateObj, out Sen sensitivityClassification = null; // get the labels - UInt16 numLabels; - if (!stateObj.TryReadUInt16(out numLabels)) + if (!stateObj.TryReadUInt16(out ushort numLabels)) { return false; } var labels = new List