Skip to content

Commit e142818

Browse files
authored
Remove Select example.
Go does not currently have any equivalent with regards to lambda flow
1 parent e8aac2b commit e142818

1 file changed

Lines changed: 0 additions & 59 deletions

File tree

docs/codeql/codeql-language-guides/customizing-library-models-for-go.rst

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -250,65 +250,6 @@ The remaining values are used to define the ``access path``, the ``kind``, and t
250250
- The ninth value ``taint`` is the kind of the flow. ``taint`` means that taint is propagated through the call.
251251
- The tenth value ``manual`` is the provenance of the summary, which is used to identify the origin of the summary.
252252

253-
Example: Add flow through the ``Select`` method
254-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
255-
This example shows how the C# query pack models a more complex flow through a method.
256-
Here we model flow through higher order methods and collection types, as well as how to handle extension methods and generics.
257-
258-
.. code-block:: csharp
259-
260-
public static void TaintFlow(IEnumerable<string> stream) {
261-
IEnumerable<string> lines = stream.Select(item => item + "\n");
262-
...
263-
}
264-
265-
We need to add tuples to the ``summaryModel``\(namespace, type, subtypes, name, signature, ext, input, output, kind, provenance) extensible predicate by updating a data extension file:
266-
267-
.. code-block:: yaml
268-
269-
extensions:
270-
- addsTo:
271-
pack: codeql/csharp-all
272-
extensible: summaryModel
273-
data:
274-
- ["System.Linq", "Enumerable", False, "Select<TSource,TResult>", "(System.Collections.Generic.IEnumerable<TSource>,System.Func<TSource,TResult>)", "", "Argument[0].Element", "Argument[1].Parameter[0]", "value", "manual"]
275-
- ["System.Linq", "Enumerable", False, "Select<TSource,TResult>", "(System.Collections.Generic.IEnumerable<TSource>,System.Func<TSource,TResult>)", "", "Argument[1].ReturnValue", "ReturnValue.Element", "value", "manual"]
276-
277-
278-
Since we are adding flow through a method, we need to add tuples to the ``summaryModel`` extensible predicate.
279-
Each tuple defines part of the flow that comprises the total flow through the ``Select`` method.
280-
The first five values identify the callable (in this case a method) to be modeled as a summary.
281-
These are the same for both of the rows above as we are adding two summaries for the same method.
282-
283-
- The first value ``System.Linq`` is the namespace name.
284-
- The second value ``Enumerable`` is the class (type) name.
285-
- The third value ``False`` is a flag that indicates whether or not the summary also applies to all overrides of the method.
286-
- The fourth value ``Select<TSource,TResult>`` is the method name, along with the type parameters for the method. The names of the generic type parameters provided in the model must match the names of the generic type parameters in the method signature in the source code.
287-
- The fifth value ``(System.Collections.Generic.IEnumerable<TSource>,System.Func<TSource,TResult>)`` is the method input type signature. The generics in the signature must match the generics in the method signature in the source code.
288-
289-
The sixth value should be left empty and is out of scope for this documentation.
290-
The remaining values are used to define the ``access path``, the ``kind``, and the ``provenance`` (origin) of the summary definition.
291-
292-
- The seventh value is the access path to the ``input`` (where data flows from).
293-
- The eighth value is the access path to the ``output`` (where data flows to).
294-
295-
For the first row:
296-
297-
- The seventh value is ``Argument[0].Element``, which is the access path to the elements of the qualifier (the elements of the enumerable ``stream`` in the example).
298-
- The eight value is ``Argument[1].Parameter[0]``, which is the access path to the first parameter of the ``System.Func<TSource,TResult>`` argument of ``Select`` (the lambda parameter ``item`` in the example).
299-
300-
For the second row:
301-
302-
- The seventh value is ``Argument[1].ReturnValue``, which is the access path to the return value of the ``System.Func<TSource,TResult>`` argument of ``Select`` (the return value of the lambda in the example).
303-
- The eighth value is ``ReturnValue.Element``, which is the access path to the elements of the return value of ``Select`` (the elements of the enumerable ``lines`` in the example).
304-
305-
For the remaining values for both rows:
306-
307-
- The ninth value ``value`` is the kind of the flow. ``value`` means that the value is preserved.
308-
- The tenth value ``manual`` is the provenance of the summary, which is used to identify the origin of the summary.
309-
310-
That is, the first row specifies that values can flow from the elements of the qualifier enumerable into the first argument of the function provided to ``Select``. The second row specifies that values can flow from the return value of the function to the elements of the enumerable returned from ``Select``.
311-
312253
Example: Accessing the ``Body`` field of an HTTP request
313254
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
314255
This example shows how we can model a field read as a source of tainted data.

0 commit comments

Comments
 (0)