Skip to content

Commit 7dee5cd

Browse files
[5.2.1] | Fix CodeQL and Rozlyn warnings (dotnet#2428) and (dotnet#2432)
1 parent faf9b95 commit 7dee5cd

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-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
@@ -764,13 +764,14 @@ private static string ToFriendlyName(this SslProtocols protocol)
764764
{
765765
name = "TLS 1.0";
766766
}
767-
#pragma warning disable CS0618 // Type or member is obsolete: SSL is depricated
767+
// SSL 2.0 and 3.0 are only referenced to log a warning, not explicitly used for connections
768+
#pragma warning disable CS0618, CA5397
768769
else if ((protocol & SslProtocols.Ssl3) == SslProtocols.Ssl3)
769770
{
770771
name = "SSL 3.0";
771772
}
772773
else if ((protocol & SslProtocols.Ssl2) == SslProtocols.Ssl2)
773-
#pragma warning restore CS0618 // Type or member is obsolete: SSL is depricated
774+
#pragma warning restore CS0618, CA5397
774775
{
775776
name = "SSL 2.0";
776777
}
@@ -790,9 +791,10 @@ private static string ToFriendlyName(this SslProtocols protocol)
790791
public static string GetProtocolWarning(this SslProtocols protocol)
791792
{
792793
string message = string.Empty;
793-
#pragma warning disable CS0618 // Type or member is obsolete : SSL is depricated
794+
// SSL 2.0 and 3.0 are only referenced to log a warning, not explicitly used for connections
795+
#pragma warning disable CS0618, CA5397
794796
if ((protocol & (SslProtocols.Ssl2 | SslProtocols.Ssl3 | SslProtocols.Tls | SslProtocols.Tls11)) != SslProtocols.None)
795-
#pragma warning restore CS0618 // Type or member is obsolete : SSL is depricated
797+
#pragma warning restore CS0618, CA5397
796798
{
797799
message = StringsHelper.Format(Strings.SEC_ProtocolWarning, protocol.ToFriendlyName());
798800
}

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
@@ -427,13 +427,14 @@ internal override uint WaitForSSLHandShakeToComplete(out int protocolVersion)
427427
}
428428
else if (nativeProtocol.HasFlag(NativeProtocols.SP_PROT_SSL3_CLIENT) || nativeProtocol.HasFlag(NativeProtocols.SP_PROT_SSL3_SERVER))
429429
{
430-
#pragma warning disable CS0618 // Type or member is obsolete : SSL is depricated
430+
// SSL 2.0 and 3.0 are only referenced to log a warning, not explicitly used for connections
431+
#pragma warning disable CS0618, CA5397
431432
protocolVersion = (int)SslProtocols.Ssl3;
432433
}
433434
else if (nativeProtocol.HasFlag(NativeProtocols.SP_PROT_SSL2_CLIENT) || nativeProtocol.HasFlag(NativeProtocols.SP_PROT_SSL2_SERVER))
434435
{
435436
protocolVersion = (int)SslProtocols.Ssl2;
436-
#pragma warning restore CS0618 // Type or member is obsolete : SSL is depricated
437+
#pragma warning restore CS0618, CA5397
437438
}
438439
else //if (nativeProtocol.HasFlag(NativeProtocols.SP_PROT_NONE))
439440
{

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,13 @@ private bool VerifyHealthReportAgainstRootCertificate(X509Certificate2Collection
252252
chain.ChainPolicy.ExtraStore.Add(cert);
253253
}
254254

255+
// An Always Encrypted-enabled driver doesn't verify an expiration date or a certificate authority chain.
256+
// A certificate is simply used as a key pair consisting of a public and private key. This is by design.
257+
258+
#pragma warning disable IA5352
259+
// CodeQL [SM00395] By design. Always Encrypted certificates should not be checked.
255260
chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck;
261+
#pragma warning restore IA5352
256262

257263
if (!chain.Build(healthReportCert))
258264
{

0 commit comments

Comments
 (0)