mirror of
https://github.com/github/codeql.git
synced 2026-04-19 05:54:00 +02:00
Merge pull request #18269 from hvitved/csharp/dataflow-reflection-call
C#: Remove false-positive reflection calls in dataflow
This commit is contained in:
@@ -424,7 +424,11 @@ class NonDelegateDataFlowCall extends DataFlowCall, TNonDelegateCall {
|
||||
Callable getATarget(boolean static) {
|
||||
result = dc.getADynamicTarget().getUnboundDeclaration() and static = false
|
||||
or
|
||||
result = dc.getAStaticTarget().getUnboundDeclaration() and static = true
|
||||
result = dc.getAStaticTarget().getUnboundDeclaration() and
|
||||
static = true and
|
||||
// In reflection calls, _all_ methods with matching names and arities are considered
|
||||
// static targets, so we need to exclude them
|
||||
not dc.isReflection()
|
||||
}
|
||||
|
||||
override ControlFlow::Nodes::ElementNode getControlFlowNode() { result = cfn }
|
||||
|
||||
@@ -52,7 +52,21 @@ class DispatchCall extends Internal::TDispatchCall {
|
||||
}
|
||||
|
||||
/** Holds if this call uses reflection. */
|
||||
predicate isReflection() { this instanceof Internal::TDispatchReflectionCall }
|
||||
predicate isReflection() {
|
||||
this instanceof Internal::TDispatchReflectionCall
|
||||
or
|
||||
this instanceof Internal::TDispatchDynamicElementAccess
|
||||
or
|
||||
this instanceof Internal::TDispatchDynamicMemberAccess
|
||||
or
|
||||
this instanceof Internal::TDispatchDynamicMethodCall
|
||||
or
|
||||
this instanceof Internal::TDispatchDynamicOperatorCall
|
||||
or
|
||||
this instanceof Internal::TDispatchDynamicEventAccess
|
||||
or
|
||||
this instanceof Internal::TDispatchDynamicObjectCreation
|
||||
}
|
||||
}
|
||||
|
||||
/** Internal implementation details. */
|
||||
|
||||
Reference in New Issue
Block a user