mirror of
https://github.com/github/codeql.git
synced 2026-04-26 01:05:15 +02:00
C#: Implement missingArgumentCallExclude and multipleArgumentCallExclude
This commit is contained in:
@@ -72,6 +72,44 @@ private module Input implements InputSig<CsharpDataFlow> {
|
||||
}
|
||||
|
||||
predicate reverseReadExclude(Node n) { n.asExpr() = any(AwaitExpr ae).getExpr() }
|
||||
|
||||
predicate missingArgumentCallExclude(ArgumentNode arg) {
|
||||
// TODO: Remove once object initializers are modeled properly
|
||||
arg.(Private::PostUpdateNodes::ObjectInitializerNode).getInitializer() instanceof
|
||||
ObjectInitializer
|
||||
or
|
||||
// TODO: Remove once underlying issue is fixed
|
||||
exists(QualifiableExpr qe |
|
||||
qe.isConditional() and
|
||||
qe.getQualifier() = arg.asExpr()
|
||||
)
|
||||
}
|
||||
|
||||
predicate multipleArgumentCallExclude(ArgumentNode arg, DataFlowCall call) {
|
||||
isArgumentNode(arg, call, _) and
|
||||
(
|
||||
// TODO: Remove once object initializers are modeled properly
|
||||
arg =
|
||||
any(Private::PostUpdateNodes::ObjectInitializerNode init |
|
||||
init.argumentOf(call, _) and
|
||||
init.getInitializer().getNumberOfChildren() > 1
|
||||
)
|
||||
or
|
||||
exists(ControlFlow::Nodes::ElementNode cfn, ControlFlow::Nodes::Split split |
|
||||
exists(arg.asExprAtNode(cfn))
|
||||
|
|
||||
split = cfn.getASplit() and
|
||||
not split = call.getControlFlowNode().getASplit()
|
||||
or
|
||||
split = call.getControlFlowNode().getASplit() and
|
||||
not split = cfn.getASplit()
|
||||
)
|
||||
or
|
||||
call instanceof TransitiveCapturedDataFlowCall
|
||||
or
|
||||
call.(NonDelegateDataFlowCall).getDispatchCall().isReflection()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
import MakeConsistency<CsharpDataFlow, CsharpTaintTracking, Input>
|
||||
|
||||
@@ -2032,7 +2032,7 @@ abstract class PostUpdateNode extends Node {
|
||||
abstract Node getPreUpdateNode();
|
||||
}
|
||||
|
||||
private module PostUpdateNodes {
|
||||
module PostUpdateNodes {
|
||||
class ObjectCreationNode extends PostUpdateNode, ExprNode, TExprNode {
|
||||
private ObjectCreation oc;
|
||||
|
||||
|
||||
@@ -50,6 +50,9 @@ class DispatchCall extends Internal::TDispatchCall {
|
||||
RuntimeCallable getADynamicTargetInCallContext(DispatchCall ctx) {
|
||||
result = Internal::getADynamicTargetInCallContext(this, ctx)
|
||||
}
|
||||
|
||||
/** Holds if this call uses reflection. */
|
||||
predicate isReflection() { this instanceof Internal::TDispatchReflectionCall }
|
||||
}
|
||||
|
||||
/** Internal implementation details. */
|
||||
|
||||
Reference in New Issue
Block a user