C#: Add LogForging testcase based on ASP.NET.

This commit is contained in:
Michael Nebel
2022-09-23 13:02:42 +02:00
parent 39402b842e
commit e45e06b675

View File

@@ -0,0 +1,21 @@
using System;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Headers;
using Microsoft.AspNetCore.Mvc;
public class AspController : ControllerBase
{
public void Action1(string username)
{
var logger = new ILogger();
// BAD: Logged as-is
logger.Warn(username + " logged in");
}
public void Action1(DateTime date)
{
var logger = new ILogger();
// GOOD: DateTime is a sanitizer. (FALSE POSITIVE)
logger.Warn($"Warning about the date: {date:yyyy-MM-dd}");
}
}