Python: use "extracted" instead of "source"

The precedence for the use of "source" to denote elements of source code
is found in `EssaVariable::getSourceVariable` as well as in the Ruby
code base. But it clashes with the many uses of source to mean
"source of flow" found in the data flow library.
This commit is contained in:
Rasmus Lerchedahl Petersen
2022-09-20 13:26:04 +02:00
parent 9a7afa9d8d
commit 318e3290f2
4 changed files with 24 additions and 24 deletions

View File

@@ -443,7 +443,7 @@ newtype TDataFlowCall =
}
/** A call found in the program source (as opposed to a synthesised summary call). */
class TDataFlowSourceCall = TSpecialCall or TNormalCall;
class TExtractedDataFlowCall = TSpecialCall or TNormalCall;
/** A call that is taken into account by the global data flow computation. */
abstract class DataFlowCall extends TDataFlowCall {
@@ -483,7 +483,7 @@ abstract class DataFlowCall extends TDataFlowCall {
}
/** A call found in the program source (as opposed to a synthesised call). */
abstract class DataFlowSourceCall extends DataFlowCall, TDataFlowSourceCall {
abstract class ExtractedDataFlowCall extends DataFlowCall, TExtractedDataFlowCall {
final override Location getLocation() { result = this.getNode().getLocation() }
abstract override DataFlowCallable getCallable();
@@ -494,7 +494,7 @@ abstract class DataFlowSourceCall extends DataFlowCall, TDataFlowSourceCall {
}
/** A call associated with a `CallNode`. */
class NormalCall extends DataFlowSourceCall, TNormalCall {
class NormalCall extends ExtractedDataFlowCall, TNormalCall {
CallNode call;
NormalCall() { this = TNormalCall(call) }
@@ -589,7 +589,7 @@ class ClassCall extends NormalCall {
}
/** A call to a special method. */
class SpecialCall extends DataFlowSourceCall, TSpecialCall {
class SpecialCall extends ExtractedDataFlowCall, TSpecialCall {
SpecialMethodCallNode special;
SpecialCall() { this = TSpecialCall(special) }
@@ -763,7 +763,7 @@ private class SummaryPostUpdateNode extends SummaryNode, PostUpdateNode {
}
/** Gets a viable run-time target for the call `call`. */
DataFlowCallable viableCallable(DataFlowSourceCall call) {
DataFlowCallable viableCallable(ExtractedDataFlowCall call) {
result = call.getCallable()
or
// A call to a library callable with a flow summary
@@ -794,9 +794,9 @@ abstract class ReturnNode extends Node {
}
/** A data flow node that represents a value returned by a callable. */
class ReturnSourceNode extends ReturnNode, CfgNode {
class ExtractedReturnNode extends ReturnNode, CfgNode {
// See `TaintTrackingImplementation::returnFlowStep`
ReturnSourceNode() { node = any(Return ret).getValue().getAFlowNode() }
ExtractedReturnNode() { node = any(Return ret).getValue().getAFlowNode() }
override ReturnKind getKind() { any() }
}
@@ -814,7 +814,7 @@ private module OutNodes {
class ExprOutNode extends OutNode, ExprNode {
private DataFlowCall call;
ExprOutNode() { call.(DataFlowSourceCall).getNode() = this.getNode() }
ExprOutNode() { call.(ExtractedDataFlowCall).getNode() = this.getNode() }
override DataFlowCall getCall(ReturnKind kind) {
result = call and

View File

@@ -294,11 +294,11 @@ class ParameterNode extends Node, TParameterNode instanceof ParameterNodeImpl {
}
/** A parameter node found in the source code (not in a summary). */
class SourceParameterNode extends ParameterNodeImpl, CfgNode {
class ExtractedParameterNode extends ParameterNodeImpl, CfgNode {
//, LocalSourceNode {
ParameterDefinition def;
SourceParameterNode() {
ExtractedParameterNode() {
node = def.getDefiningNode() and
// Disregard parameters that we cannot resolve
// TODO: Make this unnecessary
@@ -313,10 +313,10 @@ class SourceParameterNode extends ParameterNodeImpl, CfgNode {
override Parameter getParameter() { result = def.getParameter() }
}
class LocalSourceParameterNode extends SourceParameterNode, LocalSourceNode { }
class LocalSourceParameterNode extends ExtractedParameterNode, LocalSourceNode { }
/** Gets a node corresponding to parameter `p`. */
SourceParameterNode parameterNode(Parameter p) { result.getParameter() = p }
ExtractedParameterNode parameterNode(Parameter p) { result.getParameter() = p }
/** A data flow node that represents a call argument. */
abstract class ArgumentNode extends Node {
@@ -324,18 +324,18 @@ abstract class ArgumentNode extends Node {
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, _) }
final ExtractedDataFlowCall getCall() { this.argumentOf(result, _) }
}
/** A data flow node that represents a call argument found in the source code. */
class ArgumentSourceNode extends ArgumentNode {
ArgumentSourceNode() { this = any(DataFlowSourceCall c).getArg(_) }
class ExtractedArgumentNode extends ArgumentNode {
ExtractedArgumentNode() { this = any(ExtractedDataFlowCall c).getArg(_) }
final override predicate argumentOf(DataFlowCall call, ArgumentPosition pos) {
this.sourceArgumentOf(call, pos)
this.extractedArgumentOf(call, pos)
}
predicate sourceArgumentOf(DataFlowSourceCall call, ArgumentPosition pos) {
predicate extractedArgumentOf(ExtractedDataFlowCall call, ArgumentPosition pos) {
this = call.getArg(pos)
}
}

View File

@@ -16,12 +16,12 @@
* global data flwo graph is connected up via `getViableCallable`.
* - Non-extracted calls, `SummaryCall`. These are synthesised by the flow summary framework.
*
* The first two can be referred to as `DataFlowSourceCall`. In fact, `LibraryCall` is a subclass of `NormalCall`, where
* `getCallable` is set to `none()`. The member predicate `DataFlowSourceCall::getCallable` is _not_ the mechanism for
* The first two can be referred to as `ExtractedDataFlowCall`. In fact, `LibraryCall` is a subclass of `NormalCall`, where
* `getCallable` is set to `none()`. The member predicate `ExtractedDataFlowCall::getCallable` is _not_ the mechanism for
* call resolution in global data flow. That mechanism is `getViableCallable`.
* Resolving a call to a non-extracted callable goes via `LibraryCallable::getACall`, which may involve type tracking.
* To avoid that type tracking becomes mutualy recursive with data flow, type tracking must use a call graph not including summaries.
* Type tracking sees the callgraph given by `DataFlowSourceCall::getACallable`.
* Type tracking sees the callgraph given by `ExtractedDataFlowCall::getACallable`.
*
* We do not support summaries of special methods via the special methods framework,
* the summary would have to identify the call.

View File

@@ -35,10 +35,10 @@ string getPossibleContentName() {
*/
pragma[nomagic]
private DataFlowPrivate::DataFlowCallable getCallableForArgument(
DataFlowPublic::ArgumentSourceNode nodeFrom, int i
DataFlowPublic::ExtractedArgumentNode nodeFrom, int i
) {
exists(DataFlowPrivate::DataFlowSourceCall call |
nodeFrom.sourceArgumentOf(call, i) and
exists(DataFlowPrivate::ExtractedDataFlowCall call |
nodeFrom.extractedArgumentOf(call, i) and
result = call.getCallable()
)
}
@@ -60,7 +60,7 @@ predicate callStep(DataFlowPublic::ArgumentNode nodeFrom, DataFlowPrivate::Param
/** Holds if `nodeFrom` steps to `nodeTo` by being returned from a call. */
predicate returnStep(DataFlowPrivate::ReturnNode nodeFrom, Node nodeTo) {
exists(DataFlowPrivate::DataFlowSourceCall call |
exists(DataFlowPrivate::ExtractedDataFlowCall call |
nodeFrom.getEnclosingCallable() = call.getCallable() and
nodeTo.(DataFlowPublic::CfgNode).getNode() = call.getNode()
)