You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 978cf12
Browse filesBrowse the repository at this point in the historyBrowse files
Each model of an element is defined using a data extension where each tuple constitutes a model.
33
-
A data extension file to extend the standard Java queries included with CodeQL is a YAML file with the form:
33
+
A data extension file to extend the standard Java queries included with CodeQL can be written using either JSON or YAML. The JSON format takes the following form:
34
+
35
+
.. code-block:: json
36
+
37
+
{
38
+
"extensions": [
39
+
{
40
+
"addsTo": {
41
+
"pack": "codeql/java-all",
42
+
"extensible": "<name of extensible predicate>"
43
+
},
44
+
"data": [
45
+
["tuple", 1],
46
+
["tuple", 2]
47
+
// ...
48
+
]
49
+
}
50
+
]
51
+
}
52
+
53
+
Files in the JSON format must use the ``.json`` file extension. Single-line (``//``) and multi-line (``/* ... */``) comments are supported as a non-standard JSON extension.
54
+
55
+
A YAML file has the following form:
34
56
35
57
.. code-block:: yaml
36
58
@@ -39,11 +61,11 @@ A data extension file to extend the standard Java queries included with CodeQL i
39
61
pack: codeql/java-all
40
62
extensible: <name of extensible predicate>
41
63
data:
42
-
- <tuple1>
43
-
- <tuple2>
64
+
- ["tuple", 1]
65
+
- ["tuple", 2]
44
66
- ...
45
67
46
-
Each YAML file may contain one or more top-level extensions.
68
+
Each data extension file may contain one or more top-level extensions.
47
69
48
70
- ``addsTo`` defines the CodeQL pack name and extensible predicate that the extension is injected into.
49
71
- ``data`` defines one or more rows of tuples that are injected as values into the extensible predicate. The number of columns and their types must match the definition of the extensible predicate.
@@ -74,9 +96,9 @@ Specifying types in Java and Kotlin models
74
96
75
97
**Nested and inner classes** are denoted by joining the enclosing type and the nested type with a dollar sign (``$``), for example ``Outer$Inner``. This applies both to the type column and to nested types in a signature. For example, the ``Level`` enum nested inside the ``Logger`` interface, nested inside the ``System`` class, is written as ``System$Logger$Level``:
@@ -109,20 +131,27 @@ This is the ``execute`` method in the ``Statement`` class, which is located in t
109
131
110
132
We need to add a tuple to the ``sinkModel(package, type, subtypes, name, signature, ext, input, kind, provenance)`` extensible predicate by updating a data extension file.
The first five values identify the callable (in this case a method) to be modeled as a sink.
122
151
123
152
- The first value ``java.sql`` is the package name.
124
153
- The second value ``Statement`` is the name of the class (type) that contains the method.
125
-
- The third value ``True`` is a flag that indicates whether or not the model also applies to all overrides of the method.
154
+
- The third value ``true`` is a flag that indicates whether or not the model also applies to all overrides of the method.
126
155
- The fourth value ``execute`` is the method name.
127
156
- The fifth value ``(String)`` is the method input type signature.
128
157
@@ -147,20 +176,27 @@ This is the ``getInputStream`` method in the ``Socket`` class, which is located
147
176
148
177
We need to add a tuple to the ``sourceModel(package, type, subtypes, name, signature, ext, output, kind, provenance)`` extensible predicate by updating a data extension file.
The first five values identify the callable (in this case a method) to be modeled as a source.
160
196
161
197
- The first value ``java.net`` is the package name.
162
198
- The second value ``Socket`` is the name of the class (type) that contains the source.
163
-
- The third value ``False`` is a flag that indicates whether or not the model also applies to all overrides of the method.
199
+
- The third value ``false`` is a flag that indicates whether or not the model also applies to all overrides of the method.
164
200
- The fourth value ``getInputStream`` is the method name.
165
201
- The fifth value ``()`` is the method input type signature.
166
202
@@ -185,15 +221,22 @@ This pattern covers many of the cases where we need to summarize flow through a
185
221
186
222
We need to add tuples to the ``summaryModel(package, type, subtypes, name, signature, ext, input, output, kind, provenance)`` extensible predicate by updating a data extension file:
Each tuple defines flow from one argument to the return value.
199
242
The first row defines flow from the qualifier (``s1`` in the example) to the return value (``t`` in the example) and the second row defines flow from the first argument (``s2`` in the example) to the return value (``t`` in the example).
@@ -203,7 +246,7 @@ These are the same for both of the rows above as we are adding two summaries for
203
246
204
247
- The first value ``java.lang`` is the package name.
205
248
- The second value ``String`` is the class (type) name.
206
-
- The third value ``False`` is a flag that indicates whether or not the model also applies to all overrides of the method.
249
+
- The third value ``false`` is a flag that indicates whether or not the model also applies to all overrides of the method.
207
250
- The fourth value ``concat`` is the method name.
208
251
- The fifth value ``(String)`` is the method input type signature.
209
252
@@ -229,23 +272,30 @@ Here we model flow through higher order methods and collection types.
229
272
230
273
We need to add tuples to the ``summaryModel(package, type, subtypes, name, signature, ext, input, output, kind, provenance)`` extensible predicate by updating a data extension file:
Each tuple defines part of the flow that comprises the total flow through the ``map`` method.
243
293
The first five values identify the callable (in this case a method) to be modeled as a summary.
244
294
These are the same for both of the rows above as we are adding two summaries for the same method.
245
295
246
296
- The first value ``java.util.stream`` is the package name.
247
297
- The second value ``Stream`` is the class (type) name.
248
-
- The third value ``True`` is a flag that indicates whether or not the model also applies to all overrides of the method.
298
+
- The third value ``true`` is a flag that indicates whether or not the model also applies to all overrides of the method.
249
299
- The fourth value ``map`` is the method name.
250
300
- The fifth value ``Function`` is the method input type signature.
251
301
@@ -286,20 +336,27 @@ This is the ``getName`` method in the ``File`` class, which is located in the ``
286
336
287
337
We need to add a tuple to the ``barrierModel(package, type, subtypes, name, signature, ext, output, kind, provenance)`` extensible predicate by updating a data extension file.
The first five values identify the callable (in this case a method) to be modeled as a barrier.
299
356
300
357
- The first value ``java.io`` is the package name.
301
358
- The second value ``File`` is the name of the class (type) that contains the method.
302
-
- The third value ``True`` is a flag that indicates whether or not the model also applies to all overrides of the method.
359
+
- The third value ``true`` is a flag that indicates whether or not the model also applies to all overrides of the method.
303
360
- The fourth value ``getName`` is the method name.
304
361
- The fifth value ``()`` is the method input type signature.
305
362
@@ -328,20 +385,27 @@ When the ``isAbsolute`` method returns ``false``, the URI is relative and theref
328
385
329
386
We need to add a tuple to the ``barrierGuardModel(package, type, subtypes, name, signature, ext, input, acceptingValue, kind, provenance)`` extensible predicate by updating a data extension file.
The first five values identify the callable (in this case a method) to be modeled as a barrier guard.
341
405
342
406
- The first value ``java.net`` is the package name.
343
407
- The second value ``URI`` is the name of the class (type) that contains the method.
344
-
- The third value ``True`` is a flag that indicates whether or not the model guard also applies to all overrides of the method.
408
+
- The third value ``true`` is a flag that indicates whether or not the model guard also applies to all overrides of the method.
345
409
- The fourth value ``isAbsolute`` is the method name.
346
410
- The fifth value ``()`` is the method input type signature.
347
411
@@ -367,14 +431,21 @@ A neutral model is used to define that there is no flow through a method.
367
431
368
432
We need to add a tuple to the ``neutralModel(package, type, name, signature, kind, provenance)`` extensible predicate by updating a data extension file.
The first four values identify the callable (in this case a method) to be modeled as a neutral, the fifth value is the kind, and the sixth value is the provenance (origin) of the neutral.
0 commit comments