11import go
22import semmle.go.frameworks.Twirp
3+ import semmle.go.security.RequestForgery //.dataflow.ReflectedXssQuery as XssConfig
34
45class InlineTest extends LineComment {
56 string tests ;
@@ -49,22 +50,27 @@ query predicate passingPositiveTests(string res, string expectation, InlineTest
4950 exists ( RequestForgery:: Sink n | t .inNode ( n ) )
5051 or
5152 expectation = "message" and
52- exists ( Twirp:: ProtobufMessage n | t .inType ( n ) )
53+ exists ( Twirp:: ProtobufMessageType n | t .inType ( n ) )
5354 or
5455 expectation = "serviceInterface" and
55- exists ( Twirp:: ServiceInterface n | t .inType ( n .getNamedType ( ) ) )
56+ exists ( Twirp:: ServiceInterfaceType n | t .inType ( n .getNamedType ( ) ) )
5657 or
5758 expectation = "serviceClient" and
58- exists ( Twirp:: ServiceClient n | t .inType ( n ) )
59+ exists ( Twirp:: ServiceClientType n | t .inType ( n ) )
5960 or
6061 expectation = "serviceServer" and
61- exists ( Twirp:: ServiceServer n | t .inType ( n ) )
62+ exists ( Twirp:: ServiceServerType n | t .inType ( n ) )
6263 or
6364 expectation = "clientConstructor" and
6465 exists ( Twirp:: ClientConstructor n | t .inEntity ( n ) )
6566 or
6667 expectation = "serverConstructor" and
6768 exists ( Twirp:: ServerConstructor n | t .inEntity ( n ) )
69+ or
70+ expectation = "ssrf" and
71+ exists ( RequestForgery:: Configuration cfg , DataFlow:: Node sink |
72+ cfg .hasFlow ( _, sink ) and t .inNode ( sink )
73+ )
6874 )
6975}
7076
@@ -82,22 +88,27 @@ query predicate failingPositiveTests(string res, string expectation, InlineTest
8288 not exists ( RequestForgery:: Sink n | t .inNode ( n ) )
8389 or
8490 expectation = "message" and
85- not exists ( Twirp:: ProtobufMessage n | t .inType ( n ) )
91+ not exists ( Twirp:: ProtobufMessageType n | t .inType ( n ) )
8692 or
8793 expectation = "serviceInterface" and
88- not exists ( Twirp:: ServiceInterface n | t .inType ( n .getNamedType ( ) ) )
94+ not exists ( Twirp:: ServiceInterfaceType n | t .inType ( n .getNamedType ( ) ) )
8995 or
9096 expectation = "serviceClient" and
91- not exists ( Twirp:: ServiceClient n | t .inType ( n ) )
97+ not exists ( Twirp:: ServiceClientType n | t .inType ( n ) )
9298 or
9399 expectation = "serviceServer" and
94- not exists ( Twirp:: ServiceServer n | t .inType ( n ) )
100+ not exists ( Twirp:: ServiceServerType n | t .inType ( n ) )
95101 or
96102 expectation = "clientConstructor" and
97103 not exists ( Twirp:: ClientConstructor n | t .inEntity ( n ) )
98104 or
99105 expectation = "serverConstructor" and
100106 not exists ( Twirp:: ServerConstructor n | t .inEntity ( n ) )
107+ or
108+ expectation = "ssrf" and
109+ not exists ( RequestForgery:: Configuration cfg , DataFlow:: Node sink |
110+ cfg .hasFlow ( _, sink ) and t .inNode ( sink )
111+ )
101112 )
102113}
103114
@@ -115,22 +126,27 @@ query predicate passingNegativeTests(string res, string expectation, InlineTest
115126 not exists ( RequestForgery:: Sink n | t .inNode ( n ) )
116127 or
117128 expectation = "!message" and
118- not exists ( Twirp:: ProtobufMessage n | t .inType ( n ) )
129+ not exists ( Twirp:: ProtobufMessageType n | t .inType ( n ) )
119130 or
120131 expectation = "!serviceInterface" and
121- not exists ( Twirp:: ServiceInterface n | t .inType ( n ) )
132+ not exists ( Twirp:: ServiceInterfaceType n | t .inType ( n ) )
122133 or
123134 expectation = "!serviceClient" and
124- not exists ( Twirp:: ServiceClient n | t .inType ( n ) )
135+ not exists ( Twirp:: ServiceClientType n | t .inType ( n ) )
125136 or
126137 expectation = "!serviceServer" and
127- not exists ( Twirp:: ServiceServer n | t .inType ( n ) )
138+ not exists ( Twirp:: ServiceServerType n | t .inType ( n ) )
128139 or
129140 expectation = "!clientConstructor" and
130141 not exists ( Twirp:: ClientConstructor n | t .inEntity ( n ) )
131142 or
132143 expectation = "!serverConstructor" and
133144 not exists ( Twirp:: ServerConstructor n | t .inEntity ( n ) )
145+ or
146+ expectation = "!ssrf" and
147+ not exists ( RequestForgery:: Configuration cfg , DataFlow:: Node sink |
148+ cfg .hasFlow ( _, sink ) and t .inNode ( sink )
149+ )
134150 )
135151}
136152
@@ -148,21 +164,26 @@ query predicate failingNegativeTests(string res, string expectation, InlineTest
148164 exists ( RequestForgery:: Sink n | t .inNode ( n ) )
149165 or
150166 expectation = "!message" and
151- exists ( Twirp:: ProtobufMessage n | t .inType ( n ) )
167+ exists ( Twirp:: ProtobufMessageType n | t .inType ( n ) )
152168 or
153169 expectation = "!serviceInterface" and
154- exists ( Twirp:: ServiceInterface n | t .inType ( n ) )
170+ exists ( Twirp:: ServiceInterfaceType n | t .inType ( n ) )
155171 or
156172 expectation = "!serviceClient" and
157- exists ( Twirp:: ServiceClient n | t .inType ( n ) )
173+ exists ( Twirp:: ServiceClientType n | t .inType ( n ) )
158174 or
159175 expectation = "!serviceServer" and
160- exists ( Twirp:: ServiceServer n | t .inType ( n ) )
176+ exists ( Twirp:: ServiceServerType n | t .inType ( n ) )
161177 or
162178 expectation = "!clientConstructor" and
163179 exists ( Twirp:: ClientConstructor n | t .inEntity ( n ) )
164180 or
165181 expectation = "!serverConstructor" and
166182 exists ( Twirp:: ServerConstructor n | t .inEntity ( n ) )
183+ or
184+ expectation = "!ssrf" and
185+ exists ( RequestForgery:: Configuration cfg , DataFlow:: Node sink |
186+ cfg .hasFlow ( _, sink ) and t .inNode ( sink )
187+ )
167188 )
168189}
0 commit comments