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
Copy file name to clipboardExpand all lines: docs/codeql/codeql-language-guides/analyzing-data-flow-in-rust.rst
+16-35Lines changed: 16 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,10 +23,9 @@ Using local data flow
23
23
~~~~~~~~~~~~~~~~~~~~~
24
24
25
25
You can use the local data flow library by importing the ``codeql.rust.dataflow.DataFlow`` module. The library uses the class ``Node`` to represent any element through which data can flow.
26
-
``Node``\ s are divided into expression nodes (``ExprNode``) and parameter nodes (``ParameterNode``).
27
-
You can map a data flow ``ParameterNode`` to its corresponding ``Parameter`` AST node using the ``asParameter`` member predicate.
28
-
Similarly, you can use the ``asExpr`` member predicate to map a data flow ``ExprNode`` to its corresponding ``ExprCfgNode`` in the control-flow library.
29
-
26
+
Common ``Node`` types include expression nodes (``ExprNode``) and parameter nodes (``ParameterNode``).
27
+
You can use the ``asExpr`` member predicate to map a data flow ``ExprNode`` to its corresponding ``ExprCfgNode`` in the control-flow library.
28
+
Similarly, you can map a data flow ``ParameterNode`` to its corresponding ``Parameter`` AST node using the ``asParameter`` member predicate.
30
29
.. code-block:: ql
31
30
32
31
class Node {
@@ -39,22 +38,8 @@ Similarly, you can use the ``asExpr`` member predicate to map a data flow ``Expr
39
38
...
40
39
}
41
40
42
-
You can use the predicates ``exprNode`` and ``parameterNode`` to map from expressions and parameters to their data-flow node:
* Gets the node corresponding to the value of parameter `p` at function entry.
53
-
*/
54
-
ParameterNode parameterNode(Parameter p) { ... }
55
-
56
-
Note that since ``asExpr`` and ``exprNode`` map between data-flow and control-flow nodes, you then need to call the ``getExpr`` member predicate on the control-flow node to map to the corresponding AST node,
57
-
for example, by writing ``node.asExpr().getExpr()``.
41
+
Note that since ``asExpr`` maps from data-flow to control-flow nodes, you then need to call the ``getExpr`` member predicate on the control-flow node to map to the corresponding AST node,
42
+
for example by writing ``node.asExpr().getExpr()``.
58
43
A control-flow graph considers every way control can flow through code, consequently, there can be multiple data-flow and control-flow nodes associated with a single expression node in the AST.
59
44
60
45
The predicate ``localFlowStep(Node nodeFrom, Node nodeTo)`` holds if there is an immediate data flow edge from the node ``nodeFrom`` to the node ``nodeTo``.
@@ -207,11 +192,7 @@ The global taint tracking library uses the same configuration module as the glob
207
192
Predefined sources
208
193
~~~~~~~~~~~~~~~~~~
209
194
210
-
The data flow library module ``codeql.rust.dataflow.FlowSources`` contains a number of predefined sources that you can use to write security queries to track data flow and taint flow.
211
-
212
-
- The class ``RemoteFlowSource`` represents data flow from remote network inputs and from other applications.
213
-
- The class ``LocalFlowSource`` represents data flow from local user input.
214
-
- The class ``FlowSource`` includes both of the above.
195
+
The library module ``codeql.rust.Concepts`` contains a number of predefined sources and sinks that you can use to write security queries to track data flow and taint flow.
215
196
216
197
Examples of global data flow
217
198
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -229,16 +210,16 @@ The following global taint-tracking query finds places where a string literal is
Copy file name to clipboardExpand all lines: docs/codeql/codeql-language-guides/codeql-for-rust.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,4 +13,4 @@ Experiment and learn how to write effective and efficient queries for CodeQL dat
13
13
analyzing-data-flow-in-rust
14
14
15
15
- :doc:`CodeQL library for Rust <codeql-library-for-rust>`: When you're analyzing Rust code, you can make use of the large collection of classes in the CodeQL library for Rust.
16
-
- :doc:`Analyzing data flow in Ruby<analyzing-data-flow-in-rust>`: You can use CodeQL to track the flow of data through a Rust program to places where the data is used.
16
+
- :doc:`Analyzing data flow in Rust<analyzing-data-flow-in-rust>`: You can use CodeQL to track the flow of data through a Rust program to places where the data is used.
Copy file name to clipboardExpand all lines: docs/codeql/codeql-language-guides/codeql-library-for-rust.rst
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,14 +12,14 @@ CodeQL ships with a library for analyzing Rust code. The classes in this library
12
12
abstractions and predicates to help you with common analysis tasks.
13
13
14
14
The library is implemented as a set of CodeQL modules, that is, files with the extension ``.qll``. The
15
-
module `rust.qll <https://github.com/github/codeql/blob/main/rust/ql/lib/rust.qll>`__ imports most other standard library modules, so you can include the complete
16
-
library by beginning your query with:
15
+
module `rust.qll <https://github.com/github/codeql/blob/main/rust/ql/lib/rust.qll>`__ imports most other standard library modules, so you can include them
16
+
by beginning your query with:
17
17
18
18
.. code-block:: ql
19
19
20
20
import rust
21
21
22
-
The CodeQL libraries model various aspects of Rust code. The above import includes the abstract syntax tree (AST) library, which is used for locating program elements,
22
+
The CodeQL libraries model various aspects of Rust code. The above import includes the abstract syntax tree (AST) library, which is used for locating program elements
23
23
to match syntactic elements in the source code. This can be used for example to find values, patterns and structures.
0 commit comments