Skip to content

Commit 908f563

Browse files
authored
Fix | Suppress CodeQL warning for usage of deprecated Ssl2. (#2428)
1 parent 740069d commit 908f563

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

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

+6-4
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

+3-2
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
{

0 commit comments

Comments
 (0)