Skip to content

Commit f0e20fa

Browse files
committed
C#: Add test case for missing log message sinks with ambiguous types
1 parent 7263d4d commit f0e20fa

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#select
2+
compilationErrors
3+
| standalone.cs:16:12:16:18 | CS0104: 'ILogger' is an ambiguous reference between 'A.ILogger' and 'B.ILogger' |
4+
methodCalls
5+
| standalone.cs:20:9:20:21 | call to method |
6+
| standalone.cs:25:9:25:33 | call to method |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import semmle.code.csharp.security.dataflow.flowsinks.ExternalLocationSink
2+
import semmle.code.csharp.commons.Diagnostics
3+
4+
from ExternalLocationSink sink
5+
where sink.getLocation().getFile().fromSource()
6+
select sink, sink.getExpr()
7+
8+
query predicate compilationErrors(CompilerError e) { any() }
9+
10+
query predicate methodCalls(MethodCall m) { any() }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
semmle-extractor-options: --standalone
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using A;
2+
using B;
3+
4+
namespace A
5+
{
6+
public interface ILogger { }
7+
}
8+
9+
namespace B
10+
{
11+
public interface ILogger { }
12+
}
13+
14+
public class C
15+
{
16+
public ILogger logger;
17+
18+
private void M(string s)
19+
{
20+
logger.Log(s);
21+
}
22+
23+
private static void Main()
24+
{
25+
new C().logger.Log("abc");
26+
}
27+
}

0 commit comments

Comments
 (0)