C#: Add test case for missing log message sinks with ambiguous types

This commit is contained in:
Tamas Vajk
2023-11-21 10:04:08 +01:00
parent 7263d4d650
commit f0e20fa69e
4 changed files with 44 additions and 0 deletions

View File

@@ -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 |

View File

@@ -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() }

View File

@@ -0,0 +1 @@
semmle-extractor-options: --standalone

View File

@@ -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");
}
}