Skip to content

Commit 9ccc65d

Browse files
authored
Merge pull request #12935 from michaelnebel/neutralkindsdocs
Java: Update customizing library models for java documentation.
2 parents f2f9944 + 5bf552b commit 9ccc65d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The CodeQL library for Java exposes the following extensible predicates:
3535
- **sourceModel**\(package, type, subtypes, name, signature, ext, output, kind, provenance). This is used for **source** models.
3636
- **sinkModel**\(package, type, subtypes, name, signature, ext, input, kind, provenance). This is used for **sink** models.
3737
- **summaryModel**\(package, type, subtypes, name, signature, ext, input, output, kind, provenance). This is used for **summary** models.
38-
- **neutralModel**\(package, type, name, signature, provenance). This is used for **neutral** models, which only have minor impact on the data flow analysis.
38+
- **neutralModel**\(package, type, name, signature, kind, provenance). This is used for **neutral** models, which only have minor impact on the data flow analysis.
3939

4040
The extensible predicates are populated using data extensions specified in YAML files.
4141

@@ -236,7 +236,7 @@ That is, the first row models that there is value flow from the elements of the
236236

237237
Example: Add a **neutral** method
238238
----------------------------------
239-
In this example we will show how to model the **now** method as being neutral.
239+
In this example we will show how to model the **now** method as being neutral with respect to flow.
240240
A neutral model is used to define that there is no flow through a method.
241241
Note that the neutral model for the **now** method is already added to the CodeQL Java analysis.
242242

@@ -247,7 +247,7 @@ Note that the neutral model for the **now** method is already added to the CodeQ
247247
...
248248
}
249249
250-
We need to add a tuple to the **neutralModel**\(package, type, name, signature, provenance) extensible predicate. To do this, add the following to a data extension file:
250+
We need to add a tuple to the **neutralModel**\(package, type, name, signature, kind, provenance) extensible predicate. To do this, add the following to a data extension file:
251251

252252
.. code-block:: yaml
253253
@@ -256,17 +256,18 @@ We need to add a tuple to the **neutralModel**\(package, type, name, signature,
256256
pack: codeql/java-all
257257
extensible: neutralModel
258258
data:
259-
- ["java.time", "Instant", "now", "()", "manual"]
259+
- ["java.time", "Instant", "now", "()", "summary", "manual"]
260260
261261
262262
Since we are adding a neutral model, we need to add tuples to the **neutralModel** extensible predicate.
263-
The first five values identify the callable (in this case a method) to be modeled as a neutral and the fifth value is the provenance (origin) of the neutral.
263+
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.
264264

265265
- The first value **java.time** is the package name.
266266
- The second value **Instant** is the class (type) name.
267267
- The third value **now** is the method name.
268268
- The fourth value **()** is the method input type signature.
269-
- The fifth value **manual** is the provenance of the neutral.
269+
- The fifth value **summary** is the kind of the neutral.
270+
- The sixth value **manual** is the provenance of the neutral.
270271

271272
.. _reference-material:
272273

@@ -354,13 +355,14 @@ The following kinds are supported:
354355
- **taint**: This means the output is not necessarily equal to the input, but it was derived from the input in an unrestrictive way. An attacker who controls the input will have significant control over the output as well.
355356
- **value**: This means that the output equals the input or a copy of the input such that all of its properties are preserved.
356357

357-
neutralModel(package, type, name, signature, provenance)
358-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
358+
neutralModel(package, type, name, signature, kind, provenance)
359+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
359360

360361
This extensible predicate is not typically needed externally, but included here for completeness.
361362
It only has minor impact on the data flow analysis.
362363
Manual neutrals are considered high confidence dispatch call targets and can reduce the number of dispatch call targets during data flow analysis (a performance optimization).
363364

365+
- **kind**: Kind of the neutral. For neutrals the kind can be **summary**, **source**, or **sink** to indicate that the callable is neutral with respect to flow (no summary), source (is not a source) or sink (is not a sink).
364366
- **provenance**: Provenance (origin) of the flow through.
365367

366368
.. _access-paths:

0 commit comments

Comments
 (0)