3
3
*/
4
4
5
5
import go
6
+ private import semmle.go.security.RequestForgeryCustomizations
6
7
7
8
/**
8
9
* Module for Go-Micro framework.
@@ -15,6 +16,13 @@ module GoMicro {
15
16
GoMicroServerType ( ) { this .hasQualifiedName ( "go-micro.dev/v4/server" , "Server" ) }
16
17
}
17
18
19
+ /**
20
+ * A GoMicro client type.
21
+ */
22
+ class GoMicroClientType extends Type {
23
+ GoMicroClientType ( ) { this .hasQualifiedName ( "go-micro.dev/v4/client" , "Client" ) }
24
+ }
25
+
18
26
/**
19
27
* A file that is generated by the protobuf compiler.
20
28
*/
@@ -84,6 +92,20 @@ module GoMicro {
84
92
}
85
93
}
86
94
95
+ /**
96
+ * A Client server handler type.
97
+ */
98
+ class ClientServiceType extends NamedType {
99
+ ClientServiceType ( ) {
100
+ exists ( ServiceInterfaceType i , TypeEntity te |
101
+ this .implements ( i ) and
102
+ this .getName ( ) .regexpMatch ( "(?i).*Service" ) and
103
+ te .getType ( ) = this and
104
+ te .getDeclaration ( ) .getLocation ( ) .getFile ( ) instanceof ProtocGeneratedFile
105
+ )
106
+ }
107
+ }
108
+
87
109
/**
88
110
* A service register handler.
89
111
*/
@@ -111,6 +133,36 @@ module GoMicro {
111
133
}
112
134
}
113
135
136
+ /**
137
+ * A client service function.
138
+ */
139
+ class ClientService extends Function {
140
+ ClientService ( ) {
141
+ exists ( ClientServiceType c |
142
+ this .getName ( ) .regexpMatch ( "(?i)new" + c .getName ( ) ) and
143
+ this .getParameterType ( 0 ) instanceof StringType and
144
+ this .getParameterType ( 1 ) instanceof GoMicroClientType and
145
+ this .getDeclaration ( ) .getLocation ( ) .getFile ( ) instanceof ProtocGeneratedFile
146
+ )
147
+ }
148
+ }
149
+
150
+ /**
151
+ * An SSRF sink for the Client service function.
152
+ */
153
+ class ClientRequestUrlAsSink extends RequestForgery:: Sink {
154
+ ClientRequestUrlAsSink ( ) {
155
+ exists ( DataFlow:: CallNode call |
156
+ call .getArgument ( 0 ) = this and
157
+ call .getTarget ( ) instanceof ClientService
158
+ )
159
+ }
160
+
161
+ override DataFlow:: Node getARequest ( ) { result = this }
162
+
163
+ override string getKind ( ) { result = "URL" }
164
+ }
165
+
114
166
/**
115
167
* A set of remote requests from a service handler.
116
168
*/
0 commit comments