Skip to content

Commit 2ec2e72

Browse files
dauinsightDavid-EngelJRahnamaDavoudEshtehari
authored
[4.0.6] | Fix CodeQL and Rozlyn warnings (#2428) and (#2432) (#2513)
[4.0.6] | Fix CodeQL and Rozlyn warnings (#2428) and (#2432) --------- Co-authored-by: David Engel <v-davidengel@microsoft.com> Co-authored-by: Javad Rahnama <v-jarahn@microsoft.com> Co-authored-by: David Engel <dengel1012@gmail.com> Co-authored-by: DavoudEshtehari <61173489+DavoudEshtehari@users.noreply.github.com>
1 parent 070d343 commit 2ec2e72

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
@@ -822,13 +822,14 @@ private static string ToFriendlyName(this SslProtocols protocol)
822822
{
823823
name = "TLS 1.0";
824824
}
825-
#pragma warning disable CS0618 // Type or member is obsolete: SSL is depricated
825+
// SSL 2.0 and 3.0 are only referenced to log a warning, not explicitly used for connections
826+
#pragma warning disable CS0618, CA5397
826827
else if ((protocol & SslProtocols.Ssl3) == SslProtocols.Ssl3)
827828
{
828829
name = "SSL 3.0";
829830
}
830831
else if ((protocol & SslProtocols.Ssl2) == SslProtocols.Ssl2)
831-
#pragma warning restore CS0618 // Type or member is obsolete: SSL is depricated
832+
#pragma warning restore CS0618, CA5397
832833
{
833834
name = "SSL 2.0";
834835
}
@@ -848,9 +849,10 @@ private static string ToFriendlyName(this SslProtocols protocol)
848849
public static string GetProtocolWarning(this SslProtocols protocol)
849850
{
850851
string message = string.Empty;
851-
#pragma warning disable CS0618 // Type or member is obsolete : SSL is depricated
852+
// SSL 2.0 and 3.0 are only referenced to log a warning, not explicitly used for connections
853+
#pragma warning disable CS0618, CA5397
852854
if ((protocol & (SslProtocols.Ssl2 | SslProtocols.Ssl3 | SslProtocols.Tls | SslProtocols.Tls11)) != SslProtocols.None)
853-
#pragma warning restore CS0618 // Type or member is obsolete : SSL is depricated
855+
#pragma warning restore CS0618, CA5397
854856
{
855857
message = StringsHelper.Format(Strings.SEC_ProtocolWarning, protocol.ToFriendlyName());
856858
}

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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,13 @@ 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+
#pragma warning disable IA5352
250+
// CodeQL [SM00395] By design. Always Encrypted certificates should not be checked.
246251
chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck;
252+
#pragma warning restore IA5352
247253

248254
if (!chain.Build(healthReportCert))
249255
{

0 commit comments

Comments
 (0)