Skip to content

Commit

Permalink
Add test case with Func<T, bool>
Browse files Browse the repository at this point in the history
  • Loading branch information
costin-zaharia-sonarsource committed May 15, 2024
1 parent 0e37049 commit c9fdf40
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Security.Cryptography;
using System.Security.Cryptography.Xml;
using System.Xml;
using System.Linq;

public class XMLSignatures
{
Expand All @@ -11,14 +12,16 @@ public void TestCases(RSACryptoServiceProvider rsaCryptoServiceProvider)
SignedXml signedXml = new SignedXml(xmlDoc);
signedXml.LoadXml((XmlElement)xmlDoc.GetElementsByTagName("Signature").Item(0));

_ = signedXml.CheckSignature(rsaCryptoServiceProvider); // A key is provided.
_ = signedXml.CheckSignature("other"); // Custom defined extension method.
_ = signedXml.CheckSignatureReturningKey("other"); // Custom defined extension method.
_ = signedXml.CheckSignature(rsaCryptoServiceProvider); // A key is provided.
_ = signedXml.CheckSignature("other"); // Custom defined extension method.
_ = signedXml.CheckSignatureReturningKey("other"); // Custom defined extension method.
_ = new[] { rsaCryptoServiceProvider }.Select(signedXml.CheckSignature); // Used as an Func<T, bool>, parameter is provided.

_ = signedXml.CheckSignature(); // Noncompliant {{Change this code to only accept signatures computed from a trusted party.}}
_ = signedXml.CheckSignature(); // Noncompliant {{Change this code to only accept signatures computed from a trusted party.}}
// ^^^^^^^^^^^^^^^^^^^^^^^^^^
_ = signedXml.CheckSignatureReturningKey(out var signingKey); // Noncompliant {{Change this code to only accept signatures computed from a trusted party.}}
_ = signedXml.CheckSignatureReturningKey(out var signingKey); // Noncompliant {{Change this code to only accept signatures computed from a trusted party.}}
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

}
}

Expand Down

0 comments on commit c9fdf40

Please sign in to comment.