@@ -40,10 +40,7 @@ module Twirp {
4040 */
4141 class ProtobufMessageType extends Type {
4242 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 ( ) , _, _, _, _)
4744 }
4845 }
4946
@@ -54,11 +51,8 @@ module Twirp {
5451 NamedType namedType ;
5552
5653 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 ( ) , _, _, _, _)
6256 }
6357
6458 /**
@@ -77,12 +71,11 @@ module Twirp {
7771 */
7872 class ServiceClientType extends NamedType {
7973 ServiceClientType ( ) {
80- exists ( ServiceInterfaceType i , PointerType p , TypeEntity te |
74+ exists ( ServiceInterfaceType i , PointerType p |
8175 p .implements ( i ) and
8276 this = p .getBaseType ( ) and
8377 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 ( ) , _, _, _, _)
8679 )
8780 }
8881 }
@@ -92,11 +85,10 @@ module Twirp {
9285 */
9386 class ServiceServerType extends NamedType {
9487 ServiceServerType ( ) {
95- exists ( ServiceInterfaceType i , TypeEntity te |
88+ exists ( ServiceInterfaceType i |
9689 this .implements ( i ) and
9790 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 ( ) , _, _, _, _)
10092 )
10193 }
10294 }
@@ -106,12 +98,10 @@ module Twirp {
10698 */
10799 class ClientConstructor extends Function {
108100 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 ( ) , _, _, _, _)
115105 }
116106 }
117107
@@ -122,11 +112,9 @@ module Twirp {
122112 */
123113 class ServerConstructor extends Function {
124114 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 ( ) , _, _, _, _)
130118 }
131119 }
132120
@@ -151,11 +139,10 @@ module Twirp {
151139 */
152140 class ServiceHandler extends Method {
153141 ServiceHandler ( ) {
154- exists ( DataFlow:: CallNode call , Type handlerType , ServiceInterfaceType i |
142+ exists ( DataFlow:: CallNode call |
155143 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 ( _) )
159146 )
160147 }
161148 }
@@ -165,8 +152,8 @@ module Twirp {
165152 */
166153 class Request extends UntrustedFlowSource:: Range instanceof DataFlow:: ParameterNode {
167154 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
170157 handler .getParameterType ( 0 ) .hasQualifiedName ( "context" , "Context" ) and
171158 this .getType ( ) .( PointerType ) .getBaseType ( ) instanceof ProtobufMessageType
172159 )
0 commit comments