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-python.rst
+45-25Lines changed: 45 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -271,34 +271,16 @@ These predicates are defined in the configuration:
271
271
272
272
Similar to global data flow, the characteristic predicate (``MyTaintTrackingConfiguration()``) defines the unique name of the configuration and the taint analysis is performed using the predicate ``hasFlow(DataFlow::Node source, DataFlow::Node sink)``.
273
273
274
-
Flow sources
275
-
~~~~~~~~~~~~
274
+
Predefined sources and sinks
275
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
276
276
277
-
The data flow library contains some predefined flow sources. The class ``RemoteFlowSource`` (defined in module ``semmle.python.dataflow.new.RemoteFlowSources``) represents data flow from remote network inputs. This is useful for finding security problems in networked services.
277
+
The data flow library contains a number of predefined sources and sinks, providing a good starting point for defining data flow based security queries.
278
278
279
-
For global flow, it is also useful to restrict sources to instances of ``LocalSourceNode``. The predefined sources generally do that.
280
-
281
-
Example
282
-
~~~~~~~
279
+
- The class ``RemoteFlowSource`` (defined in module ``semmle.python.dataflow.new.RemoteFlowSources``) represents data flow from remote network inputs. This is useful for finding security problems in networked services.
280
+
- The library ``Concepts`` (defined in module ``semmle.python.Concepts``) contain several subclasses of ``DataFlow::Node`` that are security relevant, such as ``FileSystemAccess`` and ``SqlExecution``.
281
+
- The module ``Attributes`` (defined in module ``semmle.python.dataflow.new.internal.Attributes``) defines ``AttrRead`` and ``AttrWrite`` which handle both ordinary and dynamic attribute access.
283
282
284
-
This query shows a data flow configuration that uses all network input as data sources:
For global flow, it is also useful to restrict sources to instances of ``LocalSourceNode``. The predefined sources generally do that.
302
284
303
285
Class hierarchy
304
286
~~~~~~~~~~~~~~~
@@ -309,12 +291,50 @@ Class hierarchy
309
291
- ``DataFlow::ExprNode`` - an expression behaving as a data flow node.
310
292
- ``DataFlow::ParameterNode`` - a parameter data flow node representing the value of a parameter at function entry.
311
293
- ``RemoteFlowSource`` - data flow from network/remote input.
294
+
- ``Attributes::AttrRead`` - flow out of an attribute.
295
+
- ``Attributes::AttrWrite`` - flow into an attribute.
296
+
- ``Concepts::SystemCommandExecution`` - a data-flow node that executes an operating system command, for instance by spawning a new process.
297
+
- ``Concepts::FileSystemAccess`` - a data flow node that performs a file system access, including reading and writing data, creating and deleting files and folders, checking and updating permissions, and so on.
298
+
- ``Concepts::Path::PathNormalization`` - a data-flow node that performs path normalization. This is often needed in order to safely access paths.
299
+
- ``Concepts::Decoding`` - a data-flow node that decodes data from a binary or textual format. A decoding (automatically) preserves taint from input to output. However, it can also be a problem in itself, for example if it allows code execution or could result in denial-of-service.
300
+
- ``Concepts::Encoding`` - a data-flow node that encodes data to a binary or textual format. An encoding (automatically) preserves taint from input to output.
301
+
- ``Concepts::CodeExecution`` - a data-flow node that dynamically executes Python code.
302
+
- ``Concepts::SqlExecution`` - a data-flow node that executes SQL statements.
303
+
- ``Concepts::HTTP::Server::RouteSetup`` - a data-flow node that sets up a route on a server.
304
+
- ``Concepts::HTTP::Server::HttpResponse`` - a data-flow node that creates a HTTP response on a server.
312
305
313
306
- ``TaintTracking::Configuration`` - base class for custom global taint tracking analysis.
314
307
315
308
Examples
316
309
~~~~~~~~
317
310
311
+
This query shows a data flow configuration that uses all network input as data sources:
0 commit comments