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
InputStream stream = socket.getInputStream();// The return value of this method is a remote source.
90
90
return stream;
91
91
}
92
92
@@ -119,9 +119,108 @@ The remaining values are used to define the **access path**, the **kind**, and t
119
119
- The eighth value **remote** is the kind of the source. The source kind is used to define for which queries the source is in scope. **remote** applies to many of security related queries as it means a remote source of untrusted data. As an example the SQL injection query uses **remote** sources.
120
120
- The ninth value **manual** is the provenance of the source, which is used to identify the origin of the source.
121
121
122
-
Example: Adding flow through '<TODO>' methods.
123
-
----------------------------------------------
122
+
Example: Adding flow through the **concat** method.
Since we are adding flow through a method, we need to add tuples to the **summaryModel** extension point.
151
+
Each tuple defines flow from one argument to the return value.
152
+
The first five values are used to identify the method (callable) which we are defining a source on.
153
+
These are the same for both of the rows above.
154
+
155
+
- The first value **java.lang** is the package name.
156
+
- The second value **String** is the class (type) name.
157
+
- The third value **False** is flag indicating, whether the source also applies to all overrides of the method.
158
+
- The fourth value **concat** is the method name.
159
+
- The fifth value **(String)** is the method input type signature.
160
+
161
+
For most practical purposes the sixth value is not relevant.
162
+
The remaining values are used to define the **access path**, the **kind**, and the **provenance** (origin) of the source.
163
+
164
+
- The seventh value is the access path to the input where data flows from. **Argument[-1]** is the access path to the qualifier (**s1** in the example) and **Argument[0]** is the access path to the first argument (**s2** in the example).
165
+
- The eighth value **ReturnValue** is the access path to the output where data flows too, in this case **ReturnValue**, which means that the input flows to the return value.
166
+
- The ninth value **taint** is the kind of the flow. **taint** means that taint is propagated through the flow.
167
+
- The tenth value **manual** is the provenance of the source, which is used to identify the origin of the summary.
168
+
169
+
Example: Add flow through the **map** method.
170
+
---------------------------------------------
171
+
In this example will will see a more complex example of modelling flow through a method.
172
+
This pattern shows how to model flow through higher order methods and collection types.
173
+
Please note that the flow through the **map** method is already added to the CodeQL Java analysis.
Since we are adding flow through a method, we need to add tuples to the **summaryModel** extension point.
197
+
Each tuple defines part of the flow that comprises the total flow through the method.
198
+
The first five values are used to identify the method (callable) which we are defining a source on.
199
+
These are the same for both of the rows above.
200
+
201
+
- The first value **java.util.stream** is the package name.
202
+
- The second value **Stream** is the class (type) name.
203
+
- The third value **True** is flag indicating, whether the source also applies to all overrides of the method.
204
+
- The fourth value **map** is the method name.
205
+
- The fifth value **Function** is the method input type signature.
206
+
207
+
For most practical purposes the sixth value is not relevant.
208
+
The remaining values are used to define the **access path**, the **kind**, and the **provenance** (origin) of the source.
209
+
- The seventh value is the access path to the **input** where data flows from.
210
+
- The eighth value **ReturnValue** is the access path to the **output** where data flows too.
211
+
212
+
For the first row the
213
+
- The seventh value is **Argument[-1].Element**, which is the access path to the elements of the qualifier (the elements of the stream **s** in the example).
214
+
- The eight value is **Argument[0].Paramter[0]**, which is the access path the first parameter of the **Function** argument of **map** (the lambda parameter **e** in the example).
215
+
216
+
For the second row the
217
+
- The seventh value is **Argument[0].ReturnValue**, which is the access path to the return value of the **Function** argument of **map** (the return value of the lambda in the example).
218
+
- The eighth value is **ReturnValue.Element**, which is the access path to the elements of the return value of **map** (the elements of the stream **l** in the example).
219
+
220
+
- The ninth value **value** is the kind of the flow. **value** means that the value is propagated.
221
+
- The tenth value **manual** is the provenance of the source, which is used to identify the origin of the summary.
222
+
223
+
That is, the first row models that there is value flow from the elements of qualifier stream into the first argument of the Function provided to **map** and the second row models that there is value flow from the return value of the Function to the elements of the stream returned from **map**.
0 commit comments