Skip to content

Commit bb44a76

Browse files
authored
Merge pull request github#3138 from jf205/recent-changes
docs: fix links in Python articles (rc/1.23)
2 parents 1a992ba + 2407eb1 commit bb44a76

File tree

5 files changed

+44
-38
lines changed

5 files changed

+44
-38
lines changed

docs/language/learn-ql/cpp/dataflow.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ or using the predicates ``exprNode`` and ``parameterNode``:
4545
*/
4646
ParameterNode parameterNode(Parameter p) { ... }
4747
48-
The predicate ``localFlowStep(Node nodeFrom, Node, nodeTo)`` holds if there is an immediate data flow edge from the node ``nodeFrom`` to the node ``nodeTo``. The predicate can be applied recursively (using the ``+`` and ``*`` operators), or through the predefined recursive predicate ``localFlow``, which is equivalent to ``localFlowStep*``.
48+
The predicate ``localFlowStep(Node nodeFrom, Node nodeTo)`` holds if there is an immediate data flow edge from the node ``nodeFrom`` to the node ``nodeTo``. The predicate can be applied recursively (using the ``+`` and ``*`` operators), or through the predefined recursive predicate ``localFlow``, which is equivalent to ``localFlowStep*``.
4949

5050
For example, finding flow from a parameter ``source`` to an expression ``sink`` in zero or more local steps can be achieved as follows:
5151

docs/language/learn-ql/java/dataflow.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ or using the predicates ``exprNode`` and ``parameterNode``:
4545
*/
4646
ParameterNode parameterNode(Parameter p) { ... }
4747
48-
The predicate ``localFlowStep(Node nodeFrom, Node, nodeTo)`` holds if there is an immediate data flow edge from the node ``nodeFrom`` to the node ``nodeTo``. The predicate can be applied recursively (using the ``+`` and ``*`` operators), or through the predefined recursive predicate ``localFlow``, which is equivalent to ``localFlowStep*``.
48+
The predicate ``localFlowStep(Node nodeFrom, Node nodeTo)`` holds if there is an immediate data flow edge from the node ``nodeFrom`` to the node ``nodeTo``. The predicate can be applied recursively (using the ``+`` and ``*`` operators), or through the predefined recursive predicate ``localFlow``, which is equivalent to ``localFlowStep*``.
4949

5050
For example, finding flow from a parameter ``source`` to an expression ``sink`` in zero or more local steps can be achieved as follows:
5151

docs/language/learn-ql/python/introduce-libraries-python.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Summary
158158

159159
The most commonly used standard classes in the syntactic part of the library are organized as follows:
160160

161-
``Module``, ``Class``, ``Function``, ``Stmt``, and ``Expr`` - they are all subclasses of `AstNode <https://help.semmle.com/qldoc/python/semmle/python/AST.qll/type.AST$AstNode.html>`__.
161+
``Module``, ``Class``, ``Function``, ``Stmt``, and ``Expr`` - they are all subclasses of `AstNode <https://help.semmle.com/qldoc/python/semmle/python/AstExtended.qll/type.AstExtended$AstNode.html>`__.
162162

163163
Abstract syntax tree
164164
''''''''''''''''''''
@@ -323,8 +323,8 @@ The CodeQL library for Python also supplies classes to specify taint-tracking an
323323
Summary
324324
~~~~~~~
325325

326-
- `TaintKind <https://help.semmle.com/qldoc/python/semmle/python/security/TaintTracking.qll/type.TaintTracking$TaintKind.html>`__
327-
- `Configuration <https://help.semmle.com/qldoc/python/semmle/python/security/TaintTracking.qll/type.TaintTracking$TaintTracking$Configuration.html>`__
326+
- `TaintKind <https://help.semmle.com/qldoc/python/semmle/python/dataflow/TaintTracking.qll/type.TaintTracking$TaintKind.html>`__
327+
- `Configuration <https://help.semmle.com/qldoc/python/semmle/python/dataflow/Configuration.qll/type.Configuration$TaintTracking$Configuration.html>`__
328328

329329
These classes are explained in more detail in :doc:`Tutorial: Taint tracking and data flow analysis in Python <taint-tracking>`.
330330

docs/language/learn-ql/python/taint-tracking.rst

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Taint tracking and data flow analysis in Python
44
Overview
55
--------
66

7-
Taint tracking is used to analyze how potentially insecure, or 'tainted' data flows throughout a program at runtime.
7+
Taint tracking is used to analyze how potentially insecure, or 'tainted' data flows throughout a program at runtime.
88
You can use taint tracking to find out whether user-controlled input can be used in a malicious way,
99
whether dangerous arguments are passed to vulnerable functions, and whether confidential or sensitive data can leak.
1010
You can also use it to track invalid, insecure, or untrusted data in other analyses.
@@ -13,36 +13,36 @@ Taint tracking differs from basic data flow in that it considers non-value-prese
1313
For example, in the assignment ``dir = path + "/"``, if ``path`` is tainted then ``dir`` is also tainted,
1414
even though there is no data flow from ``path`` to ``path + "/"``.
1515

16-
Separate CodeQL libraries have been written to handle 'normal' data flow and taint tracking in :doc:`C/C++ <../cpp/dataflow>`, :doc:`C# <../csharp/dataflow>`, :doc:`Java <../java/dataflow>`, and :doc:`JavaScript <../javascript/dataflow>`. You can access the appropriate classes and predicates that reason about these different modes of data flow by importing the appropriate library in your query.
17-
In Python analysis, we can use the same taint tracking library to model both 'normal' data flow and taint flow, but we are still able make the distinction between steps that preserve value and those that don't by defining additional data flow properties.
16+
Separate CodeQL libraries have been written to handle 'normal' data flow and taint tracking in :doc:`C/C++ <../cpp/dataflow>`, :doc:`C# <../csharp/dataflow>`, :doc:`Java <../java/dataflow>`, and :doc:`JavaScript <../javascript/dataflow>`. You can access the appropriate classes and predicates that reason about these different modes of data flow by importing the appropriate library in your query.
17+
In Python analysis, we can use the same taint tracking library to model both 'normal' data flow and taint flow, but we are still able make the distinction between steps that preserve value and those that don't by defining additional data flow properties.
1818

1919
For further information on data flow and taint tracking with CodeQL, see :doc:`Introduction to data flow <../intro-to-data-flow>`.
2020

2121
Fundamentals of taint tracking and data flow analysis
2222
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2323

24-
The taint tracking library is in the `TaintTracking <https://help.semmle.com/qldoc/python/semmle/python/security/TaintTracking.qll/module.TaintTracking.html>`__ module.
24+
The taint tracking library is in the `TaintTracking <https://help.semmle.com/qldoc/python/semmle/python/dataflow/TaintTracking.qll/module.TaintTracking.html>`__ module.
2525
Any taint tracking or data flow analysis query has three explicit components, one of which is optional, and an implicit component.
2626
The explicit components are:
2727

28-
1. One or more ``sources`` of potentially insecure or unsafe data, represented by the `TaintTracking::Source <https://help.semmle.com/qldoc/python/semmle/python/security/TaintTracking.qll/type.TaintTracking$TaintSource.html>`__ class.
29-
2. One or more ``sinks``, to where the data or taint may flow, represented by the `TaintTracking::Sink <https://help.semmle.com/qldoc/python/semmle/python/security/TaintTracking.qll/type.TaintTracking$TaintSink.html>`__ class.
30-
3. Zero or more ``sanitizers``, represented by the `Sanitizer <https://help.semmle.com/qldoc/python/semmle/python/security/TaintTracking.qll/type.TaintTracking$Sanitizer.html>`__ class.
28+
1. One or more ``sources`` of potentially insecure or unsafe data, represented by the `TaintTracking::Source <https://help.semmle.com/qldoc/python/semmle/python/dataflow/TaintTracking.qll/type.TaintTracking$TaintSource.html>`__ class.
29+
2. One or more ``sinks``, to where the data or taint may flow, represented by the `TaintTracking::Sink <https://help.semmle.com/qldoc/python/semmle/python/dataflow/TaintTracking.qll/type.TaintTracking$TaintSink.html>`__ class.
30+
3. Zero or more ``sanitizers``, represented by the `Sanitizer <https://help.semmle.com/qldoc/python/semmle/python/dataflow/TaintTracking.qll/type.TaintTracking$Sanitizer.html>`__ class.
3131

3232
A taint tracking or data flow query gives results when there is the flow of data from a source to a sink, which is not blocked by a sanitizer.
3333

34-
These three components are bound together using a `TaintTracking::Configuration <https://help.semmle.com/qldoc/python/semmle/python/security/TaintTracking.qll/type.TaintTracking$TaintTracking$Configuration.html>`__.
34+
These three components are bound together using a `TaintTracking::Configuration <https://help.semmle.com/qldoc/python/semmle/python/dataflow/Configuration.qll/type.Configuration$TaintTracking$Configuration.html>`__.
3535
The purpose of the configuration is to specify exactly which sources and sinks are relevant to the specific query.
3636

37-
The final, implicit component is the "kind" of taint, represented by the `TaintKind <https://help.semmle.com/qldoc/python/semmle/python/security/TaintTracking.qll/type.TaintTracking$TaintKind.html>`__ class.
37+
The final, implicit component is the "kind" of taint, represented by the `TaintKind <https://help.semmle.com/qldoc/python/semmle/python/dataflow/TaintTracking.qll/type.TaintTracking$TaintKind.html>`__ class.
3838
The kind of taint determines which non-value-preserving steps are possible, in addition to value-preserving steps that are built into the analysis.
39-
In the above example ``dir = path + "/"``, taint flows from ``path`` to ``dir`` if the taint represents a string, but not if the taint is ``None``.
39+
In the above example ``dir = path + "/"``, taint flows from ``path`` to ``dir`` if the taint represents a string, but not if the taint is ``None``.
4040

4141
Limitations
4242
~~~~~~~~~~~
4343

4444
Although taint tracking is a powerful technique, it is worth noting that it depends on the underlying data flow graphs.
45-
Creating a data flow graph that is both accurate and covers a large enough part of a program is a challenge,
45+
Creating a data flow graph that is both accurate and covers a large enough part of a program is a challenge,
4646
especially for a dynamic language like Python. The call graph might be incomplete, the reachability of code is an approximation,
4747
and certain constructs, like ``eval``, are just too dynamic to analyze.
4848

@@ -61,18 +61,18 @@ A simple taint tracking query has the basic form:
6161
*/
6262
6363
import semmle.python.security.TaintTracking
64-
64+
6565
class MyConfiguration extends TaintTracking::Configuration {
66-
66+
6767
MyConfiguration() { this = "My example configuration" }
68-
68+
6969
override predicate isSource(TaintTracking::Source src) { ... }
70-
70+
7171
override predicate isSink(TaintTracking::Sink sink) { ... }
72-
72+
7373
/* optionally */
7474
override predicate isExtension(Extension extension) { ... }
75-
75+
7676
}
7777
7878
from MyConfiguration config, TaintTracking::Source src, TaintTracking::Sink sink
@@ -107,17 +107,17 @@ The sink is defined by using a custom ``TaintTracking::Sink`` class.
107107
}
108108
109109
}
110-
110+
111111
class HttpToUnsafeConfiguration extends TaintTracking::Configuration {
112-
113-
HttpToUnsafeConfiguration() {
112+
113+
HttpToUnsafeConfiguration() {
114114
this = "Example config finding flow from http request to 'unsafe' function"
115115
}
116-
116+
117117
override predicate isSource(TaintTracking::Source src) { src instanceof HttpRequestTaintSource }
118-
118+
119119
override predicate isSink(TaintTracking::Sink sink) { sink instanceof UnsafeSink }
120-
120+
121121
}
122122
123123
from HttpToUnsafeConfiguration config, TaintTracking::Source src, TaintTracking::Sink sink
@@ -183,17 +183,17 @@ Thus, our example query becomes:
183183
}
184184
185185
}
186-
186+
187187
class HttpToUnsafeConfiguration extends TaintTracking::Configuration {
188-
189-
HttpToUnsafeConfiguration() {
188+
189+
HttpToUnsafeConfiguration() {
190190
this = "Example config finding flow from http request to 'unsafe' function"
191191
}
192-
192+
193193
override predicate isSource(TaintTracking::Source src) { src instanceof HttpRequestTaintSource }
194-
194+
195195
override predicate isSink(TaintTracking::Sink sink) { sink instanceof UnsafeSink }
196-
196+
197197
}
198198
199199
from HttpToUnsafeConfiguration config, TaintedPathSource src, TaintedPathSink sink
@@ -205,7 +205,7 @@ Thus, our example query becomes:
205205
Custom taint kinds and flows
206206
----------------------------
207207

208-
In the above examples, we have assumed the existence of a suitable ``TaintKind``,
208+
In the above examples, we have assumed the existence of a suitable ``TaintKind``,
209209
but sometimes it is necessary to model the flow of other objects, such as database connections, or ``None``.
210210

211211
The ``TaintTracking::Source`` and ``TaintTracking::Sink`` classes have predicates that determine which kind of taint the source and sink model, respectively.

docs/language/ql-spec/language.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,10 +1075,16 @@ Apart from the presence or absence of the rank variable, all other reduced forms
10751075

10761076
- If the formula is omitted, then it is taken to be ``any()``.
10771077
- If there are no aggregation expressions, then either:
1078-
+ The aggregation id is ``count`` or ``strictcount`` and the expression is taken to be ``1``.
1079-
+ There must be precisely one variable declaration, and the aggregation expression is taken to be a reference to that variable.
1078+
1079+
- The aggregation id is ``count`` or ``strictcount`` and the expression is taken to be ``1``.
1080+
- There must be precisely one variable declaration, and the aggregation expression is taken to be a reference to that variable.
1081+
10801082
- If the aggregation id is ``concat`` or ``strictconcat`` and it has a single expression then the second expression is taken to be ``""``.
1081-
- If the ``monotonicAggregates`` language pragma is not enabled, or the original formula and variable declarations are both omitted, then the aggregate is transformed as follows: - For each aggregation expression ``expr_i``, a fresh variable ``v_i`` is declared with the same type as the expression in addition to the original variable declarations. - The new range is the conjunction of the original range and a term ``v_i = expr_i`` for each aggregation expression ``expr_i``. - Each original aggregation expression ``expr_i`` is replaced by a new aggregation expression ``v_i``.
1083+
- If the ``monotonicAggregates`` language pragma is not enabled, or the original formula and variable declarations are both omitted, then the aggregate is transformed as follows:
1084+
1085+
- For each aggregation expression ``expr_i``, a fresh variable ``v_i`` is declared with the same type as the expression in addition to the original variable declarations.
1086+
- The new range is the conjunction of the original range and a term ``v_i = expr_i`` for each aggregation expression ``expr_i``.
1087+
- Each original aggregation expression ``expr_i`` is replaced by a new aggregation expression ``v_i``.
10821088

10831089
The variables in the variable declarations list must not occur in the typing environment.
10841090

0 commit comments

Comments
 (0)