@@ -23,6 +23,42 @@ newtype JavaRelatedLocationType =
2323 MethodDoc ( ) or
2424 ClassDoc ( )
2525
26+ /**
27+ * A framework mode endpoint.
28+ */
29+ abstract class FrameworkModeEndpoint extends Top {
30+ /**
31+ * Returns the parameter index of the endpoint.
32+ */
33+ abstract int getIndex ( ) ;
34+
35+ /**
36+ * Returns the name of the parameter of the endpoint.
37+ */
38+ abstract string getParamName ( ) ;
39+
40+ /**
41+ * Returns the callable that contains the endpoint.
42+ */
43+ abstract Callable getEnclosingCallable ( ) ;
44+ }
45+
46+ class ParameterEndpoint extends FrameworkModeEndpoint instanceof Parameter {
47+ override int getIndex ( ) { result = this .( Parameter ) .getPosition ( ) }
48+
49+ override string getParamName ( ) { result = this .( Parameter ) .getName ( ) }
50+
51+ override Callable getEnclosingCallable ( ) { result = this .( Parameter ) .getCallable ( ) }
52+ }
53+
54+ class QualifierEndpoint extends FrameworkModeEndpoint instanceof Callable {
55+ override int getIndex ( ) { result = - 1 }
56+
57+ override string getParamName ( ) { result = "this" }
58+
59+ override Callable getEnclosingCallable ( ) { result = this }
60+ }
61+
2662/**
2763 * A candidates implementation for framework mode.
2864 *
@@ -33,7 +69,7 @@ newtype JavaRelatedLocationType =
3369 */
3470module FrameworkCandidatesImpl implements SharedCharacteristics:: CandidateSig {
3571 // for documentation of the implementations here, see the QLDoc in the CandidateSig signature module.
36- class Endpoint = DataFlow :: ParameterNode ;
72+ class Endpoint = FrameworkModeEndpoint ;
3773
3874 class EndpointType = AutomodelEndpointTypes:: EndpointType ;
3975
@@ -46,7 +82,7 @@ module FrameworkCandidatesImpl implements SharedCharacteristics::CandidateSig {
4682 // Sanitizers are currently not modeled in MaD. TODO: check if this has large negative impact.
4783 predicate isSanitizer ( Endpoint e , EndpointType t ) { none ( ) }
4884
49- RelatedLocation asLocation ( Endpoint e ) { result = e . asParameter ( ) }
85+ RelatedLocation asLocation ( Endpoint e ) { result = e }
5086
5187 predicate isKnownKind = AutomodelJavaUtil:: isKnownKind / 2 ;
5288
@@ -70,9 +106,7 @@ module FrameworkCandidatesImpl implements SharedCharacteristics::CandidateSig {
70106 FrameworkModeGetCallable:: getCallable ( e ) .hasQualifiedName ( package , type , name ) and
71107 signature = ExternalFlow:: paramsString ( FrameworkModeGetCallable:: getCallable ( e ) ) and
72108 ext = "" and
73- exists ( int paramIdx | e .isParameterOf ( _, paramIdx ) |
74- input = AutomodelJavaUtil:: getArgumentForIndex ( paramIdx )
75- )
109+ input = AutomodelJavaUtil:: getArgumentForIndex ( e .getIndex ( ) )
76110 }
77111
78112 /**
@@ -124,22 +158,13 @@ class FrameworkModeMetadataExtractor extends string {
124158 Endpoint e , string package , string type , string subtypes , string name , string signature ,
125159 string input , string parameterName
126160 ) {
127- exists ( Callable callable , int paramIdx |
128- (
129- e .( DataFlow:: ExplicitParameterNode ) .asParameter ( ) = callable .getParameter ( paramIdx ) and
130- parameterName = e .asParameter ( ) .getName ( )
131- or
132- e .( DataFlow:: InstanceParameterNode ) .getCallable ( ) = callable and
133- paramIdx = - 1 and
134- parameterName = "this"
135- ) and
136- input = AutomodelJavaUtil:: getArgumentForIndex ( paramIdx ) and
137- package = callable .getDeclaringType ( ) .getPackage ( ) .getName ( ) and
138- type = callable .getDeclaringType ( ) .getErasure ( ) .( RefType ) .nestedName ( ) and
139- subtypes = AutomodelJavaUtil:: considerSubtypes ( callable ) .toString ( ) and
140- name = callable .getName ( ) and
141- signature = ExternalFlow:: paramsString ( callable )
142- )
161+ parameterName = e .getParamName ( ) and
162+ name = e .getEnclosingCallable ( ) .getName ( ) and
163+ input = AutomodelJavaUtil:: getArgumentForIndex ( e .getIndex ( ) ) and
164+ package = e .getEnclosingCallable ( ) .getDeclaringType ( ) .getPackage ( ) .getName ( ) and
165+ type = e .getEnclosingCallable ( ) .getDeclaringType ( ) .getErasure ( ) .( RefType ) .nestedName ( ) and
166+ subtypes = AutomodelJavaUtil:: considerSubtypes ( e .getEnclosingCallable ( ) ) .toString ( ) and
167+ signature = ExternalFlow:: paramsString ( e .getEnclosingCallable ( ) )
143168 }
144169}
145170
@@ -207,7 +232,7 @@ private class NotAModelApiParameter extends CharacteristicsImpl::UninterestingTo
207232 NotAModelApiParameter ( ) { this = "not a model API parameter" }
208233
209234 override predicate appliesToEndpoint ( Endpoint e ) {
210- not exists ( ModelExclusions:: ModelApi api | api .getAParameter ( ) = e . asParameter ( ) )
235+ not exists ( ModelExclusions:: ModelApi api | api .getAParameter ( ) = e )
211236 }
212237}
213238
0 commit comments