File tree Expand file tree Collapse file tree 5 files changed +49
-2
lines changed
lib/semmle/code/csharp/security/dataflow/flowsinks
test/library-tests/standalone/externalLocationSink Expand file tree Collapse file tree 5 files changed +49
-2
lines changed Original file line number Diff line number Diff line change @@ -27,8 +27,9 @@ private class ExternalModelSink extends ExternalLocationSink {
2727 */
2828class LogMessageSink extends ExternalLocationSink {
2929 LogMessageSink ( ) {
30- this .getExpr ( ) = any ( LoggerType i ) .getAMethod ( ) .getACall ( ) .getAnArgument ( )
31- or
30+ this .getExpr ( ) = any ( LoggerType i ) .getAMethod ( ) .getACall ( ) .getAnArgument ( ) or
31+ this .getExpr ( ) =
32+ any ( MethodCall call | call .getQualifier ( ) .getType ( ) instanceof LoggerType ) .getAnArgument ( ) or
3233 this .getExpr ( ) =
3334 any ( ExtensionMethodCall call |
3435 call .getTarget ( ) .( ExtensionMethod ) .getExtendedType ( ) instanceof LoggerType
Original file line number Diff line number Diff line change 1+ #select
2+ | standalone.cs:20:20:20:20 | access to parameter s | standalone.cs:20:20:20:20 | access to parameter s |
3+ | standalone.cs:25:28:25:32 | "abc" | standalone.cs:25:28:25:32 | "abc" |
4+ compilationErrors
5+ | standalone.cs:16:12:16:18 | CS0104: 'ILogger' is an ambiguous reference between 'A.ILogger' and 'B.ILogger' |
6+ methodCalls
7+ | standalone.cs:20:9:20:21 | call to method |
8+ | standalone.cs:25:9:25:33 | call to method |
Original file line number Diff line number Diff line change 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 number Diff line number Diff line change 1+ semmle-extractor-options: --standalone
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments