Skip to content

Commit 211cda3

Browse files
egregius313owen-mc
andauthored
Method signatures and receiver/qualifier language
Co-authored-by: Owen Mansel-Chan <62447351+owen-mc@users.noreply.github.com>
1 parent cfa1ad6 commit 211cda3

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ We need to add a tuple to the ``sinkModel``\(namespace, type, subtypes, name, si
8989
pack: codeql/go-all
9090
extensible: sinkModel
9191
data:
92-
- ["database/sql", "DB", False, "Prepare", "(string)", "", "Argument[0]", "sql-injection", "manual"]
92+
- ["database/sql", "DB", False, "Prepare", "", "", "Argument[0]", "sql-injection", "manual"]
9393
9494
Since we want to add a new sink, we need to add a tuple to the ``sinkModel`` extensible predicate.
9595
The first five values identify the callable (in this case a method) to be modeled as a sink.
@@ -98,7 +98,7 @@ The first five values identify the callable (in this case a method) to be modele
9898
- The second value ``DB`` is the name of the type that the method is associated with.
9999
- The third value ``False`` is a flag that indicates whether or not the sink also applies to all overrides of the method.
100100
- The fourth value ``Prepare`` is the method name. Constructors are named after the class.
101-
- The fifth value ``(string)`` is the method input type signature. This value is often excluded and is simply set to an empty string since Go does not allow for a given type to have multiple methods with the same type.
101+
- The fifth value ``""`` is the method input type signature. For Go it should always be an empty string. It is needed for other languages where multiple functions or methods may have the same name and they need to be distinguished by the number and types of the arguments.
102102

103103
The sixth value should be left empty and is out of scope for this documentation.
104104
The remaining values are used to define the ``access path``, the ``kind``, and the ``provenance`` (origin) of the sink.
@@ -228,7 +228,7 @@ We need to add a tuple to the ``summaryModel``\(namespace, type, subtypes, name,
228228
pack: codeql/go-all
229229
extensible: summaryModel
230230
data:
231-
- ["net/url", "URL", False, "Hostname", "()", "", "Argument[this]", "ReturnValue", "taint", "manual"]
231+
- ["net/url", "URL", False, "Hostname", "", "", "Argument[receiver]", "ReturnValue", "taint", "manual"]
232232
233233
Since we are adding flow through a method, we need to add tuples to the ``summaryModel`` extensible predicate.
234234
Each tuple defines flow from one argument to the return value.
@@ -241,12 +241,12 @@ These are the same for both of the rows above as we are adding two summaries for
241241
- The second value ``URL`` is the receiver type.
242242
- The third value ``True`` is a flag that indicates whether or not the summary also applies to all overrides of the method.
243243
- The fourth value ``Hostname`` is the method name.
244-
- The fifth value ``()`` is the method input type signature.
244+
- The fifth value ``""`` is left blank, since specifying the signature is optional and Go does not allow multiple signature overloads for the same function.
245245

246246
The sixth value should be left empty and is out of scope for this documentation.
247247
The remaining values are used to define the ``access path``, the ``kind``, and the ``provenance`` (origin) of the summary.
248248

249-
- The seventh value is the access path to the input (where data flows from). ``Argument[this]`` is the access path to the qualifier (``u`` in the example).
249+
- The seventh value is the access path to the input (where data flows from). ``Argument[receiver]`` is the access path to the receiver (``u`` in the example).
250250
- The eighth value ``ReturnValue`` is the access path to the output (where data flows to), in this case ``ReturnValue``, which means that the input flows to the return value.
251251
- The ninth value ``taint`` is the kind of the flow. ``taint`` means that taint is propagated through the call.
252252
- The tenth value ``manual`` is the provenance of the summary, which is used to identify the origin of the summary.

0 commit comments

Comments
 (0)