Skip to content

Commit 0915db4

Browse files
committed
C++/C#/Go: Use shared interpretModelForTest.
1 parent f0e7f1a commit 0915db4

File tree

3 files changed

+18
-122
lines changed

3 files changed

+18
-122
lines changed

cpp/ql/lib/semmle/code/cpp/dataflow/ExternalFlow.qll

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,14 @@ private import internal.FlowSummaryImpl
101101
private import internal.FlowSummaryImpl::Public
102102
private import internal.FlowSummaryImpl::Private
103103
private import internal.FlowSummaryImpl::Private::External
104-
private import internal.ExternalFlowExtensions as Extensions
104+
private import internal.ExternalFlowExtensions
105105
private import codeql.mad.ModelValidation as SharedModelVal
106106
private import codeql.util.Unit
107+
private import codeql.mad.static.MaD as SharedMaD
108+
109+
private module MaD = SharedMaD::ModelsAsData<Extensions>;
110+
111+
import MaD
107112

108113
/**
109114
* A unit class for adding additional source model rows.
@@ -230,49 +235,6 @@ private predicate summaryModel0(
230235
)
231236
}
232237

233-
/**
234-
* Holds if the given extension tuple `madId` should pretty-print as `model`.
235-
*
236-
* This predicate should only be used in tests.
237-
*/
238-
predicate interpretModelForTest(QlBuiltins::ExtensionId madId, string model) {
239-
exists(
240-
string namespace, string type, boolean subtypes, string name, string signature, string ext,
241-
string output, string kind, string provenance
242-
|
243-
Extensions::sourceModel(namespace, type, subtypes, name, signature, ext, output, kind,
244-
provenance, madId)
245-
|
246-
model =
247-
"Source: " + namespace + "; " + type + "; " + subtypes + "; " + name + "; " + signature + "; "
248-
+ ext + "; " + output + "; " + kind + "; " + provenance
249-
)
250-
or
251-
exists(
252-
string namespace, string type, boolean subtypes, string name, string signature, string ext,
253-
string input, string kind, string provenance
254-
|
255-
Extensions::sinkModel(namespace, type, subtypes, name, signature, ext, input, kind, provenance,
256-
madId)
257-
|
258-
model =
259-
"Sink: " + namespace + "; " + type + "; " + subtypes + "; " + name + "; " + signature + "; " +
260-
ext + "; " + input + "; " + kind + "; " + provenance
261-
)
262-
or
263-
exists(
264-
string namespace, string type, boolean subtypes, string name, string signature, string ext,
265-
string input, string output, string kind, string provenance
266-
|
267-
Extensions::summaryModel(namespace, type, subtypes, name, signature, ext, input, output, kind,
268-
provenance, madId)
269-
|
270-
model =
271-
"Summary: " + namespace + "; " + type + "; " + subtypes + "; " + name + "; " + signature +
272-
"; " + ext + "; " + input + "; " + output + "; " + kind + "; " + provenance
273-
)
274-
}
275-
276238
/**
277239
* Holds if `input` is `input0`, but with all occurrences of `@` replaced
278240
* by `n` repetitions of `*` (and similarly for `output` and `output0`).

csharp/ql/lib/semmle/code/csharp/dataflow/internal/ExternalFlow.qll

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -101,44 +101,11 @@ private import semmle.code.csharp.dispatch.OverridableCallable
101101
private import semmle.code.csharp.frameworks.System
102102
private import codeql.dataflow.internal.AccessPathSyntax as AccessPathSyntax
103103
private import codeql.mad.ModelValidation as SharedModelVal
104+
private import codeql.mad.static.MaD as SharedMaD
104105

105-
/**
106-
* Holds if the given extension tuple `madId` should pretty-print as `model`.
107-
*
108-
* This predicate should only be used in tests.
109-
*/
110-
predicate interpretModelForTest(QlBuiltins::ExtensionId madId, string model) {
111-
exists(
112-
string namespace, string type, boolean subtypes, string name, string signature, string ext,
113-
string output, string kind, string provenance
114-
|
115-
sourceModel(namespace, type, subtypes, name, signature, ext, output, kind, provenance, madId) and
116-
model =
117-
"Source: " + namespace + "; " + type + "; " + subtypes + "; " + name + "; " + signature + "; "
118-
+ ext + "; " + output + "; " + kind + "; " + provenance
119-
)
120-
or
121-
exists(
122-
string namespace, string type, boolean subtypes, string name, string signature, string ext,
123-
string input, string kind, string provenance
124-
|
125-
sinkModel(namespace, type, subtypes, name, signature, ext, input, kind, provenance, madId) and
126-
model =
127-
"Sink: " + namespace + "; " + type + "; " + subtypes + "; " + name + "; " + signature + "; " +
128-
ext + "; " + input + "; " + kind + "; " + provenance
129-
)
130-
or
131-
exists(
132-
string namespace, string type, boolean subtypes, string name, string signature, string ext,
133-
string input, string output, string kind, string provenance
134-
|
135-
summaryModel(namespace, type, subtypes, name, signature, ext, input, output, kind, provenance,
136-
madId) and
137-
model =
138-
"Summary: " + namespace + "; " + type + "; " + subtypes + "; " + name + "; " + signature +
139-
"; " + ext + "; " + input + "; " + output + "; " + kind + "; " + provenance
140-
)
141-
}
106+
private module MaD = SharedMaD::ModelsAsData<Extensions>;
107+
108+
import MaD
142109

143110
private predicate relevantNamespace(string namespace) {
144111
sourceModel(namespace, _, _, _, _, _, _, _, _, _) or

go/ql/lib/semmle/go/dataflow/ExternalFlow.qll

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,21 @@
8686
*/
8787

8888
private import go
89-
import internal.ExternalFlowExtensions as FlowExtensions
89+
private import internal.ExternalFlowExtensions
9090
private import FlowSummary as FlowSummary
9191
private import internal.DataFlowPrivate
9292
private import internal.FlowSummaryImpl
9393
private import internal.FlowSummaryImpl::Public as Public
9494
private import internal.FlowSummaryImpl::Private
9595
private import internal.FlowSummaryImpl::Private::External
9696
private import codeql.mad.ModelValidation as SharedModelVal
97+
private import codeql.mad.static.MaD as SharedMaD
98+
99+
private module MaD = SharedMaD::ModelsAsData<Extensions>;
100+
101+
import MaD
102+
103+
module FlowExtensions = Extensions;
97104

98105
/** Gets the prefix for a group of packages. */
99106
private string groupPrefix() { result = "group:" }
@@ -178,46 +185,6 @@ predicate neutralModel(
178185
)
179186
}
180187

181-
/**
182-
* Holds if the given extension tuple `madId` should pretty-print as `model`.
183-
*
184-
* This predicate should only be used in tests.
185-
*/
186-
predicate interpretModelForTest(QlBuiltins::ExtensionId madId, string model) {
187-
exists(
188-
string package, string type, boolean subtypes, string name, string signature, string ext,
189-
string output, string kind, string provenance
190-
|
191-
FlowExtensions::sourceModel(package, type, subtypes, name, signature, ext, output, kind,
192-
provenance, madId) and
193-
model =
194-
"Source: " + package + "; " + type + "; " + subtypes + "; " + name + "; " + signature + "; " +
195-
ext + "; " + output + "; " + kind + "; " + provenance
196-
)
197-
or
198-
exists(
199-
string package, string type, boolean subtypes, string name, string signature, string ext,
200-
string input, string kind, string provenance
201-
|
202-
FlowExtensions::sinkModel(package, type, subtypes, name, signature, ext, input, kind,
203-
provenance, madId) and
204-
model =
205-
"Sink: " + package + "; " + type + "; " + subtypes + "; " + name + "; " + signature + "; " +
206-
ext + "; " + input + "; " + kind + "; " + provenance
207-
)
208-
or
209-
exists(
210-
string package, string type, boolean subtypes, string name, string signature, string ext,
211-
string input, string output, string kind, string provenance
212-
|
213-
FlowExtensions::summaryModel(package, type, subtypes, name, signature, ext, input, output, kind,
214-
provenance, madId) and
215-
model =
216-
"Summary: " + package + "; " + type + "; " + subtypes + "; " + name + "; " + signature + "; " +
217-
ext + "; " + input + "; " + output + "; " + kind + "; " + provenance
218-
)
219-
}
220-
221188
bindingset[p]
222189
private string cleanPackage(string p) {
223190
exists(string noPrefix |

0 commit comments

Comments
 (0)