Skip to content

Commit 5520453

Browse files
[3.1.6] | Fix CodeQL and Rozlyn warnings (#2428) and (#2432) (#2515)
* Fix CodeQL and Rozlyn warnings (#2428) and (#2432) --------- Co-authored-by: Aris Rellegue <[email protected]>
1 parent 39b13a6 commit 5520453

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,13 +1001,14 @@ private static string ToFriendlyName(this SslProtocols protocol)
10011001
{
10021002
name = "TLS 1.0";
10031003
}
1004-
#pragma warning disable CS0618 // Type or member is obsolete: SSL is depricated
1004+
// SSL 2.0 and 3.0 are only referenced to log a warning, not explicitly used for connections
1005+
#pragma warning disable CS0618, CA5397
10051006
else if ((protocol & SslProtocols.Ssl3) == SslProtocols.Ssl3)
10061007
{
10071008
name = "SSL 3.0";
10081009
}
10091010
else if ((protocol & SslProtocols.Ssl2) == SslProtocols.Ssl2)
1010-
#pragma warning restore CS0618 // Type or member is obsolete: SSL is depricated
1011+
#pragma warning restore CS0618, CA5397
10111012
{
10121013
name = "SSL 2.0";
10131014
}
@@ -1027,9 +1028,10 @@ private static string ToFriendlyName(this SslProtocols protocol)
10271028
public static string GetProtocolWarning(this SslProtocols protocol)
10281029
{
10291030
string message = string.Empty;
1030-
#pragma warning disable CS0618 // Type or member is obsolete : SSL is depricated
1031+
// SSL 2.0 and 3.0 are only referenced to log a warning, not explicitly used for connections
1032+
#pragma warning disable CS0618, CA5397
10311033
if ((protocol & (SslProtocols.Ssl2 | SslProtocols.Ssl3 | SslProtocols.Tls | SslProtocols.Tls11)) != SslProtocols.None)
1032-
#pragma warning restore CS0618 // Type or member is obsolete : SSL is depricated
1034+
#pragma warning restore CS0618, CA5397
10331035
{
10341036
message = StringsHelper.Format(Strings.SEC_ProtocolWarning, protocol.ToFriendlyName());
10351037
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,14 @@ internal override uint WaitForSSLHandShakeToComplete(out int protocolVersion)
413413
}
414414
else if (nativeProtocol.HasFlag(NativeProtocols.SP_PROT_SSL3_CLIENT) || nativeProtocol.HasFlag(NativeProtocols.SP_PROT_SSL3_SERVER))
415415
{
416-
#pragma warning disable CS0618 // Type or member is obsolete : SSL is depricated
416+
// SSL 2.0 and 3.0 are only referenced to log a warning, not explicitly used for connections
417+
#pragma warning disable CS0618, CA5397
417418
protocolVersion = (int)SslProtocols.Ssl3;
418419
}
419420
else if (nativeProtocol.HasFlag(NativeProtocols.SP_PROT_SSL2_CLIENT) || nativeProtocol.HasFlag(NativeProtocols.SP_PROT_SSL2_SERVER))
420421
{
421422
protocolVersion = (int)SslProtocols.Ssl2;
422-
#pragma warning restore CS0618 // Type or member is obsolete : SSL is depricated
423+
#pragma warning restore CS0618, CA5397
423424
}
424425
else if (nativeProtocol.HasFlag(NativeProtocols.SP_PROT_NONE))
425426
{

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/VirtualSecureModeEnclaveProviderBase.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ private bool VerifyHealthReportAgainstRootCertificate(X509Certificate2Collection
243243
chain.ChainPolicy.ExtraStore.Add(cert);
244244
}
245245

246+
// An Always Encrypted-enabled driver doesn't verify an expiration date or a certificate authority chain.
247+
// A certificate is simply used as a key pair consisting of a public and private key. This is by design.
248+
249+
// CodeQL [SM00395] By design. Always Encrypted certificates should not be checked.
246250
chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck;
247251

248252
if (!chain.Build(healthReportCert))

0 commit comments

Comments
 (0)