python: make ArgumentNode publicly usable

- add `getCall`
This commit is contained in:
yoff
2022-06-23 08:48:55 +00:00
committed by GitHub
parent b22de69ab2
commit fe0c5d8ee5
5 changed files with 7 additions and 7 deletions

View File

@@ -322,6 +322,9 @@ SourceParameterNode parameterNode(Parameter p) { result.getParameter() = p }
abstract class ArgumentNode extends Node {
/** Holds if this argument occurs at the given position in the given call. */
abstract predicate argumentOf(DataFlowCall call, ArgumentPosition pos);
/** Gets the call in which this node is an argument, if any. */
final DataFlowSourceCall getCall() { this.argumentOf(result, _) }
}
/** A data flow node that represents a call argument. */
@@ -335,9 +338,6 @@ class ArgumentSourceNode extends ArgumentNode {
predicate sourceArgumentOf(DataFlowSourceCall call, ArgumentPosition pos) {
this = call.getArg(pos)
}
/** Gets the call in which this node is an argument. */
final DataFlowSourceCall getCall() { this.argumentOf(result, _) }
}
/**

View File

@@ -35,7 +35,7 @@ class MaximalFlowsConfig extends DataFlow::Configuration {
override predicate isSink(DataFlow::Node node) {
exists(node.getLocation().getFile().getRelativePath()) and
not any(CallNode c).getArg(_) = node.asCfgNode() and
not node instanceof DataFlow::ArgumentSourceNode and
not node instanceof DataFlow::ArgumentNode and
not node.asCfgNode().(NameNode).getId().matches("SINK%") and
not exists(DataFlow::Node succ | DataFlow::localFlowStep(node, succ))
}

View File

@@ -43,7 +43,7 @@ abstract class RoutingTest extends InlineExpectationsTest {
}
pragma[inline]
private string fromFunc(DataFlow::ArgumentSourceNode fromNode) {
private string fromFunc(DataFlow::ArgumentNode fromNode) {
result = fromNode.getCall().getNode().(CallNode).getFunction().getNode().(Name).getId()
}

View File

@@ -11,7 +11,7 @@ class CallGraphConfig extends DataFlow::Configuration {
override predicate isSource(DataFlow::Node node) {
node instanceof DataFlowPrivate::ReturnNode
or
node instanceof DataFlow::ArgumentSourceNode
node instanceof DataFlow::ArgumentNode
}
override predicate isSink(DataFlow::Node node) {

View File

@@ -11,7 +11,7 @@ class CallGraphConfig extends DataFlow::Configuration {
node instanceof DataFlowPrivate::ReturnNode
or
// These sources should allow for the non-standard call syntax
node instanceof DataFlow::ArgumentSourceNode
node instanceof DataFlow::ArgumentNode
}
override predicate isSink(DataFlow::Node node) {