Skip to content

Commit

Permalink
Feature | Add support for Data Classification v2 (#626)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheenamalhotra committed Jul 16, 2020
1 parent 762d24f commit 16f5f32
Show file tree
Hide file tree
Showing 16 changed files with 494 additions and 290 deletions.
Expand Up @@ -3,15 +3,14 @@
<members name="ColumnSensitivity">
<ColumnSensitivity>
<summary>Represents the Data Classification Sensitivity Information for columns as configured in Database.</summary>
<remarks>To be added.</remarks>
</ColumnSensitivity>
<ctor>
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.DataClassification.ColumnSensitivity" /> class.</summary>
<param name="sensitivityProperties">List of sensitivity properties.</param>
</ctor>
<GetSensitivityProperties>
<summary>Returns the list of sensitivity properties as received from Server for this 'ColumnSensitivity' information</summary>
<value>List of sensitivity properties.</value>
<remarks>To be added.</remarks>
</GetSensitivityProperties>
</members>
</docs>
Expand Up @@ -3,20 +3,19 @@
<members name="InformationType">
<InformationType>
<summary>Represents the Data Classification Information Types as received from SQL Server for the active 'SqlDataReader'</summary>
<remarks>To be added.</remarks>
</InformationType>
<ctor>
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.DataClassification.InformationType" /> class.</summary>
<param name="name">Name of Information Type.</param>
<param name="id">ID of Information Type.</param>
</ctor>
<Id>
<summary>Gets the ID for this 'InformationType' object</summary>
<value>ID of InformationType.</value>
<remarks>To be added.</remarks>
<value>ID of Information Type.</value>
</Id>
<Name>
<summary>Gets the name for this 'InformationType' object</summary>
<value>Name of InformationType.</value>
<remarks>To be added.</remarks>
<value>Name of Information Type.</value>
</Name>
</members>
</docs>
Expand Up @@ -3,20 +3,19 @@
<members name="Label">
<Label>
<summary>Represents the Data Classification Labels as received from SQL Server for the active 'SqlDataReader'</summary>
<remarks>To be added.</remarks>
</Label>
<ctor>
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.DataClassification.Label" /> class.</summary>
<param name="name">Name of label.</param>
<param name="id">ID of label.</param>
</ctor>
<Id>
<summary>Gets the ID for this 'Label' object</summary>
<value>ID of label.</value>
<remarks>To be added.</remarks>
</Id>
<Name>
<summary>Gets the name for this 'Label' object</summary>
<value>Name of label.</value>
<remarks>To be added.</remarks>
</Name>
</members>
</docs>
Expand Up @@ -3,26 +3,47 @@
<members name="SensitivityClassification">
<SensitivityClassification>
<summary>Provides the functionlity to retrieve Sensitivity Classification data as received from SQL Server for the active 'SqlDataReader'</summary>
<remarks>To be added.</remarks>
</SensitivityClassification>
<ColumnSensitivities>
<summary>Returns the column sensitivity for this 'SensitivityClassification' Object</summary>
<value>List of column sensitivities.</value>
<remarks>To be added.</remarks>
</ColumnSensitivities>
<InformationTypes>
<summary>Returns the information types collection for this 'SensitivityClassification' Object</summary>
<value>List of information types.</value>
<remarks>To be added.</remarks>
</InformationTypes>
<Labels>
<summary>Returns the labels collection for this 'SensitivityClassification' Object</summary>
<value>List of labels.</value>
<remarks>To be added.</remarks>
</Labels>
<SensitivityRank>
<summary>Returns the relative sensitivity rank for the query associated with the active 'SqlDataReader'.</summary>
<value>Relative sensitivity ranking for this query.</value>
<remarks>
<format type="text/markdown">
<![CDATA[
## Remarks
A relative sensitivity ranking of the query. Available values are as below:
| Sensitivity Rank | Description |
| --- | --- |
| -1 | Not Defined (default) |
| 0 | None |
| 10 | Low |
| 20 | Medium |
| 30 | High |
| 40 | Critical |
]]>
</format>
</remarks>
</SensitivityRank>
<ctor>
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.DataClassification.SensitivityClassification" />
class.</summary>
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.DataClassification.SensitivityClassification" /> class.</summary>
<param name="labels">List of labels.</param>
<param name="informationTypes">List of information types.</param>
<param name="columnSensitivity">List of column sensitivities.</param>
<param name="sensitivityRank">Relative sensitivity rank for the query associated with the active 'SqlDataReader'.</param>
</ctor>
</members>
</docs>
Expand Up @@ -3,20 +3,42 @@
<members name="SensitivityProperty">
<SensitivityProperty>
<summary>Represents the Data Classification Sensitivity Information for columns as configured in Database.</summary>
<remarks>To be added.</remarks>
</SensitivityProperty>
<ctor>
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.DataClassification.SensitivityProperty" /> class.</summary>
<param name="label">Label for this SensitivityProperty.</param>
<param name="informationType">Information type for this SensitivityProperty.</param>
<param name="sensitivityRank">Sensitivity rank for this SensitivityProperty.</param>
</ctor>
<InformationType>
<summary>Returns the information type for this 'SensitivityProperty' Object</summary>
<value>Information type for this SensitivityProperty.</value>
<remarks>To be added.</remarks>
</InformationType>
<Label>
<summary>Returns the label for this 'SensitivityProperty' Object</summary>
<value>Label for this SensitivityProperty.</value>
<remarks>To be added.</remarks>
</Label>
<SensitivityRank>
<summary>Returns the sensitivity rank for this 'SensitivityProperty' Object</summary>
<value>Sensitivity rank for this SensitivityProperty.</value>
<remarks>
<format type="text/markdown">
<![CDATA[
## Remarks
A relative sensitivity ranking of a column that is part of percolumn data. Available values are as below:
| Sensitivity Rank | Description |
| --- | --- |
| -1 | Not Defined (default) |
| 0 | None |
| 10 | Low |
| 20 | Medium |
| 30 | High |
| 40 | Critical |
]]>
</format>
</remarks>
</SensitivityRank>
</members>
</docs>
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<docs>
<members name="SensitivityRank">
<SensitivityRank>
<summary>
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.
</summary>
</SensitivityRank>
<NotDefined>No sensitivity rank defined.</NotDefined>
<None>Corresponds to rank value of 0.</None>
<Low>Corresponds to rank value of 10.</Low>
<Medium>Corresponds to rank value 20.</Medium>
<High>Corresponds to rank value 30.</High>
<Critical>Corresponds to rank value 40.</Critical>
</members>
</docs>
Expand Up @@ -1895,26 +1895,46 @@ public partial class Label
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/Label.xml' path='docs/members[@name="Label"]/Name/*' />
public string Name { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml' path='docs/members[@name="SensitivityRank"]/SensitivityRank/*' />
public enum SensitivityRank
{
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml' path='docs/members[@name="SensitivityRank"]/NotDefined/*' />
NOT_DEFINED = -1,
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml' path='docs/members[@name="SensitivityRank"]/None/*' />
NONE = 0,
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml' path='docs/members[@name="SensitivityRank"]/Low/*' />
LOW = 10,
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml' path='docs/members[@name="SensitivityRank"]/Medium/*' />
MEDIUM = 20,
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml' path='docs/members[@name="SensitivityRank"]/High/*' />
HIGH = 30,
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml' path='docs/members[@name="SensitivityRank"]/Critical/*' />
CRITICAL = 40
}
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityClassification.xml' path='docs/members[@name="SensitivityClassification"]/SensitivityClassification/*' />
public partial class SensitivityClassification
{
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityClassification.xml' path='docs/members[@name="SensitivityClassification"]/ctor/*' />
public SensitivityClassification(System.Collections.Generic.IList<Microsoft.Data.SqlClient.DataClassification.Label> labels, System.Collections.Generic.IList<Microsoft.Data.SqlClient.DataClassification.InformationType> informationTypes, System.Collections.Generic.IList<Microsoft.Data.SqlClient.DataClassification.ColumnSensitivity> columnSensitivity) { }
public SensitivityClassification(System.Collections.Generic.IList<Microsoft.Data.SqlClient.DataClassification.Label> labels, System.Collections.Generic.IList<Microsoft.Data.SqlClient.DataClassification.InformationType> informationTypes, System.Collections.Generic.IList<Microsoft.Data.SqlClient.DataClassification.ColumnSensitivity> columnSensitivity, SensitivityRank sensitivityRank) { }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityClassification.xml' path='docs/members[@name="SensitivityClassification"]/ColumnSensitivities/*' />
public System.Collections.ObjectModel.ReadOnlyCollection<Microsoft.Data.SqlClient.DataClassification.ColumnSensitivity> ColumnSensitivities { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityClassification.xml' path='docs/members[@name="SensitivityClassification"]/InformationTypes/*' />
public System.Collections.ObjectModel.ReadOnlyCollection<Microsoft.Data.SqlClient.DataClassification.InformationType> InformationTypes { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityClassification.xml' path='docs/members[@name="SensitivityClassification"]/Labels/*' />
public System.Collections.ObjectModel.ReadOnlyCollection<Microsoft.Data.SqlClient.DataClassification.Label> Labels { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityClassification.xml' path='docs/members[@name="SensitivityClassification"]/SensitivityRank/*' />
public SensitivityRank SensitivityRank { get { throw null; } }
}
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityProperty.xml' path='docs/members[@name="SensitivityProperty"]/SensitivityProperty/*' />
public partial class SensitivityProperty
{
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityProperty.xml' path='docs/members[@name="SensitivityProperty"]/ctor/*' />
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) { }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityProperty.xml' path='docs/members[@name="SensitivityProperty"]/InformationType/*' />
public Microsoft.Data.SqlClient.DataClassification.InformationType InformationType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityProperty.xml' path='docs/members[@name="SensitivityProperty"]/Label/*' />
public Microsoft.Data.SqlClient.DataClassification.Label Label { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityProperty.xml' path='docs/members[@name="SensitivityProperty"]/SensitivityRank/*' />
public SensitivityRank SensitivityRank { get { throw null; } }
}
}
Expand Up @@ -129,7 +129,6 @@ sealed internal class SqlInternalConnectionTds : SqlInternalConnection, IDisposa
private readonly SqlAuthenticationProviderManager _sqlAuthenticationProviderManager;

internal bool _cleanSQLDNSCaching = false;

private bool _serverSupportsDNSCaching = false;

/// <summary>
Expand Down Expand Up @@ -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("<sc.SqlInternalConnectionTds.OnFeatureExtAck|ERR> {0}, Invalid version number for DATACLASSIFICATION", ObjectID);
throw SQL.ParsingErrorValue(ParsingErrorState.DataClassificationInvalidVersion, supportedDataClassificationVersion);
Expand Down
Expand Up @@ -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
Expand Down

0 comments on commit 16f5f32

Please sign in to comment.