Skip to content

Commit 5659b58

Browse files
committed
Java: Extend the description of models.
1 parent ce162ce commit 5659b58

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

docs/codeql/codeql-language-guides/customizing-library-models-for-java.rst

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,17 @@ Customizing Library Models for Java
99
.. include:: ../reusables/beta-note-customizing-library-models.rst
1010

1111
The Java analysis can be customized by adding library models (summaries, sinks and sources) in data extension files.
12+
A model is a definition of a behavior of a library element, such as a method, that is used to improve the data flow analysis precision by identifying more results.
13+
Most of the security related queries are *taint tracking* queries that tries to find paths from a *source* of untrusted input to a *sink* that represents a vulnerability.
14+
Furthermore, the taint tracking queries also need to know how data can flow through elements that are not included in the source code - these are named *summaries*.
1215

16+
That is
17+
18+
- **sources** are the starting points of a taint tracking data flow analysis.
19+
- **sinks** are the end points of a taint tracking data flow analysis.
20+
- **summaries** are models of elements that allows us to synthesize the elements flow behavior without having them in the source code. This is especially helpful when using a third party (or the standard) library.
21+
22+
The models are defined using data extensions where each tuple constitutes a model.
1323
A data extension file for Java is a YAML file in the form:
1424

1525
.. code-block:: yaml
@@ -23,14 +33,14 @@ A data extension file for Java is a YAML file in the form:
2333
- <tuple2>
2434
- ...
2535
26-
Data extensions contribute to extensible predicates defined CodeQL libraries. For more information on how to define data extensions and extensible predicates as well as how to wire them up, see the :ref:`data-extensions` documentation.
36+
Data extensions contribute to the extensible predicates defined in the CodeQL library. For more information on how to define data extensions and extensible predicates as well as how to wire them up, see the :ref:`data-extensions` documentation.
2737

28-
The CodeQL libraries for Java expose the following extensible predicates:
38+
The CodeQL library for Java expose the following extensible predicates:
2939

30-
- **sourceModel**\(package, type, subtypes, name, signature, ext, output, kind, provenance)
31-
- **sinkModel**\(package, type, subtypes, name, signature, ext, input, kind, provenance)
32-
- **summaryModel**\(package, type, subtypes, name, signature, ext, input, output, kind, provenance)
33-
- **neutralModel**\(package, type, name, signature, provenance)
40+
- **sourceModel**\(package, type, subtypes, name, signature, ext, output, kind, provenance). This is used for **source** models.
41+
- **sinkModel**\(package, type, subtypes, name, signature, ext, input, kind, provenance). This is used for **sink** models.
42+
- **summaryModel**\(package, type, subtypes, name, signature, ext, input, output, kind, provenance). This is used for **summary** models.
43+
- **neutralModel**\(package, type, name, signature, provenance). This is used for **neutral** models, which does not impact the data flow analysis, but it is included here for completeness.
3444

3545
The extensible predicates are populated using data extensions specified in YAML files.
3646

@@ -52,7 +62,7 @@ Please note that this sink is already added to the CodeQL Java analysis.
5262
stmt.execute(query); // The argument to this method is a SQL injection sink.
5363
}
5464
55-
This can be achieved by adding the following row to a data extension file:
65+
This means that we want to add a tuple to the **sinkModel**\(package, type, subtypes, name, signature, ext, input, kind, provenance) extensible predicate, which can be achieved by adding the following to a data extension file:
5666

5767
.. code-block:: yaml
5868
@@ -94,7 +104,7 @@ Please note that this source is already added to the CodeQL Java analysis.
94104
...
95105
}
96106
97-
This can be achieved by adding the following data extension.
107+
This means that we want to add a tuple to the **sourceModel**\(package, type, subtypes, name, signature, ext, output, kind, provenance) extensible predicate, which can be achieved by adding the following to a data extension file:
98108

99109
.. code-block:: yaml
100110
@@ -136,8 +146,7 @@ Please note that the flow through the **concat** method is already added to the
136146
...
137147
}
138148
139-
This can be achieved by adding the following data extension.
140-
These are widely known as summary models.
149+
This means that we want to add tuples to the **summaryModel**\(package, type, subtypes, name, signature, ext, input, output, kind, provenance) extensible predicate, which can be achieved by adding the following to a data extension file:
141150

142151
.. code-block:: yaml
143152
@@ -247,6 +256,8 @@ Please note that the neutral model for the **now** method is already added.
247256
...
248257
}
249258
259+
This means that we want to add a tuple to the **neutralModel**\(package, type, name, signature, provenance) extensible predicate, which can be achieved by adding the following to a data extension file:
260+
250261
.. code-block:: yaml
251262
252263
extensions:

0 commit comments

Comments
 (0)