Skip to content

Commit 60e3b43

Browse files
committed
C#: Fix simple types testcases.
1 parent 024712c commit 60e3b43

File tree

2 files changed

+54
-46
lines changed

2 files changed

+54
-46
lines changed

csharp/ql/test/query-tests/Security Features/CWE-117/LogForgingAsp.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
using Microsoft.AspNetCore.Http.Headers;
44
using Microsoft.AspNetCore.Mvc;
55

6+
public enum TestEnum
7+
{
8+
TestEnumValue
9+
}
10+
611
public class AspController : ControllerBase
712
{
813
public void Action1(string username)
@@ -38,4 +43,53 @@ public void Action2(bool? b)
3843
logger.Warn($"Warning about the bool: {b}");
3944
}
4045
}
46+
47+
public void ActionInt(int i)
48+
{
49+
var logger = new ILogger();
50+
// GOOD: int is a sanitizer.
51+
logger.Warn($"Warning about the int: {i}");
52+
}
53+
54+
public void ActionLong(long l)
55+
{
56+
var logger = new ILogger();
57+
// GOOD: long is a sanitizer.
58+
logger.Warn($"Warning about the long: {l}");
59+
}
60+
61+
public void ActionFloat(float f)
62+
{
63+
var logger = new ILogger();
64+
// GOOD: float is a sanitizer.
65+
logger.Warn($"Warning about the float: {f}");
66+
}
67+
68+
public void ActionDouble(double d)
69+
{
70+
var logger = new ILogger();
71+
// GOOD: double is a sanitizer.
72+
logger.Warn($"Warning about the double: {d}");
73+
}
74+
75+
public void ActionDecimal(decimal d)
76+
{
77+
var logger = new ILogger();
78+
// GOOD: decimal is a sanitizer.
79+
logger.Warn($"Warning about the decimal: {d}");
80+
}
81+
82+
public void ActionEnum(TestEnum e)
83+
{
84+
var logger = new ILogger();
85+
// GOOD: Enum is a sanitizer. [FALSE POSITIVE]
86+
logger.Warn($"Warning about the enum: {e}");
87+
}
88+
89+
public void ActionDateTime(DateTimeOffset dt)
90+
{
91+
var logger = new ILogger();
92+
// GOOD: DateTimeOffset is a sanitizer. [FALSEPOSITIVE]
93+
logger.Warn($"Warning about the DateTimeOffset: {dt}");
94+
}
4195
}

csharp/ql/test/query-tests/Security Features/CWE-117/LogForgingSimpleTypes.cs

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)