Skip to content

Commit 16f5f32

Browse files
Feature | Add support for Data Classification v2 (#626)
1 parent 762d24f commit 16f5f32

File tree

16 files changed

+494
-290
lines changed

16 files changed

+494
-290
lines changed

doc/snippets/Microsoft.Data.SqlClient.DataClassification/ColumnSensitivity.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
<members name="ColumnSensitivity">
44
<ColumnSensitivity>
55
<summary>Represents the Data Classification Sensitivity Information for columns as configured in Database.</summary>
6-
<remarks>To be added.</remarks>
76
</ColumnSensitivity>
87
<ctor>
98
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.DataClassification.ColumnSensitivity" /> class.</summary>
9+
<param name="sensitivityProperties">List of sensitivity properties.</param>
1010
</ctor>
1111
<GetSensitivityProperties>
1212
<summary>Returns the list of sensitivity properties as received from Server for this 'ColumnSensitivity' information</summary>
1313
<value>List of sensitivity properties.</value>
14-
<remarks>To be added.</remarks>
1514
</GetSensitivityProperties>
1615
</members>
1716
</docs>

doc/snippets/Microsoft.Data.SqlClient.DataClassification/InformationType.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@
33
<members name="InformationType">
44
<InformationType>
55
<summary>Represents the Data Classification Information Types as received from SQL Server for the active 'SqlDataReader'</summary>
6-
<remarks>To be added.</remarks>
76
</InformationType>
87
<ctor>
98
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.DataClassification.InformationType" /> class.</summary>
9+
<param name="name">Name of Information Type.</param>
10+
<param name="id">ID of Information Type.</param>
1011
</ctor>
1112
<Id>
1213
<summary>Gets the ID for this 'InformationType' object</summary>
13-
<value>ID of InformationType.</value>
14-
<remarks>To be added.</remarks>
14+
<value>ID of Information Type.</value>
1515
</Id>
1616
<Name>
1717
<summary>Gets the name for this 'InformationType' object</summary>
18-
<value>Name of InformationType.</value>
19-
<remarks>To be added.</remarks>
18+
<value>Name of Information Type.</value>
2019
</Name>
2120
</members>
2221
</docs>

doc/snippets/Microsoft.Data.SqlClient.DataClassification/Label.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@
33
<members name="Label">
44
<Label>
55
<summary>Represents the Data Classification Labels as received from SQL Server for the active 'SqlDataReader'</summary>
6-
<remarks>To be added.</remarks>
76
</Label>
87
<ctor>
98
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.DataClassification.Label" /> class.</summary>
9+
<param name="name">Name of label.</param>
10+
<param name="id">ID of label.</param>
1011
</ctor>
1112
<Id>
1213
<summary>Gets the ID for this 'Label' object</summary>
1314
<value>ID of label.</value>
14-
<remarks>To be added.</remarks>
1515
</Id>
1616
<Name>
1717
<summary>Gets the name for this 'Label' object</summary>
1818
<value>Name of label.</value>
19-
<remarks>To be added.</remarks>
2019
</Name>
2120
</members>
2221
</docs>

doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityClassification.xml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,47 @@
33
<members name="SensitivityClassification">
44
<SensitivityClassification>
55
<summary>Provides the functionlity to retrieve Sensitivity Classification data as received from SQL Server for the active 'SqlDataReader'</summary>
6-
<remarks>To be added.</remarks>
76
</SensitivityClassification>
87
<ColumnSensitivities>
98
<summary>Returns the column sensitivity for this 'SensitivityClassification' Object</summary>
109
<value>List of column sensitivities.</value>
11-
<remarks>To be added.</remarks>
1210
</ColumnSensitivities>
1311
<InformationTypes>
1412
<summary>Returns the information types collection for this 'SensitivityClassification' Object</summary>
1513
<value>List of information types.</value>
16-
<remarks>To be added.</remarks>
1714
</InformationTypes>
1815
<Labels>
1916
<summary>Returns the labels collection for this 'SensitivityClassification' Object</summary>
2017
<value>List of labels.</value>
21-
<remarks>To be added.</remarks>
2218
</Labels>
19+
<SensitivityRank>
20+
<summary>Returns the relative sensitivity rank for the query associated with the active 'SqlDataReader'.</summary>
21+
<value>Relative sensitivity ranking for this query.</value>
22+
<remarks>
23+
<format type="text/markdown">
24+
<![CDATA[
25+
26+
## Remarks
27+
A relative sensitivity ranking of the query. Available values are as below:
28+
29+
| Sensitivity Rank | Description |
30+
| --- | --- |
31+
| -1 | Not Defined (default) |
32+
| 0 | None |
33+
| 10 | Low |
34+
| 20 | Medium |
35+
| 30 | High |
36+
| 40 | Critical |
37+
]]>
38+
</format>
39+
</remarks>
40+
</SensitivityRank>
2341
<ctor>
24-
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.DataClassification.SensitivityClassification" />
25-
class.</summary>
42+
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.DataClassification.SensitivityClassification" /> class.</summary>
43+
<param name="labels">List of labels.</param>
44+
<param name="informationTypes">List of information types.</param>
45+
<param name="columnSensitivity">List of column sensitivities.</param>
46+
<param name="sensitivityRank">Relative sensitivity rank for the query associated with the active 'SqlDataReader'.</param>
2647
</ctor>
2748
</members>
2849
</docs>

doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityProperty.xml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,42 @@
33
<members name="SensitivityProperty">
44
<SensitivityProperty>
55
<summary>Represents the Data Classification Sensitivity Information for columns as configured in Database.</summary>
6-
<remarks>To be added.</remarks>
76
</SensitivityProperty>
87
<ctor>
98
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.DataClassification.SensitivityProperty" /> class.</summary>
9+
<param name="label">Label for this SensitivityProperty.</param>
10+
<param name="informationType">Information type for this SensitivityProperty.</param>
11+
<param name="sensitivityRank">Sensitivity rank for this SensitivityProperty.</param>
1012
</ctor>
1113
<InformationType>
1214
<summary>Returns the information type for this 'SensitivityProperty' Object</summary>
1315
<value>Information type for this SensitivityProperty.</value>
14-
<remarks>To be added.</remarks>
1516
</InformationType>
1617
<Label>
1718
<summary>Returns the label for this 'SensitivityProperty' Object</summary>
1819
<value>Label for this SensitivityProperty.</value>
19-
<remarks>To be added.</remarks>
2020
</Label>
21+
<SensitivityRank>
22+
<summary>Returns the sensitivity rank for this 'SensitivityProperty' Object</summary>
23+
<value>Sensitivity rank for this SensitivityProperty.</value>
24+
<remarks>
25+
<format type="text/markdown">
26+
<![CDATA[
27+
28+
## Remarks
29+
A relative sensitivity ranking of a column that is part of percolumn data. Available values are as below:
30+
31+
| Sensitivity Rank | Description |
32+
| --- | --- |
33+
| -1 | Not Defined (default) |
34+
| 0 | None |
35+
| 10 | Low |
36+
| 20 | Medium |
37+
| 30 | High |
38+
| 40 | Critical |
39+
]]>
40+
</format>
41+
</remarks>
42+
</SensitivityRank>
2143
</members>
2244
</docs>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<docs>
3+
<members name="SensitivityRank">
4+
<SensitivityRank>
5+
<summary>
6+
A relative ranking of the sensitivity of a query or of a column that is part of percolumn data.
7+
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.
8+
</summary>
9+
</SensitivityRank>
10+
<NotDefined>No sensitivity rank defined.</NotDefined>
11+
<None>Corresponds to rank value of 0.</None>
12+
<Low>Corresponds to rank value of 10.</Low>
13+
<Medium>Corresponds to rank value 20.</Medium>
14+
<High>Corresponds to rank value 30.</High>
15+
<Critical>Corresponds to rank value 40.</Critical>
16+
</members>
17+
</docs>

src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,26 +1895,46 @@ public Label(string name, string id) { }
18951895
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/Label.xml' path='docs/members[@name="Label"]/Name/*' />
18961896
public string Name { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
18971897
}
1898+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml' path='docs/members[@name="SensitivityRank"]/SensitivityRank/*' />
1899+
public enum SensitivityRank
1900+
{
1901+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml' path='docs/members[@name="SensitivityRank"]/NotDefined/*' />
1902+
NOT_DEFINED = -1,
1903+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml' path='docs/members[@name="SensitivityRank"]/None/*' />
1904+
NONE = 0,
1905+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml' path='docs/members[@name="SensitivityRank"]/Low/*' />
1906+
LOW = 10,
1907+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml' path='docs/members[@name="SensitivityRank"]/Medium/*' />
1908+
MEDIUM = 20,
1909+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml' path='docs/members[@name="SensitivityRank"]/High/*' />
1910+
HIGH = 30,
1911+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml' path='docs/members[@name="SensitivityRank"]/Critical/*' />
1912+
CRITICAL = 40
1913+
}
18981914
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityClassification.xml' path='docs/members[@name="SensitivityClassification"]/SensitivityClassification/*' />
18991915
public partial class SensitivityClassification
19001916
{
19011917
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityClassification.xml' path='docs/members[@name="SensitivityClassification"]/ctor/*' />
1902-
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) { }
1918+
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) { }
19031919
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityClassification.xml' path='docs/members[@name="SensitivityClassification"]/ColumnSensitivities/*' />
19041920
public System.Collections.ObjectModel.ReadOnlyCollection<Microsoft.Data.SqlClient.DataClassification.ColumnSensitivity> ColumnSensitivities { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
19051921
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityClassification.xml' path='docs/members[@name="SensitivityClassification"]/InformationTypes/*' />
19061922
public System.Collections.ObjectModel.ReadOnlyCollection<Microsoft.Data.SqlClient.DataClassification.InformationType> InformationTypes { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
19071923
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityClassification.xml' path='docs/members[@name="SensitivityClassification"]/Labels/*' />
19081924
public System.Collections.ObjectModel.ReadOnlyCollection<Microsoft.Data.SqlClient.DataClassification.Label> Labels { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
1925+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityClassification.xml' path='docs/members[@name="SensitivityClassification"]/SensitivityRank/*' />
1926+
public SensitivityRank SensitivityRank { get { throw null; } }
19091927
}
19101928
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityProperty.xml' path='docs/members[@name="SensitivityProperty"]/SensitivityProperty/*' />
19111929
public partial class SensitivityProperty
19121930
{
19131931
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityProperty.xml' path='docs/members[@name="SensitivityProperty"]/ctor/*' />
1914-
public SensitivityProperty(Microsoft.Data.SqlClient.DataClassification.Label label, Microsoft.Data.SqlClient.DataClassification.InformationType informationType) { }
1932+
public SensitivityProperty(Microsoft.Data.SqlClient.DataClassification.Label label, Microsoft.Data.SqlClient.DataClassification.InformationType informationType, SensitivityRank sensitivityRank) { }
19151933
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityProperty.xml' path='docs/members[@name="SensitivityProperty"]/InformationType/*' />
19161934
public Microsoft.Data.SqlClient.DataClassification.InformationType InformationType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
19171935
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityProperty.xml' path='docs/members[@name="SensitivityProperty"]/Label/*' />
19181936
public Microsoft.Data.SqlClient.DataClassification.Label Label { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
1937+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityProperty.xml' path='docs/members[@name="SensitivityProperty"]/SensitivityRank/*' />
1938+
public SensitivityRank SensitivityRank { get { throw null; } }
19191939
}
19201940
}

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ sealed internal class SqlInternalConnectionTds : SqlInternalConnection, IDisposa
129129
private readonly SqlAuthenticationProviderManager _sqlAuthenticationProviderManager;
130130

131131
internal bool _cleanSQLDNSCaching = false;
132-
133132
private bool _serverSupportsDNSCaching = false;
134133

135134
/// <summary>
@@ -2610,7 +2609,7 @@ internal void OnFeatureExtAck(int featureId, byte[] data)
26102609
throw SQL.ParsingError(ParsingErrorState.CorruptedTdsStream);
26112610
}
26122611
byte supportedDataClassificationVersion = data[0];
2613-
if ((0 == supportedDataClassificationVersion) || (supportedDataClassificationVersion > TdsEnums.MAX_SUPPORTED_DATA_CLASSIFICATION_VERSION))
2612+
if ((0 == supportedDataClassificationVersion) || (supportedDataClassificationVersion > TdsEnums.DATA_CLASSIFICATION_VERSION_MAX_SUPPORTED))
26142613
{
26152614
SqlClientEventSource.Log.TraceEvent("<sc.SqlInternalConnectionTds.OnFeatureExtAck|ERR> {0}, Invalid version number for DATACLASSIFICATION", ObjectID);
26162615
throw SQL.ParsingErrorValue(ParsingErrorState.DataClassificationInvalidVersion, supportedDataClassificationVersion);

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsEnums.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,8 @@ internal enum FedAuthInfoId : byte
933933

934934
// Data Classification constants
935935
internal const byte DATA_CLASSIFICATION_NOT_ENABLED = 0x00;
936-
internal const byte MAX_SUPPORTED_DATA_CLASSIFICATION_VERSION = 0x01;
936+
internal const byte DATA_CLASSIFICATION_VERSION_WITHOUT_RANK_SUPPORT = 0x01;
937+
internal const byte DATA_CLASSIFICATION_VERSION_MAX_SUPPORTED = 0x02;
937938

938939
// Needed for UapAot, since we cannot use Enum.GetName() on SniContext.
939940
// Enum.GetName() uses reflection, which is blocked on UapAot for internal types

0 commit comments

Comments
 (0)