Skip to content

Commit 53abdb3

Browse files
committed
Ruby: Move SummarizedCallableFromModel into ModelsAsData.qll
1 parent 60fe370 commit 53abdb3

File tree

2 files changed

+33
-32
lines changed

2 files changed

+33
-32
lines changed

ruby/ql/lib/codeql/ruby/dataflow/FlowSummary.qll

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
import codeql.ruby.AST
44
import codeql.ruby.DataFlow
5-
private import codeql.ruby.frameworks.data.ModelsAsData
6-
private import codeql.ruby.ApiGraphs
75
private import internal.FlowSummaryImpl as Impl
86
private import internal.DataFlowDispatch
97
private import internal.DataFlowPrivate
108

119
// import all instances below
1210
private module Summaries {
1311
private import codeql.ruby.Frameworks
12+
private import codeql.ruby.frameworks.data.ModelsAsData
1413
}
1514

1615
class SummaryComponent = Impl::Public::SummaryComponent;
@@ -144,33 +143,3 @@ abstract class SimpleSummarizedCallable extends SummarizedCallable {
144143
}
145144

146145
class RequiredSummaryComponentStack = Impl::Public::RequiredSummaryComponentStack;
147-
148-
private class SummarizedCallableFromModel extends SummarizedCallable {
149-
string package;
150-
string type;
151-
string path;
152-
153-
SummarizedCallableFromModel() {
154-
ModelOutput::relevantSummaryModel(package, type, path, _, _, _) and
155-
this = package + ";" + type + ";" + path
156-
}
157-
158-
override Call getACall() {
159-
exists(API::MethodAccessNode base |
160-
ModelOutput::resolvedSummaryBase(package, type, path, base) and
161-
result = base.getCallNode().asExpr().getExpr()
162-
)
163-
}
164-
165-
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
166-
exists(string kind |
167-
ModelOutput::relevantSummaryModel(package, type, path, input, output, kind)
168-
|
169-
kind = "value" and
170-
preservesValue = true
171-
or
172-
kind = "taint" and
173-
preservesValue = false
174-
)
175-
}
176-
}

ruby/ql/lib/codeql/ruby/frameworks/data/ModelsAsData.qll

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
*/
1616

1717
private import codeql.ruby.AST
18+
private import codeql.ruby.ApiGraphs
1819
private import internal.ApiGraphModels as Shared
1920
private import internal.ApiGraphModelsSpecific as Specific
2021
import Shared::ModelInput as ModelInput
2122
import Shared::ModelOutput as ModelOutput
2223
private import codeql.ruby.dataflow.RemoteFlowSources
24+
private import codeql.ruby.dataflow.FlowSummary
2325

2426
/**
2527
* A remote flow source originating from a CSV source row.
@@ -29,3 +31,33 @@ private class RemoteFlowSourceFromCsv extends RemoteFlowSource::Range {
2931

3032
override string getSourceType() { result = "Remote flow (from model)" }
3133
}
34+
35+
private class SummarizedCallableFromModel extends SummarizedCallable {
36+
string package;
37+
string type;
38+
string path;
39+
40+
SummarizedCallableFromModel() {
41+
ModelOutput::relevantSummaryModel(package, type, path, _, _, _) and
42+
this = package + ";" + type + ";" + path
43+
}
44+
45+
override Call getACall() {
46+
exists(API::MethodAccessNode base |
47+
ModelOutput::resolvedSummaryBase(package, type, path, base) and
48+
result = base.getCallNode().asExpr().getExpr()
49+
)
50+
}
51+
52+
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
53+
exists(string kind |
54+
ModelOutput::relevantSummaryModel(package, type, path, input, output, kind)
55+
|
56+
kind = "value" and
57+
preservesValue = true
58+
or
59+
kind = "taint" and
60+
preservesValue = false
61+
)
62+
}
63+
}

0 commit comments

Comments
 (0)