From 94e9848d61c7ddd6962eeea518c585d8df53981a Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Sat, 8 Jul 2023 18:56:37 +0200 Subject: [PATCH 1/2] Mention needed imports at top of "Analyzing data flow in Java" Currently the guide just starts using the classes from these libraries without having mentioned that you have to import the libraries first. --- .../analyzing-data-flow-in-java.rst | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/codeql/codeql-language-guides/analyzing-data-flow-in-java.rst b/docs/codeql/codeql-language-guides/analyzing-data-flow-in-java.rst index 2eccdf5e103..9e89b06bc8a 100644 --- a/docs/codeql/codeql-language-guides/analyzing-data-flow-in-java.rst +++ b/docs/codeql/codeql-language-guides/analyzing-data-flow-in-java.rst @@ -17,6 +17,18 @@ The following sections describe how to use the libraries for local data flow, gl For a more general introduction to modeling data flow, see ":ref:`About data flow analysis `." +For data flow you need the following import: + +.. code-block:: ql + + import semmle.code.java.dataflow.DataFlow + +For taint tracking you need this import: + +.. code-block:: ql + + import semmle.code.java.dataflow.TaintTracking + Local data flow --------------- @@ -368,4 +380,4 @@ Further reading .. include:: ../reusables/java-further-reading.rst -.. include:: ../reusables/codeql-ref-tools-further-reading.rst \ No newline at end of file +.. include:: ../reusables/codeql-ref-tools-further-reading.rst From 09fa2a7d50cf2b845aa31bc3bd5598933bf35183 Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Sat, 15 Jul 2023 16:59:46 +0200 Subject: [PATCH 2/2] Move imports to usage sections --- .../analyzing-data-flow-in-java.rst | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/docs/codeql/codeql-language-guides/analyzing-data-flow-in-java.rst b/docs/codeql/codeql-language-guides/analyzing-data-flow-in-java.rst index 9e89b06bc8a..68729f564c5 100644 --- a/docs/codeql/codeql-language-guides/analyzing-data-flow-in-java.rst +++ b/docs/codeql/codeql-language-guides/analyzing-data-flow-in-java.rst @@ -17,18 +17,6 @@ The following sections describe how to use the libraries for local data flow, gl For a more general introduction to modeling data flow, see ":ref:`About data flow analysis `." -For data flow you need the following import: - -.. code-block:: ql - - import semmle.code.java.dataflow.DataFlow - -For taint tracking you need this import: - -.. code-block:: ql - - import semmle.code.java.dataflow.TaintTracking - Local data flow --------------- @@ -37,7 +25,13 @@ Local data flow is data flow within a single method or callable. Local data flow Using local data flow ~~~~~~~~~~~~~~~~~~~~~ -The local data flow library is in the module ``DataFlow``, which defines the class ``Node`` denoting any element that data can flow through. ``Node``\ s are divided into expression nodes (``ExprNode``) and parameter nodes (``ParameterNode``). You can map between data flow nodes and expressions/parameters using the member predicates ``asExpr`` and ``asParameter``: +To use the data flow library you need the following import: + +.. code-block:: ql + + import semmle.code.java.dataflow.DataFlow + +The ``DataFlow`` module defines the class ``Node`` denoting any element that data can flow through. ``Node``\ s are divided into expression nodes (``ExprNode``) and parameter nodes (``ParameterNode``). You can map between data flow nodes and expressions/parameters using the member predicates ``asExpr`` and ``asParameter``: .. code-block:: ql @@ -85,7 +79,14 @@ Local taint tracking extends local data flow by including non-value-preserving f If ``x`` is a tainted string then ``y`` is also tainted. -The local taint tracking library is in the module ``TaintTracking``. Like local data flow, a predicate ``localTaintStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo)`` holds if there is an immediate taint propagation edge from the node ``nodeFrom`` to the node ``nodeTo``. You can apply the predicate recursively by using the ``+`` and ``*`` operators, or by using the predefined recursive predicate ``localTaint``, which is equivalent to ``localTaintStep*``. + +To use the taint tracking library you need the following import: + +.. code-block:: ql + + import semmle.code.java.dataflow.TaintTracking + +Like local data flow, a predicate ``localTaintStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo)`` holds if there is an immediate taint propagation edge from the node ``nodeFrom`` to the node ``nodeTo``. You can apply the predicate recursively by using the ``+`` and ``*`` operators, or by using the predefined recursive predicate ``localTaint``, which is equivalent to ``localTaintStep*``. For example, you can find taint propagation from a parameter ``source`` to an expression ``sink`` in zero or more local steps: