Skip to content

Commit b61f515

Browse files
committed
Jave: Make support for query specific models.
1 parent 8054309 commit b61f515

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Define the extensible prediactes related to experimental queries
2+
# to at least be empty.
3+
extensions:
4+
- addsTo:
5+
pack: codeql/java-all
6+
extensible: extExperimentalSourceModel
7+
data: []
8+
- addsTo:
9+
pack: codeql/java-all
10+
extensible: extExperimentalSinkModel
11+
data: []
12+
- addsTo:
13+
pack: codeql/java-all
14+
extensible: extExperimentalSummaryModel
15+
data: []

java/ql/lib/qlpack.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ dependencies:
1010
dataExtensions:
1111
- ext/*.model.yml
1212
- ext/generated/*.model.yml
13+
- ext/experimental/*.model.yml

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

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,77 @@ private predicate negativeSummaryModelInternal(string row) {
194194
any(NegativeSummaryModelCsvInternal s).row(row)
195195
}
196196

197+
/**
198+
* Holds if an experimental source model exists for the given parameters.
199+
* This is only for experimental queries.
200+
*/
201+
extensible predicate extExperimentalSourceModel(
202+
string package, string type, boolean subtypes, string name, string signature, string ext,
203+
string output, string kind, string provenance, string filter
204+
);
205+
206+
/**
207+
* Holds if an experimental sink model exists for the given parameters.
208+
* This is only for experimental queries.
209+
*/
210+
extensible predicate extExperimentalSinkModel(
211+
string package, string type, boolean subtypes, string name, string signature, string ext,
212+
string input, string kind, string provenance, string filter
213+
);
214+
215+
/**
216+
* Holds if an experimental summary model exists for the given parameters.
217+
* This is only for experimental queries.
218+
*/
219+
extensible predicate extExperimentalSummaryModel(
220+
string package, string type, boolean subtypes, string name, string signature, string ext,
221+
string input, string output, string kind, string provenance, string filter
222+
);
223+
224+
/**
225+
* A class for activating additional model rows.
226+
*
227+
* Extend this class to include experimental model rows with `this` name
228+
* in data flow analysis.
229+
*/
230+
abstract class ActiveExperimentalModels extends string {
231+
bindingset[this]
232+
ActiveExperimentalModels() { any() }
233+
234+
/**
235+
* Holds if an experimental source model exists for the given parameters.
236+
*/
237+
predicate sourceModel(
238+
string package, string type, boolean subtypes, string name, string signature, string ext,
239+
string output, string kind, string provenance
240+
) {
241+
extExperimentalSourceModel(package, type, subtypes, name, signature, ext, output, kind,
242+
provenance, this)
243+
}
244+
245+
/**
246+
* Holds if an experimental sink model exists for the given parameters.
247+
*/
248+
predicate sinkModel(
249+
string package, string type, boolean subtypes, string name, string signature, string ext,
250+
string output, string kind, string provenance
251+
) {
252+
extExperimentalSinkModel(package, type, subtypes, name, signature, ext, output, kind,
253+
provenance, this)
254+
}
255+
256+
/**
257+
* Holds if an experimental summary model exists for the given parameters.
258+
*/
259+
predicate summaryModel(
260+
string package, string type, boolean subtypes, string name, string signature, string ext,
261+
string input, string output, string kind, string provenance
262+
) {
263+
extExperimentalSummaryModel(package, type, subtypes, name, signature, ext, input, output, kind,
264+
provenance, this)
265+
}
266+
}
267+
197268
/**
198269
* Holds if a source model exists for the given parameters.
199270
*/
@@ -222,6 +293,9 @@ predicate sourceModel(
222293
)
223294
or
224295
extSourceModel(package, type, subtypes, name, signature, ext, output, kind, provenance)
296+
or
297+
any(ActiveExperimentalModels q)
298+
.sourceModel(package, type, subtypes, name, signature, ext, output, kind, provenance)
225299
}
226300

227301
/** Holds if a sink model exists for the given parameters. */
@@ -250,6 +324,9 @@ predicate sinkModel(
250324
)
251325
or
252326
extSinkModel(package, type, subtypes, name, signature, ext, input, kind, provenance)
327+
or
328+
any(ActiveExperimentalModels q)
329+
.sinkModel(package, type, subtypes, name, signature, ext, input, kind, provenance)
253330
}
254331

255332
/** Holds if a summary model exists for the given parameters. */
@@ -279,6 +356,9 @@ predicate summaryModel(
279356
)
280357
or
281358
extSummaryModel(package, type, subtypes, name, signature, ext, input, output, kind, provenance)
359+
or
360+
any(ActiveExperimentalModels q)
361+
.summaryModel(package, type, subtypes, name, signature, ext, input, output, kind, provenance)
282362
}
283363

284364
/** Holds if a summary model exists indicating there is no flow for the given parameters. */

0 commit comments

Comments
 (0)