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/customizing-library-models-for-go.rst
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
Customizing library models for Go
4
4
=================================
5
5
6
-
You can model the methods and callables that control data flow in any framework or library. This is especially useful for custom frameworks or niche libraries, that are not supported by the standard CodeQL libraries.
6
+
You can model the methods and functions that control data flow in any framework or library. This is especially useful for custom frameworks or niche libraries, that are not supported by the standard CodeQL libraries.
@@ -15,7 +15,7 @@ This article contains reference material about how to define custom models for s
15
15
About data extensions
16
16
---------------------
17
17
18
-
You can customize analysis by defining models (summaries, sinks, and sources) of your code's Go dependencies in data extension files. Each model defines the behavior of one or more elements of your library or framework, such as methods, properties, and callables. When you run dataflow analysis, these models expand the potential sources and sinks tracked by dataflow analysis and improve the precision of results.
18
+
You can customize analysis by defining models (summaries, sinks, and sources) of your code's Go dependencies in data extension files. Each model defines the behavior of one or more elements of your library or framework, such as functions, methods, and fields. When you run dataflow analysis, these models expand the potential sources and sinks tracked by dataflow analysis and improve the precision of results.
19
19
20
20
Most of the security queries search for paths from a source of untrusted input to a sink that represents a vulnerability. This is known as taint tracking. Each source is a starting point for dataflow analysis to track tainted data and each sink is an end point.
21
21
@@ -80,7 +80,7 @@ This is the ``Prepare`` method of the ``DB`` type in the ``database/sql`` packag
80
80
...
81
81
}
82
82
83
-
We need to add a tuple to the ``sinkModel``\(namespace, type, subtypes, name, signature, ext, input, kind, provenance) extensible predicate by updating a data extension file.
83
+
We need to add a tuple to the ``sinkModel``\(package, type, subtypes, name, signature, ext, input, kind, provenance) extensible predicate by updating a data extension file.
84
84
85
85
.. code-block:: yaml
86
86
@@ -92,7 +92,7 @@ We need to add a tuple to the ``sinkModel``\(namespace, type, subtypes, name, si
Since we want to add a new sink, we need to add a tuple to the ``sinkModel`` extensible predicate.
95
-
The first five values identify the callable (in this case a method) to be modeled as a sink.
95
+
The first five values identify the function (in this case a method) to be modeled as a sink.
96
96
97
97
- The first value ``database/sql`` is the package name.
98
98
- The second value ``DB`` is the name of the type that the method is associated with.
@@ -120,7 +120,7 @@ This is the ``Listen`` function which is located in the ``net`` package.
120
120
}
121
121
122
122
123
-
We need to add a tuple to the ``sourceModel``\(namespace, type, subtypes, name, signature, ext, output, kind, provenance) extensible predicate by updating a data extension file.
123
+
We need to add a tuple to the ``sourceModel``\(package, type, subtypes, name, signature, ext, output, kind, provenance) extensible predicate by updating a data extension file.
124
124
125
125
.. code-block:: yaml
126
126
@@ -133,7 +133,7 @@ We need to add a tuple to the ``sourceModel``\(namespace, type, subtypes, name,
133
133
134
134
135
135
Since we are adding a new source, we need to add a tuple to the ``sourceModel`` extensible predicate.
136
-
The first five values identify the callable (in this case a function) to be modeled as a source.
136
+
The first five values identify the function to be modeled as a source.
137
137
138
138
- The first value ``net`` is the package name.
139
139
- The second value ``""`` is left blank, since the function is not a method of a type.
@@ -162,7 +162,7 @@ This pattern covers many of the cases where we need to summarize flow through a
162
162
...
163
163
}
164
164
165
-
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:
165
+
We need to add tuples to the ``summaryModel``\(package, type, subtypes, name, signature, ext, input, output, kind, provenance) extensible predicate by updating a data extension file:
166
166
167
167
.. code-block:: yaml
168
168
@@ -178,10 +178,10 @@ Since we are adding flow through a method, we need to add tuples to the ``summar
178
178
Each tuple defines flow from one argument to the return value.
179
179
The first row defines flow from the first argument (``elems`` in the example) to the return value (``t`` in the example) and the second row defines flow from the second argument (``sep`` in the example) to the return value (``t`` in the example).
180
180
181
-
The first five values identify the callable (in this case a method) to be modeled as a summary.
181
+
The first five values identify the function to be modeled as a summary.
182
182
These are the same for both of the rows above as we are adding two summaries for the same method.
183
183
184
-
- The first value ``strings`` is the pacakge name.
184
+
- The first value ``strings`` is the package name.
185
185
- The second value ``""`` is left blank, since the function is not a method of a type.
186
186
- The third value ``False`` is a flag that indicates whether or not the summary also applies to all overrides of the method.
187
187
- The fourth value ``Join`` is the function name.
@@ -219,7 +219,7 @@ This example shows how the Go query pack models flow through a method for a simp
219
219
...
220
220
}
221
221
222
-
We need to add a tuple to the ``summaryModel``\(namespace, type, subtypes, name, signature, ext, input, output, kind, provenance) extensible predicate by updating a data extension file:
222
+
We need to add a tuple to the ``summaryModel``\(package, type, subtypes, name, signature, ext, input, output, kind, provenance) extensible predicate by updating a data extension file:
223
223
224
224
.. code-block:: yaml
225
225
@@ -234,7 +234,7 @@ Since we are adding flow through a method, we need to add tuples to the ``summar
234
234
Each tuple defines flow from one argument to the return value.
235
235
The first row defines flow from the qualifier of the method call (``u`` in the example) to the return value (``host`` in the example).
236
236
237
-
The first five values identify the callable (in this case a method) to be modeled as a summary.
237
+
The first five values identify the function (in this case a method) to be modeled as a summary.
238
238
239
239
- The first value ``net/url`` is the package name.
240
240
- The second value ``URL`` is the receiver type.
@@ -261,7 +261,7 @@ This example shows how we can model a field read as a source of tainted data.
261
261
...
262
262
}
263
263
264
-
We need to add a tuple to the ``sourceModel``\(namespace, type, subtypes, name, signature, ext, output, kind, provenance) extensible predicate by updating a data extension file.
264
+
We need to add a tuple to the ``sourceModel``\(package, type, subtypes, name, signature, ext, output, kind, provenance) extensible predicate by updating a data extension file.
265
265
266
266
.. code-block:: yaml
267
267
@@ -294,7 +294,7 @@ Package grouping
294
294
Since Go uses URLs for package identifiers, it is possible for packages to be imported with different paths. For example, the ``glog`` package can be imported using both the ``github.com/golang/glog`` and ``gopkg.in/glog`` paths.
295
295
296
296
To handle this, the CodeQL Go library uses a mapping from the package path to a group name for the package. This mapping can be specified using the ``packageGrouping`` extensible predicate, and then the models for the APIs in the package
297
-
will use the group name in place of the package path. The package field in models will be the prefix ``group:`` followed by the group name.
297
+
will use the the prefix ``group:`` followed by the group name in place of the package path.
0 commit comments