Skip to content

Commit

Permalink
Enable SA1404 Code analysis suppression should have justification (#3…
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub authored Jul 3, 2020
1 parent 67c8134 commit 68eb040
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion eng/CodeAnalysis.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@
<Rule Id="SA1401" Action="None" /> <!-- Fields should be private -->
<Rule Id="SA1402" Action="None" /> <!-- File may only contain a single type -->
<Rule Id="SA1403" Action="None" /> <!-- File may only contain a single namespace -->
<Rule Id="SA1404" Action="None" /> <!-- Code analysis suppression should have justification -->
<Rule Id="SA1404" Action="Warning" /> <!-- Code analysis suppression should have justification -->
<Rule Id="SA1405" Action="None" /> <!-- Debug.Assert should provide message text -->
<Rule Id="SA1407" Action="None" /> <!-- Arithmetic expressions should declare precedence -->
<Rule Id="SA1408" Action="None" /> <!-- Conditional expressions should declare precedence -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ namespace Internal.Cryptography
{
internal static class TripleDesBCryptModes
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5350")] // We are providing the implementation for 3DES not consuming it
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5350", Justification = "We are providing the implementation for TripleDES, not consuming it")]
private static readonly SafeAlgorithmHandle s_hAlgCbc = Open3DesAlgorithm(Cng.BCRYPT_CHAIN_MODE_CBC);
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5350")] // We are providing the implementation for 3DES not consuming it
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5350", Justification = "We are providing the implementation for TripleDES, not consuming it")]
private static readonly SafeAlgorithmHandle s_hAlgEcb = Open3DesAlgorithm(Cng.BCRYPT_CHAIN_MODE_ECB);

internal static SafeAlgorithmHandle GetSharedHandle(CipherMode cipherMode) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ internal override IList<string> GetMemberNames(bool dataOnly)
return ComTypeDesc.GetMemberNames(dataOnly);
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
internal override IList<KeyValuePair<string, object>> GetMembers(IEnumerable<string> names)
{
if (names == null)
Expand Down Expand Up @@ -321,7 +320,6 @@ DynamicMetaObject IDynamicMetaObjectProvider.GetMetaObject(Expression parameter)
return new IDispatchMetaObject(parameter, this);
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes")]
private static void GetFuncDescForDescIndex(ComTypes.ITypeInfo typeInfo, int funcIndex, out ComTypes.FUNCDESC funcDesc, out IntPtr funcDescHandle)
{
IntPtr pFuncDesc;
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/System.Private.CoreLib/src/System/Object.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public Object()
// Allow an object to free resources before the object is reclaimed by the GC.
// This method's virtual slot number is hardcoded in runtimes. Do not add any virtual methods ahead of this.
[NonVersionable]
[SuppressMessage("Microsoft.Performance", "CA1821:RemoveEmptyFinalizers")]
[SuppressMessage("Microsoft.Performance", "CA1821:RemoveEmptyFinalizers", Justification = "Base finalizer method on Object")]
~Object()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected CriticalFinalizerObject()
{
}

[SuppressMessage("Microsoft.Performance", "CA1821:RemoveEmptyFinalizers")]
[SuppressMessage("Microsoft.Performance", "CA1821:RemoveEmptyFinalizers", Justification = "Base finalizer method on CriticalFinalizerObject")]
~CriticalFinalizerObject()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Internal.Cryptography
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5350")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5350", Justification = "We are providing the implementation for DES, not consuming it.")]
internal sealed partial class DesImplementation : DES
{
private const int BitsPerByte = 8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Internal.Cryptography
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5350")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5350", Justification = "We are providing the implementation for RC2, not consuming it.")]
internal sealed partial class RC2Implementation : RC2
{
private const int BitsPerByte = 8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Internal.Cryptography
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5350")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5350", Justification = "We are providing the implementation for TripleDES, not consuming it.")]
internal sealed partial class TripleDesImplementation : TripleDES
{
private const int BitsPerByte = 8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace System.Security.Cryptography
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5350")] // We are providing the implementation for 3DES not consuming it
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5350", Justification = "We are providing the implementation for TripleDES, not consuming it.")]
public abstract class TripleDES : SymmetricAlgorithm
{
protected TripleDES()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace System.Security.Cryptography
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5350")] // We are providing the implementation for 3DES not consuming it
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5350", Justification = "We are providing the implementation for TripleDES, not consuming it")]
public sealed class TripleDESCng : TripleDES, ICngSymmetricAlgorithm
{
public TripleDESCng()
Expand Down

0 comments on commit 68eb040

Please sign in to comment.