@@ -22,31 +22,32 @@ The pack name is `codeql/cpp-all`.
2222
2323#### Extensible predicates
2424
25- | Predicate | Columns | Purpose |
26- | ---| ---| ---|
27- | ` sourceModel ` | ` (namespace, type, subtypes, name, signature, ext, output, kind, provenance) ` | Model sources of tainted data |
28- | ` sinkModel ` | ` (namespace, type, subtypes, name, signature, ext, input, kind, provenance) ` | Model sinks |
29- | ` summaryModel ` | ` (namespace, type, subtypes, name, signature, ext, input, output, kind, provenance) ` | Model flow through functions |
30- | ` barrierModel ` | ` (namespace, type, subtypes, name, signature, ext, output, kind, provenance) ` | Model barriers (sanitizers) that stop taint flow |
25+ | Predicate | Columns | Purpose |
26+ | ------------------- | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
27+ | ` sourceModel ` | ` (namespace, type, subtypes, name, signature, ext, output, kind, provenance) ` | Model sources of tainted data |
28+ | ` sinkModel ` | ` (namespace, type, subtypes, name, signature, ext, input, kind, provenance) ` | Model sinks |
29+ | ` summaryModel ` | ` (namespace, type, subtypes, name, signature, ext, input, output, kind, provenance) ` | Model flow through functions |
30+ | ` barrierModel ` | ` (namespace, type, subtypes, name, signature, ext, output, kind, provenance) ` | Model barriers (sanitizers) that stop taint flow |
3131| ` barrierGuardModel ` | ` (namespace, type, subtypes, name, signature, ext, input, acceptingValue, kind, provenance) ` | Model barrier guards (validators) that stop taint via conditional checks |
3232
3333** Note:** C/C++ does ** not** currently support ` neutralModel ` .
3434
3535#### Tuple column reference
3636
37- | Column | Description | Example |
38- | ---| ---| ---|
39- | ` namespace ` | C++ namespace (use ` "" ` for global namespace) | ` "boost::asio" ` , ` "" ` |
40- | ` type ` | Class name (use ` "" ` for free functions) | ` "" ` , ` "Socket" ` |
41- | ` subtypes ` | Whether model applies to overrides (` True ` /` False ` ). Use ` False ` for free functions. | ` False ` |
42- | ` name ` | Function or method name | ` "read_until" ` , ` "write" ` |
43- | ` signature ` | Can narrow between overloaded functions. Use ` "" ` to match all overloads. | ` "" ` |
44- | ` ext ` | Leave empty (` "" ` ) | ` "" ` |
45- | ` input ` /` output ` | Access path (supports pointer indirection via ` * ` ) | ` "Argument[*1]" ` , ` "ReturnValue" ` |
46- | ` kind ` | Source/sink/summary kind | ` "remote" ` , ` "remote-sink" ` |
47- | ` provenance ` | Origin of the model | ` "manual" ` |
37+ | Column | Description | Example |
38+ | ---------------- | ------------------------------------------------------------------------------------ | --------------------------------- |
39+ | ` namespace ` | C++ namespace (use ` "" ` for global namespace) | ` "boost::asio" ` , ` "" ` |
40+ | ` type ` | Class name (use ` "" ` for free functions) | ` "" ` , ` "Socket" ` |
41+ | ` subtypes ` | Whether model applies to overrides (` True ` /` False ` ). Use ` False ` for free functions. | ` False ` |
42+ | ` name ` | Function or method name | ` "read_until" ` , ` "write" ` |
43+ | ` signature ` | Can narrow between overloaded functions. Use ` "" ` to match all overloads. | ` "" ` |
44+ | ` ext ` | Leave empty (` "" ` ) | ` "" ` |
45+ | ` input ` /` output ` | Access path (supports pointer indirection via ` * ` ) | ` "Argument[*1]" ` , ` "ReturnValue" ` |
46+ | ` kind ` | Source/sink/summary kind | ` "remote" ` , ` "remote-sink" ` |
47+ | ` provenance ` | Origin of the model | ` "manual" ` |
4848
4949#### Important: C/C++-specific rules
50+
5051- ** Pointer indirection** : Use the ` * ` prefix on argument indices to dereference pointers. ` Argument[*1] ` means "the pointed-to value of the second argument."
5152- ** Free functions** have ` type ` = ` "" ` and ` subtypes ` = ` False `
5253- ** Namespace nesting** : Use ` :: ` separator (e.g., ` "boost::asio" ` )
@@ -55,12 +56,12 @@ The pack name is `codeql/cpp-all`.
5556
5657### Access Paths
5758
58- | Component | Description |
59- | ---| ---|
60- | ` Argument[n] ` | Argument at index n (0-based, the value itself) |
61- | ` Argument[*n] ` | First indirection (pointed-to value) of argument n |
62- | ` ReturnValue ` | Return value of the function |
63- | ` ReturnValue[*] ` | Pointed-to value of the return value |
59+ | Component | Description |
60+ | ---------------- | -------------------------------------------------- |
61+ | ` Argument[n] ` | Argument at index n (0-based, the value itself) |
62+ | ` Argument[*n] ` | First indirection (pointed-to value) of argument n |
63+ | ` ReturnValue ` | Return value of the function |
64+ | ` ReturnValue[*] ` | Pointed-to value of the return value |
6465
6566### Sink Kinds
6667
@@ -87,7 +88,7 @@ extensions:
8788 pack: codeql/cpp-all
8889 extensible: sinkModel
8990 data:
90- - [" boost::asio", "" , False, " write", "", "", " Argument[*1]", " remote-sink", " manual" ]
91+ - [' boost::asio', '' , False, ' write', '', '', ' Argument[*1]', ' remote-sink', ' manual' ]
9192
9293 - addsTo:
9394 pack: codeql/cpp-all
@@ -113,7 +114,7 @@ extensions:
113114 pack : codeql/cpp-all
114115 extensible : sourceModel
115116 data :
116- - [" boost::asio", "" , False, " read_until", "", "", " Argument[*1]", " remote", " manual" ]
117+ - [' boost::asio', '' , False, ' read_until', '', '', ' Argument[*1]', ' remote', ' manual' ]
117118` ` `
118119
119120Note: ` Argument[*1]` means the **pointed-to value** of the second argument (the buffer being filled with network data).
@@ -126,7 +127,18 @@ extensions:
126127 pack: codeql/cpp-all
127128 extensible: summaryModel
128129 data:
129- - ["boost::asio", "", False, "buffer", "", "", "Argument[*0]", "ReturnValue", "taint", "manual"]
130+ - [
131+ 'boost::asio',
132+ '',
133+ False,
134+ 'buffer',
135+ '',
136+ '',
137+ 'Argument[*0]',
138+ 'ReturnValue',
139+ 'taint',
140+ 'manual'
141+ ]
130142` ` `
131143
132144# ## Example: Taint Barrier Using `mysql_real_escape_string`
@@ -144,7 +156,17 @@ extensions:
144156 pack: codeql/cpp-all
145157 extensible: barrierModel
146158 data:
147- - ["", "", False, "mysql_real_escape_string", "", "", "Argument[*1]", "sql-injection", "manual"]
159+ - [
160+ '',
161+ '',
162+ False,
163+ 'mysql_real_escape_string',
164+ '',
165+ '',
166+ 'Argument[*1]',
167+ 'sql-injection',
168+ 'manual'
169+ ]
148170` ` `
149171
150172Note : ` Argument[*1]` means the **pointed-to value** of the second argument — the output buffer that receives the escaped string. The `kind` `"sql-injection"` must match the sink kind used by SQL injection queries.
@@ -165,20 +187,21 @@ extensions:
165187 pack: codeql/cpp-all
166188 extensible: barrierGuardModel
167189 data:
168- - ["", "" , False, " is_safe", "", "", " Argument[*0]", " true", " sql-injection", " manual" ]
190+ - ['', '' , False, ' is_safe', '', '', ' Argument[*0]', ' true', ' sql-injection', ' manual' ]
169191` ` `
170192
171193Note : The `acceptingValue` `"true"` means the barrier applies when `is_safe` returns true. The `input` `"Argument[*0]"` identifies the value being validated (the pointed-to value of the first argument).
172194
173195# ## Key Differences from Other Languages
174196
175- | Aspect | C/C++ | Java/C#/Go |
176- |---| ---| ---|
177- | Pack name | `codeql/cpp-all` | `codeql/java-all`, etc. |
178- | Identifier column 1 | `namespace` (C++ namespace) | `package`/`namespace` |
179- | Pointer indirection | `Argument[*n]` for dereferenced pointers | Not applicable |
180- | `neutralModel` | Not supported | Supported |
181- | Receiver access | Not applicable (C++ uses `Argument[this]` if modeled) | `Argument[this]` / `Argument[receiver]` |
197+ | Aspect | C/C++ | Java/C#/Go |
198+ | ------------------- | ----------------------------------------------------- | --------------------------------------- |
199+ | Pack name | `codeql/cpp-all` | `codeql/java-all`, etc. |
200+ | Identifier column 1 | `namespace` (C++ namespace) | `package`/`namespace` |
201+ | Pointer indirection | `Argument[*n]` for dereferenced pointers | Not applicable |
202+ | `neutralModel` | Not supported | Supported |
203+ | Receiver access | Not applicable (C++ uses `Argument[this]` if modeled) | `Argument[this]` / `Argument[receiver]` |
182204
183205# ## Additional References
206+
184207- **[C/C++ Reference](./cpp_query_development.prompt.md)** - C/C++ query development
0 commit comments