Skip to content

Commit 5e7159f

Browse files
committed
Swift: Minor edits.
1 parent f2cb2b3 commit 5e7159f

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

docs/codeql/codeql-language-guides/analyzing-data-flow-in-swift.rst

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ For a more general introduction to modeling data flow, see ":ref:`About data flo
1515
Local data flow
1616
---------------
1717

18-
Local data flow tracks the flow of data within a single method or callable. Local data flow is easier, faster, and more precise than global data flow. Before looking at more complex tracking, you should always consider local tracking because it is sufficient for many queries.
18+
Local data flow tracks the flow of data within a single function. Local data flow is easier, faster, and more precise than global data flow. Before looking at more complex tracking, you should always consider local tracking because it is sufficient for many queries.
1919

2020
Using local data flow
2121
~~~~~~~~~~~~~~~~~~~~~
@@ -36,7 +36,7 @@ The ``Node`` class has a number of useful subclasses, such as ``ExprNode`` for e
3636
*/
3737
ControlFlowNode getCfgNode() { none() }
3838
39-
...
39+
...
4040
}
4141
4242
You can use the predicates ``exprNode`` and ``parameterNode`` to map from expressions and parameters to their data-flow node:
@@ -65,7 +65,7 @@ For example, you can find flow from an expression ``source`` to an expression ``
6565
Using local taint tracking
6666
~~~~~~~~~~~~~~~~~~~~~~~~~~
6767

68-
Local taint tracking extends local data flow to include flow steps where values are not preserved, for example, string manipulation.
68+
Local taint tracking extends local data flow to include flow steps where values are not preserved, such as string manipulation.
6969
For example:
7070

7171
.. code-block:: swift
@@ -209,10 +209,10 @@ The global taint tracking library uses the same configuration module as the glob
209209
where MyTaintFlow::flow(source, sink)
210210
select source, "Taint flow to $@.", sink, sink.toString()
211211
212-
Predefined sources and sinks
212+
Predefined sources
213213
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
214214

215-
The data flow library module ``codeql.swift.dataflow.FlowSources`` contains a number of predefined sources and sinks, providing a good starting point for defining data flow and taint flow based security queries.
215+
The data flow library module ``codeql.swift.dataflow.FlowSources`` contains a number of predefined sources, providing a good starting point for defining data flow and taint flow based security queries.
216216

217217
- The class ``RemoteFlowSource`` represents data flow from remote network inputs and from other applications.
218218
- The class ``LocalFlowSource`` represents data flow from local user input.
@@ -221,11 +221,11 @@ The data flow library module ``codeql.swift.dataflow.FlowSources`` contains a nu
221221
Examples of global data flow
222222
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
223223

224-
The following global taint-tracking query finds places where a string literal is used in a function call argument called "password".
224+
The following global taint-tracking query finds places where a string literal is used in a function call argument named "password".
225225
- Since this is a taint-tracking query, the ``TaintTracking::Global`` module is used.
226226
- The ``isSource`` predicate defines sources as any ``StringLiteralExpr``.
227227
- The ``isSink`` predicate defines sinks as arguments to a ``CallExpr`` called "password".
228-
- The sources and sinks may need tuning to a particular use case, for example if passwords are represented by a type other than ``String`` or passed in arguments of a different name than "password".
228+
- The sources and sinks may need tuning to a particular use, for example if passwords are represented by a type other than ``String`` or passed in arguments of a different name than "password".
229229

230230
.. code-block:: ql
231231
@@ -245,8 +245,7 @@ The following global taint-tracking query finds places where a string literal is
245245
246246
from DataFlow::Node sourceNode, DataFlow::Node sinkNode
247247
where ConstantPasswordFlow::flow(sourceNode, sinkNode)
248-
select sinkNode, sourceNode, sinkNode,
249-
"The value '" + sourceNode.toString() + "' is used as a constant password."
248+
select sinkNode, "The value '" + sourceNode.toString() + "' is used as a constant password."
250249
251250
252251
The following global taint-tracking query finds places where a value from a remote or local user input is used as an argument to the SQLite ``Connection.execute(_:)`` function.
@@ -256,7 +255,6 @@ The following global taint-tracking query finds places where a value from a remo
256255

257256
.. code-block:: ql
258257
259-
260258
import swift
261259
import codeql.swift.dataflow.DataFlow
262260
import codeql.swift.dataflow.TaintTracking
@@ -277,8 +275,7 @@ The following global taint-tracking query finds places where a value from a remo
277275
278276
from DataFlow::Node sourceNode, DataFlow::Node sinkNode
279277
where SqlInjectionFlow::flow(sourceNode, sinkNode)
280-
select sinkNode, sourceNode, sinkNode, "This query depends on a $@.", sourceNode,
281-
"user-provided value"
278+
select sinkNode, "This query depends on a $@.", sourceNode, "user-provided value"
282279
283280
Further reading
284281
---------------

0 commit comments

Comments
 (0)