mirror of
https://github.com/github/codeql.git
synced 2026-04-20 14:34:04 +02:00
C#: Add test case for missing log message sinks with ambiguous types
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
#select
|
||||
compilationErrors
|
||||
| standalone.cs:16:12:16:18 | CS0104: 'ILogger' is an ambiguous reference between 'A.ILogger' and 'B.ILogger' |
|
||||
methodCalls
|
||||
| standalone.cs:20:9:20:21 | call to method |
|
||||
| standalone.cs:25:9:25:33 | call to method |
|
||||
@@ -0,0 +1,10 @@
|
||||
import semmle.code.csharp.security.dataflow.flowsinks.ExternalLocationSink
|
||||
import semmle.code.csharp.commons.Diagnostics
|
||||
|
||||
from ExternalLocationSink sink
|
||||
where sink.getLocation().getFile().fromSource()
|
||||
select sink, sink.getExpr()
|
||||
|
||||
query predicate compilationErrors(CompilerError e) { any() }
|
||||
|
||||
query predicate methodCalls(MethodCall m) { any() }
|
||||
@@ -0,0 +1 @@
|
||||
semmle-extractor-options: --standalone
|
||||
@@ -0,0 +1,27 @@
|
||||
using A;
|
||||
using B;
|
||||
|
||||
namespace A
|
||||
{
|
||||
public interface ILogger { }
|
||||
}
|
||||
|
||||
namespace B
|
||||
{
|
||||
public interface ILogger { }
|
||||
}
|
||||
|
||||
public class C
|
||||
{
|
||||
public ILogger logger;
|
||||
|
||||
private void M(string s)
|
||||
{
|
||||
logger.Log(s);
|
||||
}
|
||||
|
||||
private static void Main()
|
||||
{
|
||||
new C().logger.Log("abc");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user