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 @@
Represents the Data Classification Labels as received from SQL Server for the active 'SqlDataReader'
- To be added.
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 label for this 'SensitivityProperty' Object
Label 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(numLabels);
- for (UInt16 i = 0; i < numLabels; i++)
+ for (ushort i = 0; i < numLabels; i++)
{
- string label;
- string id;
- if (!TryReadSensitivityLabel(stateObj, out label, out id))
+ if (!TryReadSensitivityLabel(stateObj, out string label, out string id))
{
return false;
}
@@ -3339,49 +3336,53 @@ private bool TryProcessDataClassification(TdsParserStateObject stateObj, out Sen
}
// get the information types
- UInt16 numInformationTypes;
- if (!stateObj.TryReadUInt16(out numInformationTypes))
+ if (!stateObj.TryReadUInt16(out ushort numInformationTypes))
{
return false;
}
var informationTypes = new List(numInformationTypes);
- for (UInt16 i = 0; i < numInformationTypes; i++)
+ for (ushort i = 0; i < numInformationTypes; i++)
{
- string informationType;
- string id;
- if (!TryReadSensitivityInformationType(stateObj, out informationType, out id))
+ if (!TryReadSensitivityInformationType(stateObj, out string informationType, out string id))
{
return false;
}
informationTypes.Add(new InformationType(informationType, id));
}
+ // get sensitivity rank
+ int sensitivityRank = (int)SensitivityRank.NOT_DEFINED;
+ if (DataClassificationVersion > TdsEnums.DATA_CLASSIFICATION_VERSION_WITHOUT_RANK_SUPPORT)
+ {
+ if (!stateObj.TryReadInt32(out sensitivityRank) || !Enum.IsDefined(typeof(SensitivityRank), sensitivityRank))
+ {
+ return false;
+ }
+ }
+
// get the per column classification data (corresponds to order of output columns for query)
- UInt16 numResultColumns;
- if (!stateObj.TryReadUInt16(out numResultColumns))
+ if (!stateObj.TryReadUInt16(out ushort numResultColumns))
{
return false;
}
var columnSensitivities = new List(numResultColumns);
- for (UInt16 columnNum = 0; columnNum < numResultColumns; columnNum++)
+ for (ushort columnNum = 0; columnNum < numResultColumns; columnNum++)
{
// get sensitivity properties for all the different sources which were used in generating the column output
- UInt16 numSources;
- if (!stateObj.TryReadUInt16(out numSources))
+ if (!stateObj.TryReadUInt16(out ushort numSources))
{
return false;
}
var sensitivityProperties = new List(numSources);
- for (UInt16 sourceNum = 0; sourceNum < numSources; sourceNum++)
+ for (ushort sourceNum = 0; sourceNum < numSources; sourceNum++)
{
// get the label index and then lookup label to use for source
- UInt16 labelIndex;
- if (!stateObj.TryReadUInt16(out labelIndex))
+ if (!stateObj.TryReadUInt16(out ushort labelIndex))
{
return false;
}
Label label = null;
- if (labelIndex != UInt16.MaxValue)
+ if (labelIndex != ushort.MaxValue)
{
if (labelIndex >= labels.Count)
{
@@ -3391,13 +3392,12 @@ private bool TryProcessDataClassification(TdsParserStateObject stateObj, out Sen
}
// get the information type index and then lookup information type to use for source
- UInt16 informationTypeIndex;
- if (!stateObj.TryReadUInt16(out informationTypeIndex))
+ if (!stateObj.TryReadUInt16(out ushort informationTypeIndex))
{
return false;
}
InformationType informationType = null;
- if (informationTypeIndex != UInt16.MaxValue)
+ if (informationTypeIndex != ushort.MaxValue)
{
if (informationTypeIndex >= informationTypes.Count)
{
@@ -3406,14 +3406,23 @@ private bool TryProcessDataClassification(TdsParserStateObject stateObj, out Sen
informationType = informationTypes[informationTypeIndex];
}
- // add sentivity properties for the source
- sensitivityProperties.Add(new SensitivityProperty(label, informationType));
+ // get sensitivity rank
+ int sensitivityRankProperty = (int)SensitivityRank.NOT_DEFINED;
+ if (DataClassificationVersion > TdsEnums.DATA_CLASSIFICATION_VERSION_WITHOUT_RANK_SUPPORT)
+ {
+ if (!stateObj.TryReadInt32(out sensitivityRankProperty) || !Enum.IsDefined(typeof(SensitivityRank), sensitivityRankProperty))
+ {
+ return false;
+ }
+ }
+
+ // add sensitivity properties for the source
+ sensitivityProperties.Add(new SensitivityProperty(label, informationType, (SensitivityRank)sensitivityRankProperty));
}
columnSensitivities.Add(new ColumnSensitivity(sensitivityProperties));
}
- sensitivityClassification = new SensitivityClassification(labels, informationTypes, columnSensitivities);
-
+ sensitivityClassification = new SensitivityClassification(labels, informationTypes, columnSensitivities, (SensitivityRank)sensitivityRank);
return true;
}
@@ -7829,7 +7838,7 @@ internal int WriteFedAuthFeatureRequest(FederatedAuthenticationFeatureExtensionD
// Write Feature ID, length of the version# field and Sensitivity Classification Version#
_physicalStateObj.WriteByte(TdsEnums.FEATUREEXT_DATACLASSIFICATION);
WriteInt(1, _physicalStateObj);
- _physicalStateObj.WriteByte(TdsEnums.MAX_SUPPORTED_DATA_CLASSIFICATION_VERSION);
+ _physicalStateObj.WriteByte(TdsEnums.DATA_CLASSIFICATION_VERSION_MAX_SUPPORTED);
}
return len; // size of data written
diff --git a/src/Microsoft.Data.SqlClient/netfx/ref/Microsoft.Data.SqlClient.cs b/src/Microsoft.Data.SqlClient/netfx/ref/Microsoft.Data.SqlClient.cs
index 69dbf03312..1b044d5373 100644
--- a/src/Microsoft.Data.SqlClient/netfx/ref/Microsoft.Data.SqlClient.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/ref/Microsoft.Data.SqlClient.cs
@@ -5,7 +5,7 @@
[assembly: System.Resources.NeutralResourcesLanguageAttribute("en-US")]
namespace Microsoft.Data
{
- ///
+ ///
[System.Serializable]
public sealed partial class OperationAbortedException : System.SystemException
{
@@ -17,18 +17,18 @@ private OperationAbortedException(System.Runtime.Serialization.SerializationInfo
}
namespace Microsoft.Data.Sql
{
- ///
+ ///
public sealed partial class SqlNotificationRequest
{
- ///
+ ///
public SqlNotificationRequest() { }
- ///
+ ///
public SqlNotificationRequest(string userData, string options, int timeout) { }
- ///
+ ///
public string Options { get { throw null; } set { } }
- ///
+ ///
public int Timeout { get { throw null; } set { } }
- ///
+ ///
public string UserData { get { throw null; } set { } }
}
}
@@ -826,21 +826,21 @@ public enum SqlConnectionColumnEncryptionSetting
Enabled = 1,
}
- ///
+ ///
public enum SqlConnectionAttestationProtocol
{
- ///
+ ///
NotSpecified = 0,
- ///
+ ///
AAS = 1,
#if ENCLAVE_SIMULATOR
- ///
+ ///
SIM = 2,
#endif
- ///
+ ///
HGS = 3
}
@@ -923,7 +923,7 @@ public SqlConnectionStringBuilder(string connectionString) { }
///
[System.ComponentModel.DisplayNameAttribute("Attestation Protocol")]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
- public Microsoft.Data.SqlClient.SqlConnectionAttestationProtocol AttestationProtocol {get { throw null; } set { } }
+ public Microsoft.Data.SqlClient.SqlConnectionAttestationProtocol AttestationProtocol { get { throw null; } set { } }
///
[System.ComponentModel.DisplayNameAttribute("Encrypt")]
@@ -1921,332 +1921,352 @@ public virtual void SetValue(int ordinal, object value) { }
///
public virtual int SetValues(params object[] values) { throw null; }
}
- ///
+ ///
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple = false, Inherited = false), System.SerializableAttribute]
public partial class SqlFunctionAttribute : System.Attribute
{
- ///
+ ///
public SqlFunctionAttribute() { }
- ///
+ ///
public bool IsDeterministic { get { throw null; } set { } }
- ///
+ ///
public DataAccessKind DataAccess { get { throw null; } set { } }
- ///
+ ///
public SystemDataAccessKind SystemDataAccess { get { throw null; } set { } }
- ///
+ ///
public bool IsPrecise { get { throw null; } set { } }
- ///
+ ///
public string Name { get { throw null; } set { } }
- ///
+ ///
public string TableDefinition { get { throw null; } set { } }
- ///
+ ///
public string FillRowMethodName { get { throw null; } set { } }
}
- ///
+ ///
public sealed partial class SqlMetaData
{
- ///
+ ///
public SqlMetaData(string name, System.Data.SqlDbType dbType) { }
- ///
+ ///
public SqlMetaData(string name, System.Data.SqlDbType dbType, bool useServerDefault, bool isUniqueKey, Microsoft.Data.SqlClient.SortOrder columnSortOrder, int sortOrdinal) { }
- ///
+ ///
public SqlMetaData(string name, System.Data.SqlDbType dbType, byte precision, byte scale) { }
- ///
+ ///
public SqlMetaData(string name, System.Data.SqlDbType dbType, byte precision, byte scale, bool useServerDefault, bool isUniqueKey, Microsoft.Data.SqlClient.SortOrder columnSortOrder, int sortOrdinal) { }
- ///
+ ///
public SqlMetaData(string name, System.Data.SqlDbType dbType, long maxLength) { }
- ///
+ ///
public SqlMetaData(string name, System.Data.SqlDbType dbType, long maxLength, bool useServerDefault, bool isUniqueKey, Microsoft.Data.SqlClient.SortOrder columnSortOrder, int sortOrdinal) { }
- ///
+ ///
public SqlMetaData(string name, System.Data.SqlDbType dbType, long maxLength, byte precision, byte scale, long locale, System.Data.SqlTypes.SqlCompareOptions compareOptions, System.Type userDefinedType) { }
- ///
+ ///
public SqlMetaData(string name, System.Data.SqlDbType dbType, long maxLength, byte precision, byte scale, long localeId, System.Data.SqlTypes.SqlCompareOptions compareOptions, System.Type userDefinedType, bool useServerDefault, bool isUniqueKey, Microsoft.Data.SqlClient.SortOrder columnSortOrder, int sortOrdinal) { }
- ///
+ ///
public SqlMetaData(string name, System.Data.SqlDbType dbType, long maxLength, long locale, System.Data.SqlTypes.SqlCompareOptions compareOptions) { }
- ///
+ ///
public SqlMetaData(string name, System.Data.SqlDbType dbType, long maxLength, long locale, System.Data.SqlTypes.SqlCompareOptions compareOptions, bool useServerDefault, bool isUniqueKey, Microsoft.Data.SqlClient.SortOrder columnSortOrder, int sortOrdinal) { }
- ///
+ ///
public SqlMetaData(string name, System.Data.SqlDbType dbType, string database, string owningSchema, string objectName) { }
- ///
+ ///
public SqlMetaData(string name, System.Data.SqlDbType dbType, string database, string owningSchema, string objectName, bool useServerDefault, bool isUniqueKey, Microsoft.Data.SqlClient.SortOrder columnSortOrder, int sortOrdinal) { }
- ///
+ ///
public SqlMetaData(string name, System.Data.SqlDbType dbType, System.Type userDefinedType) { }
- ///
+ ///
public SqlMetaData(string name, System.Data.SqlDbType dbType, System.Type userDefinedType, string serverTypeName) { }
- ///
+ ///
public SqlMetaData(string name, System.Data.SqlDbType dbType, System.Type userDefinedType, string serverTypeName, bool useServerDefault, bool isUniqueKey, Microsoft.Data.SqlClient.SortOrder columnSortOrder, int sortOrdinal) { }
- ///
+ ///
public System.Data.SqlTypes.SqlCompareOptions CompareOptions { get { throw null; } }
- ///
+ ///
public System.Data.DbType DbType { get { throw null; } }
- ///
+ ///
public bool IsUniqueKey { get { throw null; } }
- ///
+ ///
public long LocaleId { get { throw null; } }
- ///
+ ///
public static long Max { get { throw null; } }
- ///
+ ///
public long MaxLength { get { throw null; } }
- ///
+ ///
public string Name { get { throw null; } }
- ///
+ ///
public byte Precision { get { throw null; } }
- ///
+ ///
public byte Scale { get { throw null; } }
- ///
+ ///
public Microsoft.Data.SqlClient.SortOrder SortOrder { get { throw null; } }
- ///
+ ///
public int SortOrdinal { get { throw null; } }
- ///
+ ///
public System.Data.SqlDbType SqlDbType { get { throw null; } }
- ///
+ ///
public System.Type Type { get { throw null; } }
- ///
+ ///
public string TypeName { get { throw null; } }
- ///
+ ///
public bool UseServerDefault { get { throw null; } }
- ///
+ ///
public string XmlSchemaCollectionDatabase { get { throw null; } }
- ///
+ ///
public string XmlSchemaCollectionName { get { throw null; } }
- ///
+ ///
public string XmlSchemaCollectionOwningSchema { get { throw null; } }
- ///
+ ///
public bool Adjust(bool value) { throw null; }
- ///
+ ///
public byte Adjust(byte value) { throw null; }
- ///
+ ///
public byte[] Adjust(byte[] value) { throw null; }
- ///
+ ///
public char Adjust(char value) { throw null; }
- ///
+ ///
public char[] Adjust(char[] value) { throw null; }
- ///
+ ///
public System.Data.SqlTypes.SqlBinary Adjust(System.Data.SqlTypes.SqlBinary value) { throw null; }
- ///
+ ///
public System.Data.SqlTypes.SqlBoolean Adjust(System.Data.SqlTypes.SqlBoolean value) { throw null; }
- ///
+ ///
public System.Data.SqlTypes.SqlByte Adjust(System.Data.SqlTypes.SqlByte value) { throw null; }
- ///
+ ///
public System.Data.SqlTypes.SqlBytes Adjust(System.Data.SqlTypes.SqlBytes value) { throw null; }
- ///
+ ///
public System.Data.SqlTypes.SqlChars Adjust(System.Data.SqlTypes.SqlChars value) { throw null; }
- ///
+ ///
public System.Data.SqlTypes.SqlDateTime Adjust(System.Data.SqlTypes.SqlDateTime value) { throw null; }
- ///
+ ///
public System.Data.SqlTypes.SqlDecimal Adjust(System.Data.SqlTypes.SqlDecimal value) { throw null; }
- ///
+ ///
public System.Data.SqlTypes.SqlDouble Adjust(System.Data.SqlTypes.SqlDouble value) { throw null; }
- ///
+ ///
public System.Data.SqlTypes.SqlGuid Adjust(System.Data.SqlTypes.SqlGuid value) { throw null; }
- ///
+ ///
public System.Data.SqlTypes.SqlInt16 Adjust(System.Data.SqlTypes.SqlInt16 value) { throw null; }
- ///
+ ///
public System.Data.SqlTypes.SqlInt32 Adjust(System.Data.SqlTypes.SqlInt32 value) { throw null; }
- ///
+ ///
public System.Data.SqlTypes.SqlInt64 Adjust(System.Data.SqlTypes.SqlInt64 value) { throw null; }
- ///
+ ///
public System.Data.SqlTypes.SqlMoney Adjust(System.Data.SqlTypes.SqlMoney value) { throw null; }
- ///
+ ///
public System.Data.SqlTypes.SqlSingle Adjust(System.Data.SqlTypes.SqlSingle value) { throw null; }
- ///
+ ///
public System.Data.SqlTypes.SqlString Adjust(System.Data.SqlTypes.SqlString value) { throw null; }
- ///
+ ///
public System.Data.SqlTypes.SqlXml Adjust(System.Data.SqlTypes.SqlXml value) { throw null; }
- ///
+ ///
public System.DateTime Adjust(System.DateTime value) { throw null; }
- ///
+ ///
public System.DateTimeOffset Adjust(System.DateTimeOffset value) { throw null; }
- ///
+ ///
public decimal Adjust(decimal value) { throw null; }
- ///
+ ///
public double Adjust(double value) { throw null; }
- ///
+ ///
public System.Guid Adjust(System.Guid value) { throw null; }
- ///
+ ///
public short Adjust(short value) { throw null; }
- ///
+ ///
public int Adjust(int value) { throw null; }
- ///
+ ///
public long Adjust(long value) { throw null; }
- ///
+ ///
public object Adjust(object value) { throw null; }
- ///
+ ///
public float Adjust(float value) { throw null; }
- ///
+ ///
public string Adjust(string value) { throw null; }
- ///
+ ///
public System.TimeSpan Adjust(System.TimeSpan value) { throw null; }
- ///
+ ///
public static Microsoft.Data.SqlClient.Server.SqlMetaData InferFromValue(object value, string name) { throw null; }
}
- ///
+ ///
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple = false, Inherited = false), System.SerializableAttribute]
public sealed partial class SqlMethodAttribute : SqlFunctionAttribute
{
- ///
+ ///
public SqlMethodAttribute() { }
- ///
+ ///
public bool OnNullCall { get { throw null; } set { } }
- ///
+ ///
public bool IsMutator { get { throw null; } set { } }
- ///
+ ///
public bool InvokeIfReceiverIsNull { get { throw null; } set { } }
}
- ///
+ ///
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
public sealed partial class SqlUserDefinedAggregateAttribute : System.Attribute
{
- ///
+ ///
public const int MaxByteSizeValue = 8000;
- ///
+ ///
public SqlUserDefinedAggregateAttribute(Format format) { }
- ///
+ ///
public int MaxByteSize { get { throw null; } set { } }
- ///
+ ///
public bool IsInvariantToDuplicates { get { throw null; } set { } }
- ///
+ ///
public bool IsInvariantToNulls { get { throw null; } set { } }
- ///
+ ///
public bool IsInvariantToOrder { get { throw null; } set { } }
- ///
+ ///
public bool IsNullIfEmpty { get { throw null; } set { } }
- ///
+ ///
public Format Format { get { throw null; } }
- ///
+ ///
public string Name { get { throw null; } set { } }
}
- ///
+ ///
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Struct, AllowMultiple = false, Inherited = true)]
public sealed partial class SqlUserDefinedTypeAttribute : System.Attribute
{
- ///
+ ///
public SqlUserDefinedTypeAttribute(Format format) { }
- ///
+ ///
public int MaxByteSize { get { throw null; } set { } }
- ///
+ ///
public bool IsFixedLength { get { throw null; } set { } }
- ///
+ ///
public bool IsByteOrdered { get { throw null; } set { } }
- ///
+ ///
public Format Format { get { throw null; } }
- ///
+ ///
public string ValidationMethodName { get { throw null; } set { } }
- ///
+ ///
public string Name { get { throw null; } set { } }
}
- ///
+ ///
public enum SystemDataAccessKind
{
- ///
+ ///
None = 0,
- ///
+ ///
Read = 1
}
}
namespace Microsoft.Data.SqlClient.DataClassification
{
- ///
+ ///
public partial class ColumnSensitivity
{
- ///
+ ///
public ColumnSensitivity(System.Collections.Generic.IList sensitivityProperties) { }
- ///
+ ///
public System.Collections.ObjectModel.ReadOnlyCollection SensitivityProperties { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
- ///
+ ///
public partial class InformationType
{
- ///
+ ///
public InformationType(string name, string id) { }
- ///
+ ///
public string Id { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
- ///
+ ///
public string Name { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
- ///
+ ///
public partial class Label
{
- ///
+ ///
public Label(string name, string id) { }
- ///
+ ///
public string Id { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
- ///
+ ///
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; } }
}
}
namespace Microsoft.Data.SqlTypes
{
- ///
+ ///
public sealed partial class SqlFileStream : System.IO.Stream
{
- ///
+ ///
public SqlFileStream(string path, byte[] transactionContext, System.IO.FileAccess access) { }
- ///
+ ///
public SqlFileStream(string path, byte[] transactionContext, System.IO.FileAccess access, System.IO.FileOptions options, System.Int64 allocationSize) { }
- ///
+ ///
public string Name { get { throw null; } }
- ///
+ ///
public byte[] TransactionContext { get { throw null; } }
- ///
+ ///
public override bool CanRead { get { throw null; } }
- ///
+ ///
public override bool CanSeek { get { throw null; } }
- ///
+ ///
public override bool CanTimeout { get { throw null; } }
- ///
+ ///
public override bool CanWrite { get { throw null; } }
- ///
+ ///
public override long Length { get { throw null; } }
- ///
+ ///
public override long Position { get { throw null; } set { throw null; } }
- ///
+ ///
public override int ReadTimeout { get { throw null; } }
- ///
+ ///
public override int WriteTimeout { get { throw null; } }
- ///
+ ///
public override void Flush() { }
- ///
+ ///
public override System.IAsyncResult BeginRead(byte[] buffer, int offset, int count, System.AsyncCallback callback, object state) { throw null; }
- ///
+ ///
public override int EndRead(System.IAsyncResult asyncResult) { throw null; }
- ///
+ ///
public override System.IAsyncResult BeginWrite(byte[] buffer, int offset, int count, System.AsyncCallback callback, System.Object state) { throw null; }
- ///
+ ///
public override void EndWrite(System.IAsyncResult asyncResult) { }
- ///
+ ///
public override long Seek(long offset, System.IO.SeekOrigin origin) { throw null; }
- ///
+ ///
public override void SetLength(long value) { throw null; }
- ///
+ ///
public override int Read(byte[] buffer, int offset, int count) { throw null; }
- ///
+ ///
public override int ReadByte() { throw null; }
- ///
+ ///
public override void Write(byte[] buffer, int offset, int count) { throw null; }
- ///
+ ///
public override void WriteByte(byte value) { }
}
}
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
index 0da06ba54d..f677a1f37d 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
@@ -143,7 +143,6 @@ sealed internal class SqlInternalConnectionTds : SqlInternalConnection, IDisposa
SqlClientOriginalNetworkAddressInfo _originalNetworkAddressInfo;
internal bool _cleanSQLDNSCaching = false;
-
private bool _serverSupportsDNSCaching = false;
///
@@ -3063,7 +3062,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/netfx/src/Microsoft/Data/SqlClient/TdsEnums.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsEnums.cs
index eaba0b9cc8..a444991ddb 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsEnums.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsEnums.cs
@@ -938,7 +938,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;
// TCE Related constants
internal const byte MAX_SUPPORTED_TCE_VERSION = 0x02; // max version
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs
index 4f5fd8a2e1..795a0ff841 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs
@@ -623,7 +623,7 @@ internal void Connect(ServerInfo serverInfo,
UInt32 result = SNINativeMethodWrapper.SniGetConnectionId(_physicalStateObj.Handle, ref _connHandler._clientConnectionId);
Debug.Assert(result == TdsEnums.SNI_SUCCESS, "Unexpected failure state upon calling SniGetConnectionId");
-
+
// for DNS Caching phase 1
AssignPendingDNSInfo(serverInfo.UserProtocol, FQDNforDNSCahce);
@@ -705,12 +705,12 @@ internal void AssignPendingDNSInfo(string userProtocol, string DNSCacheKey)
if (string.IsNullOrEmpty(userProtocol))
{
-
+
result = SNINativeMethodWrapper.SniGetProviderNumber(_physicalStateObj.Handle, ref providerNumber);
Debug.Assert(result == TdsEnums.SNI_SUCCESS, "Unexpected failure state upon calling SniGetProviderNumber");
isTcpProtocol = (providerNumber == SNINativeMethodWrapper.ProviderEnum.TCP_PROV);
}
- else if (userProtocol == TdsEnums.TCP)
+ else if (userProtocol == TdsEnums.TCP)
{
isTcpProtocol = true;
}
@@ -3558,7 +3558,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);
@@ -3734,7 +3734,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);
}
@@ -3742,17 +3742,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(numLabels);
- for (UInt16 i = 0; i < numLabels; i++)
+ for (ushort i = 0; i < numLabels; i++)
{
- string label;
- string id;
- if (!TryReadSensitivityLabel(stateObj, out label, out id))
+ if (!TryReadSensitivityLabel(stateObj, out string label, out string id))
{
return false;
}
@@ -3760,49 +3757,53 @@ private bool TryProcessDataClassification(TdsParserStateObject stateObj, out Sen
}
// get the information types
- UInt16 numInformationTypes;
- if (!stateObj.TryReadUInt16(out numInformationTypes))
+ if (!stateObj.TryReadUInt16(out ushort numInformationTypes))
{
return false;
}
var informationTypes = new List(numInformationTypes);
- for (UInt16 i = 0; i < numInformationTypes; i++)
+ for (ushort i = 0; i < numInformationTypes; i++)
{
- string informationType;
- string id;
- if (!TryReadSensitivityInformationType(stateObj, out informationType, out id))
+ if (!TryReadSensitivityInformationType(stateObj, out string informationType, out string id))
{
return false;
}
informationTypes.Add(new InformationType(informationType, id));
}
+ // get sensitivity rank
+ int sensitivityRank = (int)SensitivityRank.NOT_DEFINED;
+ if (DataClassificationVersion > TdsEnums.DATA_CLASSIFICATION_VERSION_WITHOUT_RANK_SUPPORT)
+ {
+ if (!stateObj.TryReadInt32(out sensitivityRank) || !Enum.IsDefined(typeof(SensitivityRank), sensitivityRank))
+ {
+ return false;
+ }
+ }
+
// get the per column classification data (corresponds to order of output columns for query)
- UInt16 numResultColumns;
- if (!stateObj.TryReadUInt16(out numResultColumns))
+ if (!stateObj.TryReadUInt16(out ushort numResultColumns))
{
return false;
}
var columnSensitivities = new List(numResultColumns);
- for (UInt16 columnNum = 0; columnNum < numResultColumns; columnNum++)
+ for (ushort columnNum = 0; columnNum < numResultColumns; columnNum++)
{
// get sensitivity properties for all the different sources which were used in generating the column output
- UInt16 numSources;
- if (!stateObj.TryReadUInt16(out numSources))
+ if (!stateObj.TryReadUInt16(out ushort numSources))
{
return false;
}
var sensitivityProperties = new List(numSources);
- for (UInt16 sourceNum = 0; sourceNum < numSources; sourceNum++)
+ for (ushort sourceNum = 0; sourceNum < numSources; sourceNum++)
{
// get the label index and then lookup label to use for source
- UInt16 labelIndex;
- if (!stateObj.TryReadUInt16(out labelIndex))
+ if (!stateObj.TryReadUInt16(out ushort labelIndex))
{
return false;
}
Label label = null;
- if (labelIndex != UInt16.MaxValue)
+ if (labelIndex != ushort.MaxValue)
{
if (labelIndex >= labels.Count)
{
@@ -3812,13 +3813,12 @@ private bool TryProcessDataClassification(TdsParserStateObject stateObj, out Sen
}
// get the information type index and then lookup information type to use for source
- UInt16 informationTypeIndex;
- if (!stateObj.TryReadUInt16(out informationTypeIndex))
+ if (!stateObj.TryReadUInt16(out ushort informationTypeIndex))
{
return false;
}
InformationType informationType = null;
- if (informationTypeIndex != UInt16.MaxValue)
+ if (informationTypeIndex != ushort.MaxValue)
{
if (informationTypeIndex >= informationTypes.Count)
{
@@ -3827,14 +3827,23 @@ private bool TryProcessDataClassification(TdsParserStateObject stateObj, out Sen
informationType = informationTypes[informationTypeIndex];
}
- // add sentivity properties for the source
- sensitivityProperties.Add(new SensitivityProperty(label, informationType));
+ // get sensitivity rank
+ int sensitivityRankProperty = (int)SensitivityRank.NOT_DEFINED;
+ if (DataClassificationVersion > TdsEnums.DATA_CLASSIFICATION_VERSION_WITHOUT_RANK_SUPPORT)
+ {
+ if (!stateObj.TryReadInt32(out sensitivityRankProperty) || !Enum.IsDefined(typeof(SensitivityRank), sensitivityRankProperty))
+ {
+ return false;
+ }
+ }
+
+ // add sensitivity properties for the source
+ sensitivityProperties.Add(new SensitivityProperty(label, informationType, (SensitivityRank)sensitivityRankProperty));
}
columnSensitivities.Add(new ColumnSensitivity(sensitivityProperties));
}
- sensitivityClassification = new SensitivityClassification(labels, informationTypes, columnSensitivities);
-
+ sensitivityClassification = new SensitivityClassification(labels, informationTypes, columnSensitivities, (SensitivityRank)sensitivityRank);
return true;
}
@@ -8576,7 +8585,7 @@ internal int WriteFedAuthFeatureRequest(FederatedAuthenticationFeatureExtensionD
// Write Feature ID, legth of the version# field and Sensitivity Classification Version#
_physicalStateObj.WriteByte(TdsEnums.FEATUREEXT_DATACLASSIFICATION);
WriteInt(1, _physicalStateObj);
- _physicalStateObj.WriteByte(TdsEnums.MAX_SUPPORTED_DATA_CLASSIFICATION_VERSION);
+ _physicalStateObj.WriteByte(TdsEnums.DATA_CLASSIFICATION_VERSION_MAX_SUPPORTED);
}
return len; // size of data written
@@ -9828,7 +9837,7 @@ internal Task TdsExecuteRPC(SqlCommand cmd, _SqlRPC[] rpcArray, int timeout, boo
// Stream out parameters
SqlParameter[] parameters = rpcext.parameters;
-
+
bool isAdvancedTraceOn = SqlClientEventSource.Log.IsAdvancedTraceOn();
for (int i = (ii == startRpc) ? startParam : 0; i < parameters.Length; i++)
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/DataClassification/SensitivityClassification.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/DataClassification/SensitivityClassification.cs
index 084083b338..27acd8508b 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/DataClassification/SensitivityClassification.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/DataClassification/SensitivityClassification.cs
@@ -8,7 +8,7 @@
namespace Microsoft.Data.SqlClient.DataClassification
{
///
- public class Label
+ public sealed class Label
{
///
public string Name { get; private set; }
@@ -25,7 +25,7 @@ public Label(string name, string id)
}
///
- public class InformationType
+ public sealed class InformationType
{
///
public string Name { get; private set; }
@@ -41,8 +41,25 @@ public InformationType(string name, string id)
}
}
+ ///
+ public enum SensitivityRank
+ {
+ ///
+ NOT_DEFINED = -1,
+ ///
+ NONE = 0,
+ ///
+ LOW = 10,
+ ///
+ MEDIUM = 20,
+ ///
+ HIGH = 30,
+ ///
+ CRITICAL = 40
+ }
+
///
- public class SensitivityProperty
+ public sealed class SensitivityProperty
{
///
public Label Label { get; private set; }
@@ -50,16 +67,20 @@ public class SensitivityProperty
///
public InformationType InformationType { get; private set; }
+ ///
+ public SensitivityRank SensitivityRank { get; private set; }
+
///
- public SensitivityProperty(Label label, InformationType informationType)
+ public SensitivityProperty(Label label, InformationType informationType, SensitivityRank sensitivityRank = SensitivityRank.NOT_DEFINED) // Default to NOT_DEFINED for backwards compatibility
{
Label = label;
InformationType = informationType;
+ SensitivityRank = sensitivityRank;
}
}
///
- public class ColumnSensitivity
+ public sealed class ColumnSensitivity
{
///
public ReadOnlyCollection SensitivityProperties { get; private set; }
@@ -72,7 +93,7 @@ public ColumnSensitivity(IList sensitivityProperties)
}
///
- public class SensitivityClassification
+ public sealed class SensitivityClassification
{
///
public ReadOnlyCollection Labels { get; private set; }
@@ -80,15 +101,19 @@ public class SensitivityClassification
///
public ReadOnlyCollection InformationTypes { get; private set; }
+ ///
+ public SensitivityRank SensitivityRank { get; private set; }
+
///
public ReadOnlyCollection ColumnSensitivities { get; private set; }
///
- public SensitivityClassification(IList labels, IList informationTypes, IList columnSensitivity)
+ public SensitivityClassification(IList labels, IList informationTypes, IList columnSensitivity, SensitivityRank sensitivityRank = SensitivityRank.NOT_DEFINED) // Default to NOT_DEFINED for backwards compatibility
{
Labels = new ReadOnlyCollection(labels);
InformationTypes = new ReadOnlyCollection(informationTypes);
ColumnSensitivities = new ReadOnlyCollection(columnSensitivity);
+ SensitivityRank = sensitivityRank;
}
}
}
diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataClassificationTest/DataClassificationTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataClassificationTest/DataClassificationTest.cs
index 51c8ebf5eb..51ff126410 100644
--- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataClassificationTest/DataClassificationTest.cs
+++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataClassificationTest/DataClassificationTest.cs
@@ -14,7 +14,30 @@ public static class DataClassificationTest
{
private static string s_tableName;
- [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer), nameof(DataTestUtility.IsSupportedDataClassification))]
+ [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsSupportedDataClassification))]
+ public static void TestDataClassificationResultSetRank()
+ {
+ s_tableName = DataTestUtility.GetUniqueNameForSqlServer("DC");
+ using (SqlConnection sqlConnection = new SqlConnection(DataTestUtility.TCPConnectionString))
+ using (SqlCommand sqlCommand = sqlConnection.CreateCommand())
+ {
+ try
+ {
+ sqlConnection.Open();
+ Assert.True(DataTestUtility.IsSupportedDataClassification());
+ CreateTable(sqlCommand);
+ AddSensitivity(sqlCommand, rankEnabled: true);
+ InsertData(sqlCommand);
+ RunTestsForServer(sqlCommand, rankEnabled: true);
+ }
+ finally
+ {
+ DataTestUtility.DropTable(sqlConnection, s_tableName);
+ }
+ }
+ }
+
+ [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsSupportedDataClassification))]
public static void TestDataClassificationResultSet()
{
s_tableName = DataTestUtility.GetUniqueNameForSqlServer("DC");
@@ -26,6 +49,8 @@ public static void TestDataClassificationResultSet()
sqlConnection.Open();
Assert.True(DataTestUtility.IsSupportedDataClassification());
CreateTable(sqlCommand);
+ AddSensitivity(sqlCommand);
+ InsertData(sqlCommand);
RunTestsForServer(sqlCommand);
}
finally
@@ -35,16 +60,16 @@ public static void TestDataClassificationResultSet()
}
}
- private static void RunTestsForServer(SqlCommand sqlCommand)
+ private static void RunTestsForServer(SqlCommand sqlCommand, bool rankEnabled = false)
{
sqlCommand.CommandText = "SELECT * FROM " + s_tableName;
using (SqlDataReader reader = sqlCommand.ExecuteReader())
{
- VerifySensitivityClassification(reader);
+ VerifySensitivityClassification(reader, rankEnabled);
}
}
- private static void VerifySensitivityClassification(SqlDataReader reader)
+ private static void VerifySensitivityClassification(SqlDataReader reader, bool rankEnabled = false)
{
if (null != reader.SensitivityClassification)
{
@@ -69,8 +94,24 @@ private static void VerifySensitivityClassification(SqlDataReader reader)
VerifyLabel(sp.Label);
VerifyInfoType(sp.InformationType, columnPos);
}
+ if (rankEnabled)
+ {
+ if (columnPos == 1 || columnPos == 2)
+ {
+ Assert.True(sp.SensitivityRank == SensitivityRank.LOW);
+ }
+ else if (columnPos == 6 || columnPos == 7)
+ {
+ Assert.True(sp.SensitivityRank == SensitivityRank.MEDIUM);
+ }
+ }
+ else
+ {
+ Assert.True(reader.SensitivityClassification.SensitivityRank == SensitivityRank.NOT_DEFINED);
+ }
}
}
+ Assert.Equal(reader.SensitivityClassification.SensitivityRank, rankEnabled ? SensitivityRank.MEDIUM : SensitivityRank.NOT_DEFINED);
}
}
@@ -100,23 +141,50 @@ private static void CreateTable(SqlCommand sqlCommand)
+ "[Phone] [nvarchar](30) MASKED WITH (FUNCTION = 'default()') NULL,"
+ "[Fax] [nvarchar](30) MASKED WITH (FUNCTION = 'default()') NULL)";
sqlCommand.ExecuteNonQuery();
+ }
- sqlCommand.CommandText = "ADD SENSITIVITY CLASSIFICATION TO " + s_tableName
- + ".CompanyName WITH (LABEL='PII', LABEL_ID='L1', INFORMATION_TYPE='Company Name', INFORMATION_TYPE_ID='COMPANY')";
- sqlCommand.ExecuteNonQuery();
+ private static void AddSensitivity(SqlCommand sqlCommand, bool rankEnabled = false)
+ {
+ if (rankEnabled)
+ {
+ sqlCommand.CommandText = "ADD SENSITIVITY CLASSIFICATION TO " + s_tableName
+ + ".CompanyName WITH (LABEL='PII', LABEL_ID='L1', INFORMATION_TYPE='Company Name', INFORMATION_TYPE_ID='COMPANY', RANK=LOW)";
+ sqlCommand.ExecuteNonQuery();
- sqlCommand.CommandText = "ADD SENSITIVITY CLASSIFICATION TO " + s_tableName
- + ".ContactName WITH (LABEL='PII', LABEL_ID='L1', INFORMATION_TYPE='Person Name', INFORMATION_TYPE_ID='NAME')";
- sqlCommand.ExecuteNonQuery();
+ sqlCommand.CommandText = "ADD SENSITIVITY CLASSIFICATION TO " + s_tableName
+ + ".ContactName WITH (LABEL='PII', LABEL_ID='L1', INFORMATION_TYPE='Person Name', INFORMATION_TYPE_ID='NAME', RANK=LOW)";
+ sqlCommand.ExecuteNonQuery();
- sqlCommand.CommandText = "ADD SENSITIVITY CLASSIFICATION TO " + s_tableName
- + ".Phone WITH (LABEL='PII', LABEL_ID='L1', INFORMATION_TYPE='Contact Information', INFORMATION_TYPE_ID='CONTACT')";
- sqlCommand.ExecuteNonQuery();
+ sqlCommand.CommandText = "ADD SENSITIVITY CLASSIFICATION TO " + s_tableName
+ + ".Phone WITH (LABEL='PII', LABEL_ID='L1', INFORMATION_TYPE='Contact Information', INFORMATION_TYPE_ID='CONTACT', RANK=MEDIUM)";
+ sqlCommand.ExecuteNonQuery();
- sqlCommand.CommandText = "ADD SENSITIVITY CLASSIFICATION TO " + s_tableName
- + ".Fax WITH (LABEL='PII', LABEL_ID='L1', INFORMATION_TYPE='Contact Information', INFORMATION_TYPE_ID='CONTACT')";
- sqlCommand.ExecuteNonQuery();
+ sqlCommand.CommandText = "ADD SENSITIVITY CLASSIFICATION TO " + s_tableName
+ + ".Fax WITH (LABEL='PII', LABEL_ID='L1', INFORMATION_TYPE='Contact Information', INFORMATION_TYPE_ID='CONTACT', RANK=MEDIUM)";
+ sqlCommand.ExecuteNonQuery();
+ }
+ else
+ {
+ sqlCommand.CommandText = "ADD SENSITIVITY CLASSIFICATION TO " + s_tableName
+ + ".CompanyName WITH (LABEL='PII', LABEL_ID='L1', INFORMATION_TYPE='Company Name', INFORMATION_TYPE_ID='COMPANY')";
+ sqlCommand.ExecuteNonQuery();
+
+ sqlCommand.CommandText = "ADD SENSITIVITY CLASSIFICATION TO " + s_tableName
+ + ".ContactName WITH (LABEL='PII', LABEL_ID='L1', INFORMATION_TYPE='Person Name', INFORMATION_TYPE_ID='NAME')";
+ sqlCommand.ExecuteNonQuery();
+ sqlCommand.CommandText = "ADD SENSITIVITY CLASSIFICATION TO " + s_tableName
+ + ".Phone WITH (LABEL='PII', LABEL_ID='L1', INFORMATION_TYPE='Contact Information', INFORMATION_TYPE_ID='CONTACT')";
+ sqlCommand.ExecuteNonQuery();
+
+ sqlCommand.CommandText = "ADD SENSITIVITY CLASSIFICATION TO " + s_tableName
+ + ".Fax WITH (LABEL='PII', LABEL_ID='L1', INFORMATION_TYPE='Contact Information', INFORMATION_TYPE_ID='CONTACT')";
+ sqlCommand.ExecuteNonQuery();
+ }
+ }
+
+ private static void InsertData(SqlCommand sqlCommand)
+ {
// INSERT ROWS OF DATA
sqlCommand.CommandText = "INSERT INTO " + s_tableName + " VALUES (@companyName, @contactName, @contactTitle, @city, @country, @phone, @fax)";
@@ -126,7 +194,7 @@ private static void CreateTable(SqlCommand sqlCommand)
sqlCommand.Parameters.AddWithValue("city", "London");
sqlCommand.Parameters.AddWithValue("@country", "UK");
sqlCommand.Parameters.AddWithValue("@phone", "(171) 555-2222");
- sqlCommand.Parameters.AddWithValue("@fax", "");
+ sqlCommand.Parameters.AddWithValue("@fax", "(171) 554-2222");
sqlCommand.ExecuteNonQuery();
sqlCommand.Parameters.Clear();
@@ -136,7 +204,7 @@ private static void CreateTable(SqlCommand sqlCommand)
sqlCommand.Parameters.AddWithValue("city", "New Orleans");
sqlCommand.Parameters.AddWithValue("@country", "USA");
sqlCommand.Parameters.AddWithValue("@phone", "(100) 555-4822");
- sqlCommand.Parameters.AddWithValue("@fax", "");
+ sqlCommand.Parameters.AddWithValue("@fax", "(100) 223-3243");
sqlCommand.ExecuteNonQuery();
sqlCommand.Parameters.Clear();
@@ -150,7 +218,7 @@ private static void CreateTable(SqlCommand sqlCommand)
sqlCommand.ExecuteNonQuery();
}
- [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer), nameof(DataTestUtility.IsSupportedDataClassification))]
+ [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsSupportedDataClassification))]
public static void TestDataClassificationBulkCopy()
{
var data = new DataTable("Company");
@@ -177,14 +245,10 @@ public static void TestDataClassificationBulkCopy()
$" [CompanyId] [uniqueidentifier] NOT NULL," +
$" [CompanyName][nvarchar](255) NOT NULL," +
$" [Email] [nvarchar](50) NULL," +
- $" [CompanyType] [int] not null," +
- $" CONSTRAINT[PK_Company] PRIMARY KEY CLUSTERED (" +
- $" [CompanyId] ASC" +
- $" ) WITH(STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF) ON[PRIMARY]" +
- $" ) ON[PRIMARY]";
+ $" [CompanyType] [int] not null)";
sqlCommand.ExecuteNonQuery();
-
- sqlCommand.CommandText = $"ADD SENSITIVITY CLASSIFICATION TO {tableName}.Email WITH (label = 'Confidential', label_id = 'c185460f-4e20-4b89-9876-ae95f07ba087', information_type = 'Contact Info', information_type_id = '5c503e21-22c6-81fa-620b-f369b8ec38d1');";
+ sqlCommand.CommandText = $"ADD SENSITIVITY CLASSIFICATION TO {tableName}.CompanyName WITH (label = 'Confidential', label_id = 'c185460f-4e20-4b89-9876-ae95f07ba087', information_type = 'Contact Info', information_type_id = '5c503e21-22c6-81fa-620b-f369b8ec38d1');";
+ sqlCommand.CommandText = $"ADD SENSITIVITY CLASSIFICATION TO {tableName}.Email WITH (label = 'Confidential', label_id = 'c185460f-4e20-4b89-9876-ae95f07ba087', information_type = 'Contact Info', information_type_id = '5c503e21-22c6-81fa-620b-f369b8ec38d1', rank = HIGH);";
sqlCommand.ExecuteNonQuery();
}