Skip to content

Commit 318e329

Browse files
committed
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.
1 parent 9a7afa9 commit 318e329

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowDispatchPointsTo.qll

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ newtype TDataFlowCall =
443443
}
444444

445445
/** A call found in the program source (as opposed to a synthesised summary call). */
446-
class TDataFlowSourceCall = TSpecialCall or TNormalCall;
446+
class TExtractedDataFlowCall = TSpecialCall or TNormalCall;
447447

448448
/** A call that is taken into account by the global data flow computation. */
449449
abstract class DataFlowCall extends TDataFlowCall {
@@ -483,7 +483,7 @@ abstract class DataFlowCall extends TDataFlowCall {
483483
}
484484

485485
/** A call found in the program source (as opposed to a synthesised call). */
486-
abstract class DataFlowSourceCall extends DataFlowCall, TDataFlowSourceCall {
486+
abstract class ExtractedDataFlowCall extends DataFlowCall, TExtractedDataFlowCall {
487487
final override Location getLocation() { result = this.getNode().getLocation() }
488488

489489
abstract override DataFlowCallable getCallable();
@@ -494,7 +494,7 @@ abstract class DataFlowSourceCall extends DataFlowCall, TDataFlowSourceCall {
494494
}
495495

496496
/** A call associated with a `CallNode`. */
497-
class NormalCall extends DataFlowSourceCall, TNormalCall {
497+
class NormalCall extends ExtractedDataFlowCall, TNormalCall {
498498
CallNode call;
499499

500500
NormalCall() { this = TNormalCall(call) }
@@ -589,7 +589,7 @@ class ClassCall extends NormalCall {
589589
}
590590

591591
/** A call to a special method. */
592-
class SpecialCall extends DataFlowSourceCall, TSpecialCall {
592+
class SpecialCall extends ExtractedDataFlowCall, TSpecialCall {
593593
SpecialMethodCallNode special;
594594

595595
SpecialCall() { this = TSpecialCall(special) }
@@ -763,7 +763,7 @@ private class SummaryPostUpdateNode extends SummaryNode, PostUpdateNode {
763763
}
764764

765765
/** Gets a viable run-time target for the call `call`. */
766-
DataFlowCallable viableCallable(DataFlowSourceCall call) {
766+
DataFlowCallable viableCallable(ExtractedDataFlowCall call) {
767767
result = call.getCallable()
768768
or
769769
// A call to a library callable with a flow summary
@@ -794,9 +794,9 @@ abstract class ReturnNode extends Node {
794794
}
795795

796796
/** A data flow node that represents a value returned by a callable. */
797-
class ReturnSourceNode extends ReturnNode, CfgNode {
797+
class ExtractedReturnNode extends ReturnNode, CfgNode {
798798
// See `TaintTrackingImplementation::returnFlowStep`
799-
ReturnSourceNode() { node = any(Return ret).getValue().getAFlowNode() }
799+
ExtractedReturnNode() { node = any(Return ret).getValue().getAFlowNode() }
800800

801801
override ReturnKind getKind() { any() }
802802
}
@@ -814,7 +814,7 @@ private module OutNodes {
814814
class ExprOutNode extends OutNode, ExprNode {
815815
private DataFlowCall call;
816816

817-
ExprOutNode() { call.(DataFlowSourceCall).getNode() = this.getNode() }
817+
ExprOutNode() { call.(ExtractedDataFlowCall).getNode() = this.getNode() }
818818

819819
override DataFlowCall getCall(ReturnKind kind) {
820820
result = call and

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPublic.qll

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,11 @@ class ParameterNode extends Node, TParameterNode instanceof ParameterNodeImpl {
294294
}
295295

296296
/** A parameter node found in the source code (not in a summary). */
297-
class SourceParameterNode extends ParameterNodeImpl, CfgNode {
297+
class ExtractedParameterNode extends ParameterNodeImpl, CfgNode {
298298
//, LocalSourceNode {
299299
ParameterDefinition def;
300300

301-
SourceParameterNode() {
301+
ExtractedParameterNode() {
302302
node = def.getDefiningNode() and
303303
// Disregard parameters that we cannot resolve
304304
// TODO: Make this unnecessary
@@ -313,29 +313,29 @@ class SourceParameterNode extends ParameterNodeImpl, CfgNode {
313313
override Parameter getParameter() { result = def.getParameter() }
314314
}
315315

316-
class LocalSourceParameterNode extends SourceParameterNode, LocalSourceNode { }
316+
class LocalSourceParameterNode extends ExtractedParameterNode, LocalSourceNode { }
317317

318318
/** Gets a node corresponding to parameter `p`. */
319-
SourceParameterNode parameterNode(Parameter p) { result.getParameter() = p }
319+
ExtractedParameterNode parameterNode(Parameter p) { result.getParameter() = p }
320320

321321
/** A data flow node that represents a call argument. */
322322
abstract class ArgumentNode extends Node {
323323
/** Holds if this argument occurs at the given position in the given call. */
324324
abstract predicate argumentOf(DataFlowCall call, ArgumentPosition pos);
325325

326326
/** Gets the call in which this node is an argument, if any. */
327-
final DataFlowSourceCall getCall() { this.argumentOf(result, _) }
327+
final ExtractedDataFlowCall getCall() { this.argumentOf(result, _) }
328328
}
329329

330330
/** A data flow node that represents a call argument found in the source code. */
331-
class ArgumentSourceNode extends ArgumentNode {
332-
ArgumentSourceNode() { this = any(DataFlowSourceCall c).getArg(_) }
331+
class ExtractedArgumentNode extends ArgumentNode {
332+
ExtractedArgumentNode() { this = any(ExtractedDataFlowCall c).getArg(_) }
333333

334334
final override predicate argumentOf(DataFlowCall call, ArgumentPosition pos) {
335-
this.sourceArgumentOf(call, pos)
335+
this.extractedArgumentOf(call, pos)
336336
}
337337

338-
predicate sourceArgumentOf(DataFlowSourceCall call, ArgumentPosition pos) {
338+
predicate extractedArgumentOf(ExtractedDataFlowCall call, ArgumentPosition pos) {
339339
this = call.getArg(pos)
340340
}
341341
}

python/ql/lib/semmle/python/dataflow/new/internal/FlowSummaryImplSpecific.qll

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

python/ql/lib/semmle/python/dataflow/new/internal/TypeTrackerSpecific.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ string getPossibleContentName() {
3535
*/
3636
pragma[nomagic]
3737
private DataFlowPrivate::DataFlowCallable getCallableForArgument(
38-
DataFlowPublic::ArgumentSourceNode nodeFrom, int i
38+
DataFlowPublic::ExtractedArgumentNode nodeFrom, int i
3939
) {
40-
exists(DataFlowPrivate::DataFlowSourceCall call |
41-
nodeFrom.sourceArgumentOf(call, i) and
40+
exists(DataFlowPrivate::ExtractedDataFlowCall call |
41+
nodeFrom.extractedArgumentOf(call, i) and
4242
result = call.getCallable()
4343
)
4444
}
@@ -60,7 +60,7 @@ predicate callStep(DataFlowPublic::ArgumentNode nodeFrom, DataFlowPrivate::Param
6060

6161
/** Holds if `nodeFrom` steps to `nodeTo` by being returned from a call. */
6262
predicate returnStep(DataFlowPrivate::ReturnNode nodeFrom, Node nodeTo) {
63-
exists(DataFlowPrivate::DataFlowSourceCall call |
63+
exists(DataFlowPrivate::ExtractedDataFlowCall call |
6464
nodeFrom.getEnclosingCallable() = call.getCallable() and
6565
nodeTo.(DataFlowPublic::CfgNode).getNode() = call.getNode()
6666
)

0 commit comments

Comments
 (0)