@@ -135,18 +135,22 @@ Expr getAValueForProp(ObjectCreation create, Assignment a, string prop) {
135
135
predicate isPropertySet ( ObjectCreation oc , string prop ) { exists ( getAValueForProp ( oc , _, prop ) ) }
136
136
137
137
/**
138
+ * DEPRECATED: Use `OnAppendCookieSecureTracking` instead.
139
+ *
138
140
* Tracks if a callback used in `OnAppendCookie` sets `Secure` to `true`.
139
141
*/
140
- class OnAppendCookieSecureTrackingConfig extends OnAppendCookieTrackingConfig {
142
+ deprecated class OnAppendCookieSecureTrackingConfig extends OnAppendCookieTrackingConfig {
141
143
OnAppendCookieSecureTrackingConfig ( ) { this = "OnAppendCookieSecureTrackingConfig" }
142
144
143
145
override string propertyName ( ) { result = "Secure" }
144
146
}
145
147
146
148
/**
149
+ * DEPRECATED: Use `OnAppendCookieHttpOnlyTracking` instead.
150
+ *
147
151
* Tracks if a callback used in `OnAppendCookie` sets `HttpOnly` to `true`.
148
152
*/
149
- class OnAppendCookieHttpOnlyTrackingConfig extends OnAppendCookieTrackingConfig {
153
+ deprecated class OnAppendCookieHttpOnlyTrackingConfig extends OnAppendCookieTrackingConfig {
150
154
OnAppendCookieHttpOnlyTrackingConfig ( ) { this = "OnAppendCookieHttpOnlyTrackingConfig" }
151
155
152
156
override string propertyName ( ) { result = "HttpOnly" }
@@ -206,3 +210,83 @@ abstract private class OnAppendCookieTrackingConfig extends DataFlow::Configurat
206
210
)
207
211
}
208
212
}
213
+
214
+ private signature string propertyName ( ) ;
215
+
216
+ /**
217
+ * Configuration for tracking if a callback used in `OnAppendCookie` sets a cookie property to `true`.
218
+ */
219
+ private module OnAppendCookieTrackingConfig< propertyName / 0 getPropertyName> implements
220
+ DataFlow:: ConfigSig
221
+ {
222
+ /**
223
+ * Specifies the cookie property name to track.
224
+ */
225
+ predicate isSource ( DataFlow:: Node source ) {
226
+ exists ( PropertyWrite pw , Assignment delegateAssign , Callable c |
227
+ pw .getProperty ( ) .getName ( ) = "OnAppendCookie" and
228
+ pw .getProperty ( ) .getDeclaringType ( ) instanceof MicrosoftAspNetCoreBuilderCookiePolicyOptions and
229
+ delegateAssign .getLValue ( ) = pw and
230
+ (
231
+ exists ( LambdaExpr lambda |
232
+ delegateAssign .getRValue ( ) = lambda and
233
+ lambda = c
234
+ )
235
+ or
236
+ exists ( DelegateCreation delegate |
237
+ delegateAssign .getRValue ( ) = delegate and
238
+ delegate .getArgument ( ) .( CallableAccess ) .getTarget ( ) = c
239
+ )
240
+ ) and
241
+ c .getParameter ( 0 ) = source .asParameter ( )
242
+ )
243
+ }
244
+
245
+ predicate isSink ( DataFlow:: Node sink ) {
246
+ exists ( PropertyWrite pw , Assignment a |
247
+ pw .getProperty ( ) .getDeclaringType ( ) instanceof MicrosoftAspNetCoreHttpCookieOptions and
248
+ pw .getProperty ( ) .getName ( ) = getPropertyName ( ) and
249
+ a .getLValue ( ) = pw and
250
+ exists ( Expr val |
251
+ DataFlow:: localExprFlow ( val , a .getRValue ( ) ) and
252
+ val .getValue ( ) = "true"
253
+ ) and
254
+ sink .asExpr ( ) = pw .getQualifier ( )
255
+ )
256
+ }
257
+
258
+ predicate isAdditionalFlowStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
259
+ node2 .asExpr ( ) =
260
+ any ( PropertyRead pr |
261
+ pr .getQualifier ( ) = node1 .asExpr ( ) and
262
+ pr .getProperty ( ) .getDeclaringType ( ) instanceof
263
+ MicrosoftAspNetCoreCookiePolicyAppendCookieContext
264
+ )
265
+ }
266
+ }
267
+
268
+ private string getPropertyNameSecure ( ) { result = "Secure" }
269
+
270
+ /**
271
+ * Configuration module for tracking if a callback used in `OnAppendCookie` sets `Secure` to `true`.
272
+ */
273
+ private module OnAppendCookieSecureTrackingConfig =
274
+ OnAppendCookieTrackingConfig< getPropertyNameSecure / 0 > ;
275
+
276
+ /**
277
+ * Tracks if a callback used in `OnAppendCookie` sets `Secure` to `true`.
278
+ */
279
+ module OnAppendCookieSecureTracking = DataFlow:: Global< OnAppendCookieSecureTrackingConfig > ;
280
+
281
+ private string getPropertyNameHttpOnly ( ) { result = "HttpOnly" }
282
+
283
+ /**
284
+ * Configuration module for tracking if a callback used in `OnAppendCookie` sets `HttpOnly` to `true`.
285
+ */
286
+ private module OnAppendCookieHttpOnlyTrackingConfig =
287
+ OnAppendCookieTrackingConfig< getPropertyNameHttpOnly / 0 > ;
288
+
289
+ /**
290
+ * Tracks if a callback used in `OnAppendCookie` sets `HttpOnly` to `true`.
291
+ */
292
+ module OnAppendCookieHttpOnlyTracking = DataFlow:: Global< OnAppendCookieHttpOnlyTrackingConfig > ;
0 commit comments