@@ -16,6 +16,7 @@ private import semmle.code.java.security.RequestForgery
1616private import semmle.code.java.dataflow.internal.ModelExclusions as ModelExclusions
1717private import AutomodelSharedUtil as AutomodelSharedUtil
1818private import semmle.code.java.security.PathSanitizer as PathSanitizer
19+ private import AutomodelSharedGetCallable as AutomodelSharedGetCallable
1920import AutomodelSharedCharacteristics as SharedCharacteristics
2021import AutomodelEndpointTypes as AutomodelEndpointTypes
2122
@@ -85,8 +86,8 @@ module ApplicationCandidatesImpl implements SharedCharacteristics::CandidateSig
8586 additional predicate sinkSpec (
8687 Endpoint e , string package , string type , string name , string signature , string ext , string input
8788 ) {
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
9091 ext = "" and
9192 (
9293 exists ( Call c , int argIdx |
@@ -110,13 +111,19 @@ module ApplicationCandidatesImpl implements SharedCharacteristics::CandidateSig
110111 type = CallContext ( ) and
111112 result = any ( Call c | e .asExpr ( ) = [ c .getAnArgument ( ) , c .getQualifier ( ) ] )
112113 }
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 ;
113122
114123 /**
115124 * Returns the API callable being modeled.
116- *
117- * Each Java mode should implement this predicate.
118125 */
119- additional Callable getCallable ( Endpoint e ) {
126+ Callable getCallable ( Endpoint e ) {
120127 exists ( Call c |
121128 e .asExpr ( ) = [ c .getAnArgument ( ) , c .getQualifier ( ) ] and
122129 result = c .getCallee ( )
@@ -209,8 +216,8 @@ private class UnexploitableIsCharacteristic extends CharacteristicsImpl::NotASin
209216
210217 override predicate appliesToEndpoint ( Endpoint e ) {
211218 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
214221 }
215222}
216223
@@ -228,7 +235,7 @@ private class UnexploitableExistsCharacteristic extends CharacteristicsImpl::Not
228235 override predicate appliesToEndpoint ( Endpoint e ) {
229236 not ApplicationCandidatesImpl:: isSink ( e , _) and
230237 exists ( Callable callable |
231- callable = ApplicationCandidatesImpl :: getCallable ( e ) and
238+ callable = ApplicationModeGetCallable :: getCallable ( e ) and
232239 callable .getName ( ) .toLowerCase ( ) = [ "exists" , "notexists" ] and
233240 callable .getReturnType ( ) instanceof BooleanType
234241 )
@@ -242,7 +249,7 @@ private class ExceptionCharacteristic extends CharacteristicsImpl::NotASinkChara
242249 ExceptionCharacteristic ( ) { this = "exception" }
243250
244251 override predicate appliesToEndpoint ( Endpoint e ) {
245- ApplicationCandidatesImpl :: getCallable ( e ) .getDeclaringType ( ) .getASupertype * ( ) instanceof
252+ ApplicationModeGetCallable :: getCallable ( e ) .getDeclaringType ( ) .getASupertype * ( ) instanceof
246253 TypeThrowable
247254 }
248255}
@@ -291,7 +298,7 @@ private class ArgumentToLocalCall extends CharacteristicsImpl::UninterestingToMo
291298 ArgumentToLocalCall ( ) { this = "argument to local call" }
292299
293300 override predicate appliesToEndpoint ( Endpoint e ) {
294- ApplicationCandidatesImpl :: getCallable ( e ) .fromSource ( )
301+ ApplicationModeGetCallable :: getCallable ( e ) .fromSource ( )
295302 }
296303}
297304
@@ -302,7 +309,7 @@ private class ExcludedFromModeling extends CharacteristicsImpl::UninterestingToM
302309 ExcludedFromModeling ( ) { this = "excluded from modeling" }
303310
304311 override predicate appliesToEndpoint ( Endpoint e ) {
305- ModelExclusions:: isUninterestingForModels ( ApplicationCandidatesImpl :: getCallable ( e ) ) or
312+ ModelExclusions:: isUninterestingForModels ( ApplicationModeGetCallable :: getCallable ( e ) ) or
306313 ModelExclusions:: isUninterestingForModels ( e .getEnclosingCallable ( ) )
307314 }
308315}
@@ -316,7 +323,7 @@ private class NonPublicMethodCharacteristic extends CharacteristicsImpl::Uninter
316323 NonPublicMethodCharacteristic ( ) { this = "non-public method" }
317324
318325 override predicate appliesToEndpoint ( Endpoint e ) {
319- not ApplicationCandidatesImpl :: getCallable ( e ) .isPublic ( )
326+ not ApplicationModeGetCallable :: getCallable ( e ) .isPublic ( )
320327 }
321328}
322329
0 commit comments