Skip to content

Commit 45bb4a0

Browse files
committed
python: remove TaintStepFromSummary
as it should be covered by `SummarizedCallableFromModel` Also move things around, to look more like the Ruby code.
1 parent bcfce56 commit 45bb4a0

File tree

2 files changed

+27
-45
lines changed

2 files changed

+27
-45
lines changed

python/ql/lib/semmle/python/dataflow/new/FlowSummary.qll

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
private import python
44
private import semmle.python.dataflow.new.DataFlow
5-
private import semmle.python.frameworks.data.ModelsAsData
65
private import semmle.python.ApiGraphs
76
private import internal.FlowSummaryImpl as Impl
87
private import internal.DataFlowUtil
@@ -11,6 +10,7 @@ private import internal.DataFlowPrivate
1110
// import all instances below
1211
private module Summaries {
1312
private import semmle.python.Frameworks
13+
private import semmle.python.frameworks.data.ModelsAsData
1414
}
1515

1616
deprecated class SummaryComponent = Impl::Private::SummaryComponent;
@@ -36,32 +36,3 @@ abstract class SummarizedCallable extends LibraryCallable, Impl::Public::Summari
3636
}
3737

3838
deprecated class RequiredSummaryComponentStack = Impl::Private::RequiredSummaryComponentStack;
39-
40-
private class SummarizedCallableFromModel extends SummarizedCallable {
41-
string type;
42-
string path;
43-
44-
SummarizedCallableFromModel() {
45-
ModelOutput::relevantSummaryModel(type, path, _, _, _) and
46-
this = type + ";" + path
47-
}
48-
49-
override CallCfgNode getACall() { ModelOutput::resolvedSummaryBase(type, path, result) }
50-
51-
override ArgumentNode getACallback() {
52-
exists(API::Node base |
53-
ModelOutput::resolvedSummaryRefBase(type, path, base) and
54-
result = base.getAValueReachableFromSource()
55-
)
56-
}
57-
58-
override predicate propagatesFlow(string input, string output, boolean preservesValue) {
59-
exists(string kind | ModelOutput::relevantSummaryModel(type, path, input, output, kind) |
60-
kind = "value" and
61-
preservesValue = true
62-
or
63-
kind = "taint" and
64-
preservesValue = false
65-
)
66-
}
67-
}

python/ql/lib/semmle/python/frameworks/data/ModelsAsData.qll

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Shared::ModelOutput as ModelOutput
1717
private import semmle.python.dataflow.new.RemoteFlowSources
1818
private import semmle.python.dataflow.new.DataFlow
1919
private import semmle.python.ApiGraphs
20-
private import semmle.python.dataflow.new.TaintTracking
20+
private import semmle.python.dataflow.new.FlowSummary
2121

2222
/**
2323
* A remote flow source originating from a CSV source row.
@@ -28,20 +28,31 @@ private class RemoteFlowSourceFromCsv extends RemoteFlowSource {
2828
override string getSourceType() { result = "Remote flow (from model)" }
2929
}
3030

31-
/**
32-
* Like `ModelOutput::summaryStep` but with API nodes mapped to data-flow nodes.
33-
*/
34-
private predicate summaryStepNodes(DataFlow::Node pred, DataFlow::Node succ, string kind) {
35-
exists(API::Node predNode, API::Node succNode |
36-
Specific::summaryStep(predNode, succNode, kind) and
37-
pred = predNode.asSink() and
38-
succ = succNode.asSource()
39-
)
40-
}
31+
private class SummarizedCallableFromModel extends SummarizedCallable {
32+
string type;
33+
string path;
34+
35+
SummarizedCallableFromModel() {
36+
ModelOutput::relevantSummaryModel(type, path, _, _, _) and
37+
this = type + ";" + path
38+
}
39+
40+
override DataFlow::CallCfgNode getACall() { ModelOutput::resolvedSummaryBase(type, path, result) }
41+
42+
override DataFlow::ArgumentNode getACallback() {
43+
exists(API::Node base |
44+
ModelOutput::resolvedSummaryRefBase(type, path, base) and
45+
result = base.getAValueReachableFromSource()
46+
)
47+
}
4148

42-
/** Taint steps induced by summary models of kind `taint`. */
43-
private class TaintStepFromSummary extends TaintTracking::AdditionalTaintStep {
44-
override predicate step(DataFlow::Node pred, DataFlow::Node succ) {
45-
summaryStepNodes(pred, succ, "taint")
49+
override predicate propagatesFlow(string input, string output, boolean preservesValue) {
50+
exists(string kind | ModelOutput::relevantSummaryModel(type, path, input, output, kind) |
51+
kind = "value" and
52+
preservesValue = true
53+
or
54+
kind = "taint" and
55+
preservesValue = false
56+
)
4657
}
4758
}

0 commit comments

Comments
 (0)