@@ -40,10 +40,7 @@ module Twirp {
40
40
*/
41
41
class ProtobufMessageType extends Type {
42
42
ProtobufMessageType ( ) {
43
- exists ( TypeEntity te |
44
- te .getType ( ) = this and
45
- te .getDeclaration ( ) .getLocation ( ) .getFile ( ) instanceof ProtobufGeneratedFile
46
- )
43
+ this .hasLocationInfo ( any ( ProtobufGeneratedFile f ) .getAbsolutePath ( ) , _, _, _, _)
47
44
}
48
45
}
49
46
@@ -54,11 +51,8 @@ module Twirp {
54
51
NamedType namedType ;
55
52
56
53
ServiceInterfaceType ( ) {
57
- exists ( TypeEntity te |
58
- te .getType ( ) = namedType and
59
- namedType .getUnderlyingType ( ) = this and
60
- te .getDeclaration ( ) .getLocation ( ) .getFile ( ) instanceof ServicesGeneratedFile
61
- )
54
+ namedType .getUnderlyingType ( ) = this and
55
+ namedType .hasLocationInfo ( any ( ServicesGeneratedFile f ) .getAbsolutePath ( ) , _, _, _, _)
62
56
}
63
57
64
58
/**
@@ -77,12 +71,11 @@ module Twirp {
77
71
*/
78
72
class ServiceClientType extends NamedType {
79
73
ServiceClientType ( ) {
80
- exists ( ServiceInterfaceType i , PointerType p , TypeEntity te |
74
+ exists ( ServiceInterfaceType i , PointerType p |
81
75
p .implements ( i ) and
82
76
this = p .getBaseType ( ) and
83
77
this .getName ( ) .regexpMatch ( "(?i)" + i .getName ( ) + "(protobuf|json)client" ) and
84
- te .getType ( ) = this and
85
- te .getDeclaration ( ) .getLocation ( ) .getFile ( ) instanceof ServicesGeneratedFile
78
+ this .hasLocationInfo ( any ( ServicesGeneratedFile f ) .getAbsolutePath ( ) , _, _, _, _)
86
79
)
87
80
}
88
81
}
@@ -92,11 +85,10 @@ module Twirp {
92
85
*/
93
86
class ServiceServerType extends NamedType {
94
87
ServiceServerType ( ) {
95
- exists ( ServiceInterfaceType i , TypeEntity te |
88
+ exists ( ServiceInterfaceType i |
96
89
this .implements ( i ) and
97
90
this .getName ( ) .regexpMatch ( "(?i)" + i .getName ( ) + "server" ) and
98
- te .getType ( ) = this and
99
- te .getDeclaration ( ) .getLocation ( ) .getFile ( ) instanceof ServicesGeneratedFile
91
+ this .hasLocationInfo ( any ( ServicesGeneratedFile f ) .getAbsolutePath ( ) , _, _, _, _)
100
92
)
101
93
}
102
94
}
@@ -106,12 +98,10 @@ module Twirp {
106
98
*/
107
99
class ClientConstructor extends Function {
108
100
ClientConstructor ( ) {
109
- exists ( ServiceClientType c |
110
- this .getName ( ) .regexpMatch ( "(?i)new" + c .getName ( ) ) and
111
- this .getParameterType ( 0 ) instanceof StringType and
112
- this .getParameterType ( 1 ) .getName ( ) = "HTTPClient" and
113
- this .getDeclaration ( ) .getLocation ( ) .getFile ( ) instanceof ServicesGeneratedFile
114
- )
101
+ this .getName ( ) .regexpMatch ( "(?i)new" + any ( ServiceClientType c ) .getName ( ) ) and
102
+ this .getParameterType ( 0 ) instanceof StringType and
103
+ this .getParameterType ( 1 ) .getName ( ) = "HTTPClient" and
104
+ this .hasLocationInfo ( any ( ServicesGeneratedFile f ) .getAbsolutePath ( ) , _, _, _, _)
115
105
}
116
106
}
117
107
@@ -122,11 +112,9 @@ module Twirp {
122
112
*/
123
113
class ServerConstructor extends Function {
124
114
ServerConstructor ( ) {
125
- exists ( ServiceServerType c , ServiceInterfaceType i |
126
- this .getName ( ) .regexpMatch ( "(?i)new" + c .getName ( ) ) and
127
- this .getParameterType ( 0 ) = i .getNamedType ( ) and
128
- this .getDeclaration ( ) .getLocation ( ) .getFile ( ) instanceof ServicesGeneratedFile
129
- )
115
+ this .getName ( ) .regexpMatch ( "(?i)new" + any ( ServiceServerType c ) .getName ( ) ) and
116
+ this .getParameterType ( 0 ) = any ( ServiceInterfaceType i ) .getNamedType ( ) and
117
+ this .hasLocationInfo ( any ( ServicesGeneratedFile f ) .getAbsolutePath ( ) , _, _, _, _)
130
118
}
131
119
}
132
120
@@ -151,11 +139,10 @@ module Twirp {
151
139
*/
152
140
class ServiceHandler extends Method {
153
141
ServiceHandler ( ) {
154
- exists ( DataFlow:: CallNode call , Type handlerType , ServiceInterfaceType i |
142
+ exists ( DataFlow:: CallNode call |
155
143
call .getTarget ( ) instanceof ServerConstructor and
156
- call .getArgument ( 0 ) .getType ( ) = handlerType and
157
- this = handlerType .getMethod ( _) and
158
- this .implements ( i .getNamedType ( ) .getMethod ( _) )
144
+ this = call .getArgument ( 0 ) .getType ( ) .getMethod ( _) and
145
+ this .implements ( any ( ServiceInterfaceType i ) .getNamedType ( ) .getMethod ( _) )
159
146
)
160
147
}
161
148
}
@@ -165,8 +152,8 @@ module Twirp {
165
152
*/
166
153
class Request extends UntrustedFlowSource:: Range instanceof DataFlow:: ParameterNode {
167
154
Request ( ) {
168
- exists ( FuncDef c , ServiceHandler handler | handler . getFuncDecl ( ) = c |
169
- this .asParameter ( ) .isParameterOf ( c , 1 ) and
155
+ exists ( ServiceHandler handler |
156
+ this .asParameter ( ) .isParameterOf ( handler . getFuncDecl ( ) , 1 ) and
170
157
handler .getParameterType ( 0 ) .hasQualifiedName ( "context" , "Context" ) and
171
158
this .getType ( ) .( PointerType ) .getBaseType ( ) instanceof ProtobufMessageType
172
159
)
0 commit comments