Skip to content

Commit 7210786

Browse files
egregius313owen-mc
andauthored
Subtypes/overrides documentation
Co-authored-by: Owen Mansel-Chan <[email protected]>
1 parent bf11e2c commit 7210786

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ We need to add a tuple to the ``sinkModel``\(package, type, subtypes, name, sign
8989
pack: codeql/go-all
9090
extensible: sinkModel
9191
data:
92-
- ["database/sql", "DB", False, "Prepare", "", "", "Argument[0]", "sql-injection", "manual"]
92+
- ["database/sql", "DB", True, "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 function (in this case a method) to be modeled as a sink.
9696

9797
- The first value ``database/sql`` is the package name.
9898
- The second value ``DB`` is the name of the type that the method is associated with.
99-
- The third value ``False`` is a flag that indicates whether or not the sink also applies to all overrides of the method.
99+
- The third value ``True`` is a flag that indicates whether or not the sink also applies to subtypes. This includes when the subtype embeds the given type, so that the method or field is promoted to be a method or field of the subtype. For interface methods it also includes types which implement the interface type.
100100
- The fourth value ``Prepare`` is the method name.
101101
- 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

@@ -137,7 +137,7 @@ The first five values identify the function to be modeled as a source.
137137

138138
- The first value ``net/http`` is the package name.
139139
- The second value ``Request`` is the type name, since the function is a method of the ``Request`` type.
140-
- The third value ``True`` is a flag that indicates whether or not the source also applies to all overrides of the method.
140+
- The third value ``True`` is a flag that indicates whether or not the sink also applies to subtypes. This includes when the subtype embeds the given type, so that the method or field is promoted to be a method or field of the subtype. For interface methods it also includes types which implement the interface type.
141141
- The fourth value ``FormValue`` is the function name.
142142
- The fifth value ``""`` is the function 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.
143143

@@ -183,7 +183,7 @@ These are the same for both of the rows above as we are adding two summaries for
183183

184184
- The first value ``strings`` is the package name.
185185
- The second value ``""`` is left blank, since the function is not a method of a type.
186-
- The third value ``False`` is a flag that indicates whether or not the summary also applies to all overrides of the method.
186+
- The third value ``False`` is a flag that indicates whether or not the sink also applies to subtypes. This has no effect for non-method functions.
187187
- The fourth value ``Join`` is the function name.
188188
- The fifth value ``""`` is left blank, since specifying the signature is optional and Go does not allow multiple signature overloads for the same function.
189189

@@ -238,7 +238,7 @@ The first five values identify the function (in this case a method) to be modele
238238

239239
- The first value ``net/url`` is the package name.
240240
- The second value ``URL`` is the receiver type.
241-
- The third value ``True`` is a flag that indicates whether or not the summary also applies to all overrides of the method.
241+
- The third value ``True`` is a flag that indicates whether or not the sink also applies to subtypes. This includes when the subtype embeds the given type, so that the method or field is promoted to be a method or field of the subtype. For interface methods it also includes types which implement the interface type.
242242
- The fourth value ``Hostname`` is the method name.
243243
- The fifth value ``""`` is left blank, since specifying the signature is optional and Go does not allow multiple signature overloads for the same function.
244244

@@ -277,7 +277,7 @@ The first five values identify the field to be modeled as a source.
277277

278278
- The first value ``net/http`` is the package name.
279279
- The second value ``Request`` is the name of the type that the field is associated with.
280-
- The third value ``True`` is a flag that indicates whether or not the source also applies to all overrides of the field.
280+
- The third value ``True`` is a flag that indicates whether or not the sink also applies to subtypes. For fields this means when the field is accessed as a promoted field in another type.
281281
- The fourth value ``Body`` is the field name.
282282
- The fifth value ``""`` is blank since it is a field access and field accesses do not have method signatures in Go.
283283

0 commit comments

Comments
 (0)