Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing CodeQL angry faces #95

Merged
merged 4 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void AddCannedResponse(string uri, string content)

public HttpClient CreateClient(string name)
{
return new HttpClient(new Handler(_cannedResponses, _unexpectedRequests)); // lgtm [cs/httpclient-checkcertrevlist-disabled] Used in unit testing
return new HttpClient(new Handler(_cannedResponses, _unexpectedRequests)); // CodeQL [SM02185] Mock HttpClient used in unit testing
}

public void VerifyAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
namespace Microsoft.DotNet.Web.Authentication.Tests.Controllers;

[Route("test-auth/anonymous")]
[AllowAnonymous]
public class AnonymousAttributeController : ControllerBase
{
[AllowAnonymous]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should just be deleted, since it's identical to the next test. Ideally, you'd have wanted another test that had the "inherit from the controller" behavior tested (you'd just need to not have any Authorize attributes in that controller to keep CodeQL quiet)

[Route("no")]
public IActionResult NoAttribute()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ public string HashPassword(TestUser user, string password)

public static string CalculateHash(TestUser user, string password)
{
return $":HASH:{user.Name}:{password}"; // lgtm [cs/hardcoded-credentials] Part of unit tests
return $":HASH:{user.Name}:{password}"; // CodeQL [SM00423] Hardcoded as part of unit tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These aren't even hardcoded, this a string interpolation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to put 25 characters in there for a reason :D

}

public PasswordVerificationResult VerifyHashedPassword(
Expand Down
Loading