@@ -16,6 +16,7 @@ private import semmle.code.java.security.RequestForgery
16
16
private import semmle.code.java.dataflow.internal.ModelExclusions as ModelExclusions
17
17
private import AutomodelSharedUtil as AutomodelSharedUtil
18
18
private import semmle.code.java.security.PathSanitizer as PathSanitizer
19
+ private import AutomodelSharedGetCallable as AutomodelSharedGetCallable
19
20
import AutomodelSharedCharacteristics as SharedCharacteristics
20
21
import AutomodelEndpointTypes as AutomodelEndpointTypes
21
22
@@ -85,8 +86,8 @@ module ApplicationCandidatesImpl implements SharedCharacteristics::CandidateSig
85
86
additional predicate sinkSpec (
86
87
Endpoint e , string package , string type , string name , string signature , string ext , string input
87
88
) {
88
- ApplicationCandidatesImpl :: getCallable ( e ) .hasQualifiedName ( package , type , name ) and
89
- signature = ExternalFlow:: paramsString ( getCallable ( e ) ) and
89
+ ApplicationModeGetCallable :: getCallable ( e ) .hasQualifiedName ( package , type , name ) and
90
+ signature = ExternalFlow:: paramsString ( ApplicationModeGetCallable :: getCallable ( e ) ) and
90
91
ext = "" and
91
92
(
92
93
exists ( Call c , int argIdx |
@@ -110,13 +111,19 @@ module ApplicationCandidatesImpl implements SharedCharacteristics::CandidateSig
110
111
type = CallContext ( ) and
111
112
result = any ( Call c | e .asExpr ( ) = [ c .getAnArgument ( ) , c .getQualifier ( ) ] )
112
113
}
114
+ }
115
+
116
+ private class JavaCallable = Callable ;
117
+
118
+ private module ApplicationModeGetCallable implements AutomodelSharedGetCallable:: GetCallableSig {
119
+ class Callable = JavaCallable ;
120
+
121
+ class Endpoint = ApplicationCandidatesImpl:: Endpoint ;
113
122
114
123
/**
115
124
* Returns the API callable being modeled.
116
- *
117
- * Each Java mode should implement this predicate.
118
125
*/
119
- additional Callable getCallable ( Endpoint e ) {
126
+ Callable getCallable ( Endpoint e ) {
120
127
exists ( Call c |
121
128
e .asExpr ( ) = [ c .getAnArgument ( ) , c .getQualifier ( ) ] and
122
129
result = c .getCallee ( )
@@ -209,8 +216,8 @@ private class UnexploitableIsCharacteristic extends CharacteristicsImpl::NotASin
209
216
210
217
override predicate appliesToEndpoint ( Endpoint e ) {
211
218
not ApplicationCandidatesImpl:: isSink ( e , _) and
212
- ApplicationCandidatesImpl :: getCallable ( e ) .getName ( ) .matches ( "is%" ) and
213
- ApplicationCandidatesImpl :: getCallable ( e ) .getReturnType ( ) instanceof BooleanType
219
+ ApplicationModeGetCallable :: getCallable ( e ) .getName ( ) .matches ( "is%" ) and
220
+ ApplicationModeGetCallable :: getCallable ( e ) .getReturnType ( ) instanceof BooleanType
214
221
}
215
222
}
216
223
@@ -228,7 +235,7 @@ private class UnexploitableExistsCharacteristic extends CharacteristicsImpl::Not
228
235
override predicate appliesToEndpoint ( Endpoint e ) {
229
236
not ApplicationCandidatesImpl:: isSink ( e , _) and
230
237
exists ( Callable callable |
231
- callable = ApplicationCandidatesImpl :: getCallable ( e ) and
238
+ callable = ApplicationModeGetCallable :: getCallable ( e ) and
232
239
callable .getName ( ) .toLowerCase ( ) = [ "exists" , "notexists" ] and
233
240
callable .getReturnType ( ) instanceof BooleanType
234
241
)
@@ -242,7 +249,7 @@ private class ExceptionCharacteristic extends CharacteristicsImpl::NotASinkChara
242
249
ExceptionCharacteristic ( ) { this = "exception" }
243
250
244
251
override predicate appliesToEndpoint ( Endpoint e ) {
245
- ApplicationCandidatesImpl :: getCallable ( e ) .getDeclaringType ( ) .getASupertype * ( ) instanceof
252
+ ApplicationModeGetCallable :: getCallable ( e ) .getDeclaringType ( ) .getASupertype * ( ) instanceof
246
253
TypeThrowable
247
254
}
248
255
}
@@ -291,7 +298,7 @@ private class ArgumentToLocalCall extends CharacteristicsImpl::UninterestingToMo
291
298
ArgumentToLocalCall ( ) { this = "argument to local call" }
292
299
293
300
override predicate appliesToEndpoint ( Endpoint e ) {
294
- ApplicationCandidatesImpl :: getCallable ( e ) .fromSource ( )
301
+ ApplicationModeGetCallable :: getCallable ( e ) .fromSource ( )
295
302
}
296
303
}
297
304
@@ -302,7 +309,7 @@ private class ExcludedFromModeling extends CharacteristicsImpl::UninterestingToM
302
309
ExcludedFromModeling ( ) { this = "excluded from modeling" }
303
310
304
311
override predicate appliesToEndpoint ( Endpoint e ) {
305
- ModelExclusions:: isUninterestingForModels ( ApplicationCandidatesImpl :: getCallable ( e ) ) or
312
+ ModelExclusions:: isUninterestingForModels ( ApplicationModeGetCallable :: getCallable ( e ) ) or
306
313
ModelExclusions:: isUninterestingForModels ( e .getEnclosingCallable ( ) )
307
314
}
308
315
}
@@ -316,7 +323,7 @@ private class NonPublicMethodCharacteristic extends CharacteristicsImpl::Uninter
316
323
NonPublicMethodCharacteristic ( ) { this = "non-public method" }
317
324
318
325
override predicate appliesToEndpoint ( Endpoint e ) {
319
- not ApplicationCandidatesImpl :: getCallable ( e ) .isPublic ( )
326
+ not ApplicationModeGetCallable :: getCallable ( e ) .isPublic ( )
320
327
}
321
328
}
322
329
0 commit comments