Skip to content

Commit 424d909

Browse files
committed
C#: Add more Map like method delegate parameter as flow sources.
1 parent d2c5266 commit 424d909

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

csharp/ql/lib/semmle/code/csharp/frameworks/microsoft/AspNetCore.qll

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,27 @@ class MicrosoftAspNetCoreBuilderEndpointRouteBuilderExtensions extends Class {
366366
this.hasQualifiedName("Microsoft.AspNetCore.Builder", "EndpointRouteBuilderExtensions")
367367
}
368368

369-
/** Gets the `UseMap` extension method. */
369+
/** Gets the `Map` extension method. */
370+
Method getMapMethod() { result = this.getAMethod("Map") }
371+
372+
/** Gets the `MapGet` extension method. */
370373
Method getMapGetMethod() { result = this.getAMethod("MapGet") }
374+
375+
/** Gets the `MapPost` extension method. */
376+
Method getMapPostMethod() { result = this.getAMethod("MapPost") }
377+
378+
/** Gets the `MapPut` extension method. */
379+
Method getMapPutMethod() { result = this.getAMethod("MapPut") }
380+
381+
/** Gets the `MapDelete` extension method. */
382+
Method getMapDeleteMethod() { result = this.getAMethod("MapDelete") }
383+
384+
/** Get a `Map` like extenion methods. */
385+
Method getAMapMethod() {
386+
result =
387+
[
388+
this.getMapMethod(), this.getMapGetMethod(), this.getMapPostMethod(),
389+
this.getMapPutMethod(), this.getMapDeleteMethod()
390+
]
391+
}
371392
}

csharp/ql/lib/semmle/code/csharp/security/dataflow/flowsources/Remote.qll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ abstract class AspNetCoreRemoteFlowSource extends RemoteFlowSource { }
173173

174174
private predicate reachesMapGetArg(DataFlow::Node n) {
175175
exists(MethodCall mc |
176-
mc.getTarget() =
177-
any(MicrosoftAspNetCoreBuilderEndpointRouteBuilderExtensions c).getMapGetMethod() and
176+
mc.getTarget() = any(MicrosoftAspNetCoreBuilderEndpointRouteBuilderExtensions c).getAMapMethod() and
178177
n.asExpr() = mc.getArgument(2)
179178
)
180179
or

0 commit comments

Comments
 (0)