Skip to content

Commit e45e06b

Browse files
committed
C#: Add LogForging testcase based on ASP.NET.
1 parent 39402b8 commit e45e06b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using Microsoft.AspNetCore.Http;
3+
using Microsoft.AspNetCore.Http.Headers;
4+
using Microsoft.AspNetCore.Mvc;
5+
6+
public class AspController : ControllerBase
7+
{
8+
public void Action1(string username)
9+
{
10+
var logger = new ILogger();
11+
// BAD: Logged as-is
12+
logger.Warn(username + " logged in");
13+
}
14+
15+
public void Action1(DateTime date)
16+
{
17+
var logger = new ILogger();
18+
// GOOD: DateTime is a sanitizer. (FALSE POSITIVE)
19+
logger.Warn($"Warning about the date: {date:yyyy-MM-dd}");
20+
}
21+
}

0 commit comments

Comments
 (0)