Skip to content

Commit f828f8e

Browse files
authored
Merge pull request #16250 from owen-mc/go/rename-untrusted-flow-source
Go: Rename `UntrustedFlowSource` to `RemoteFlowSource` to match other language libraries
2 parents 037114b + 0311888 commit f828f8e

File tree

75 files changed

+361
-275
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+361
-275
lines changed

docs/codeql/codeql-language-guides/modeling-data-flow-in-go-libraries.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ Sources
1515
-------
1616

1717
To mark a source of data that is controlled by an untrusted user, we
18-
create a class extending ``UntrustedFlowSource::Range``. Inheritance and
18+
create a class extending ``RemoteFlowSource::Range``. Inheritance and
1919
the characteristic predicate of the class should be used to specify
2020
exactly the dataflow node that introduces the data. Here is a short
2121
example from ``Mux.qll``.
2222

2323
.. code-block:: ql
2424
25-
class RequestVars extends DataFlow::UntrustedFlowSource::Range, DataFlow::CallNode {
25+
class RequestVars extends DataFlow::RemoteFlowSource::Range, DataFlow::CallNode {
2626
RequestVars() { this.getTarget().hasQualifiedName("github.com/gorilla/mux", "Vars") }
2727
}
2828

go/docs/language/learn-ql/go/library-modeling-go.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ Sources
1313
-------
1414

1515
To mark a source of data that is controlled by an untrusted user, we
16-
create a class extending ``UntrustedFlowSource::Range``. Inheritance and
16+
create a class extending ``RemoteFlowSource::Range``. Inheritance and
1717
the characteristic predicate of the class should be used to specify
1818
exactly the dataflow node that introduces the data. Here is a short
1919
example from ``Mux.qll``.
2020

2121
.. code-block:: ql
2222
23-
class RequestVars extends DataFlow::UntrustedFlowSource::Range, DataFlow::CallNode {
23+
class RequestVars extends DataFlow::RemoteFlowSource::Range, DataFlow::CallNode {
2424
RequestVars() { this.getTarget().hasQualifiedName("github.com/gorilla/mux", "Vars") }
2525
}
2626
@@ -119,4 +119,4 @@ Here is a short example from ``Stdlib.qll``, which has been slightly simplified.
119119
This has the effect that any call to ``Print``, ``Printf``, or
120120
``Println`` in the package ``fmt`` is recognized as a logger call.
121121
Any query that uses logger calls as a sink will then identify when tainted data
122-
has been passed as an argument to ``Print``, ``Printf``, or ``Println``.
122+
has been passed as an argument to ``Print``, ``Printf``, or ``Println``.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
category: deprecated
3+
---
4+
* To make Go consistent with other language libraries, the `UntrustedFlowSource` name has been deprecated throughout. Use `RemoteFlowSource` instead, which replaces it.
5+
* Where modules have classes named `UntrustedFlowAsSource`, these are also deprecated and the `Source` class in the same module or the `RemoteFlowSource` class should be used instead.

go/ql/lib/semmle/go/frameworks/AwsLambda.qll

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
2-
* Provides classes for working with untrusted flow sources, sinks and taint propagators
2+
* Provides classes for working with remote flow sources, sinks and taint propagators
33
* from the `github.com/aws/aws-lambda-go/lambda` package.
44
*/
55

66
import go
77

88
/** A source of input data in an AWS Lambda. */
9-
private class LambdaInput extends UntrustedFlowSource::Range {
9+
private class LambdaInput extends RemoteFlowSource::Range {
1010
LambdaInput() {
1111
exists(Parameter p | p = this.asParameter() |
1212
p = any(HandlerFunction hf).getAParameter() and

go/ql/lib/semmle/go/frameworks/Beego.qll

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Provides classes for working with untrusted flow sources, sinks and taint propagators
2+
* Provides classes for working with remote flow sources, sinks and taint propagators
33
* from the `github.com/beego/beego` package.
44
*/
55

@@ -9,7 +9,7 @@ private import semmle.go.security.SafeUrlFlowCustomizations
99

1010
// Some TaintTracking::FunctionModel subclasses remain because varargs functions don't work with Models-as-Data sumamries yet.
1111
/**
12-
* Provides classes for working with untrusted flow sources, sinks and taint propagators
12+
* Provides classes for working with remote flow sources, sinks and taint propagators
1313
* from the [Beego](https://github.com/beego/beego) package.
1414
*/
1515
module Beego {
@@ -50,7 +50,7 @@ module Beego {
5050
/**
5151
* `BeegoInput` sources of untrusted data.
5252
*/
53-
private class BeegoInputSource extends UntrustedFlowSource::Range {
53+
private class BeegoInputSource extends RemoteFlowSource::Range {
5454
string methodName;
5555

5656
BeegoInputSource() {
@@ -81,7 +81,7 @@ module Beego {
8181
/**
8282
* `beego.Controller` sources of untrusted data.
8383
*/
84-
private class BeegoControllerSource extends UntrustedFlowSource::Range {
84+
private class BeegoControllerSource extends RemoteFlowSource::Range {
8585
BeegoControllerSource() {
8686
exists(string methodName, FunctionOutput output |
8787
methodName = "ParseForm" and
@@ -105,7 +105,7 @@ module Beego {
105105
/**
106106
* `BeegoInputRequestBody` sources of untrusted data.
107107
*/
108-
private class BeegoInputRequestBodySource extends UntrustedFlowSource::Range {
108+
private class BeegoInputRequestBodySource extends RemoteFlowSource::Range {
109109
BeegoInputRequestBodySource() {
110110
exists(DataFlow::FieldReadNode frn | this = frn |
111111
frn.getField().hasQualifiedName(contextPackagePath(), "BeegoInput", "RequestBody")
@@ -116,7 +116,7 @@ module Beego {
116116
/**
117117
* `beego/context.Context` sources of untrusted data.
118118
*/
119-
private class BeegoContextSource extends UntrustedFlowSource::Range {
119+
private class BeegoContextSource extends RemoteFlowSource::Range {
120120
BeegoContextSource() {
121121
exists(Method m | m.hasQualifiedName(contextPackagePath(), "Context", "GetCookie") |
122122
this = m.getACall().getResult()

go/ql/lib/semmle/go/frameworks/BeegoOrm.qll

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/**
2-
* Provides classes for working with untrusted flow sources, sinks and taint propagators
2+
* Provides classes for working with remote flow sources, sinks and taint propagators
33
* from the `github.com/astaxie/beego/orm` subpackage.
44
*/
55

66
import go
77
private import semmle.go.security.StoredXssCustomizations
88

99
/**
10-
* Provides classes for working with untrusted flow sources, sinks and taint propagators
10+
* Provides classes for working with remote flow sources, sinks and taint propagators
1111
* from the [Beego ORM](https://github.com/astaxie/beego/orm) subpackage.
1212
*/
1313
module BeegoOrm {

go/ql/lib/semmle/go/frameworks/Chi.qll

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Provides classes for working with untrusted flow sources from the `github.com/go-chi/chi` package.
2+
* Provides classes for working with remote flow sources from the `github.com/go-chi/chi` package.
33
*/
44

55
import go
@@ -9,18 +9,18 @@ private module Chi {
99
string packagePath() { result = package("github.com/go-chi/chi", "") }
1010

1111
/**
12-
* Functions that extract URL parameters, considered as a source of untrusted flow.
12+
* Functions that extract URL parameters, considered as a source of remote flow.
1313
*/
14-
private class UserControlledFunction extends UntrustedFlowSource::Range, DataFlow::CallNode {
14+
private class UserControlledFunction extends RemoteFlowSource::Range, DataFlow::CallNode {
1515
UserControlledFunction() {
1616
this.getTarget().hasQualifiedName(packagePath(), ["URLParam", "URLParamFromCtx"])
1717
}
1818
}
1919

2020
/**
21-
* Methods that extract URL parameters, considered as a source of untrusted flow.
21+
* Methods that extract URL parameters, considered as a source of remote flow.
2222
*/
23-
private class UserControlledRequestMethod extends UntrustedFlowSource::Range,
23+
private class UserControlledRequestMethod extends RemoteFlowSource::Range,
2424
DataFlow::MethodCallNode
2525
{
2626
UserControlledRequestMethod() {

go/ql/lib/semmle/go/frameworks/Echo.qll

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Provides classes for working with untrusted flow sources, taint propagators, and HTTP sinks
2+
* Provides classes for working with remote flow sources, taint propagators, and HTTP sinks
33
* from the `github.com/labstack/echo` package.
44
*/
55

@@ -10,9 +10,9 @@ private module Echo {
1010
private string packagePath() { result = package("github.com/labstack/echo", "") }
1111

1212
/**
13-
* Data from a `Context` interface method, considered as a source of untrusted flow.
13+
* Data from a `Context` interface method, considered as a source of remote flow.
1414
*/
15-
private class EchoContextSource extends UntrustedFlowSource::Range {
15+
private class EchoContextSource extends RemoteFlowSource::Range {
1616
EchoContextSource() {
1717
exists(DataFlow::MethodCallNode call, string methodName |
1818
methodName =
@@ -42,7 +42,7 @@ private module Echo {
4242
/**
4343
* A call to a method on `Context` struct that unmarshals data into a target.
4444
*/
45-
private class EchoContextBinder extends UntrustedFlowSource::Range {
45+
private class EchoContextBinder extends RemoteFlowSource::Range {
4646
EchoContextBinder() {
4747
exists(DataFlow::MethodCallNode call |
4848
call.getTarget().hasQualifiedName(packagePath(), "Context", "Bind")

go/ql/lib/semmle/go/frameworks/ElazarlGoproxy.qll

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ module ElazarlGoproxy {
9595
}
9696
}
9797

98-
private class UserControlledRequestData extends UntrustedFlowSource::Range {
98+
private class UserControlledRequestData extends RemoteFlowSource::Range {
9999
UserControlledRequestData() {
100100
exists(DataFlow::FieldReadNode frn | this = frn |
101101
// liberally consider ProxyCtx.UserData to be untrusted; it's a data field set by a request handler

go/ql/lib/semmle/go/frameworks/Fasthttp.qll

+36-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Provides classes for working with untrusted flow sources, sinks and taint propagators
2+
* Provides classes for working with remote flow sources, sinks and taint propagators
33
* from the `github.com/valyala/fasthttp` package.
44
*/
55

@@ -255,11 +255,16 @@ module Fasthttp {
255255
* Provide modeling for fasthttp.URI Type.
256256
*/
257257
module URI {
258+
/**
259+
* DEPRECATED: Use `RemoteFlowSource` instead.
260+
*/
261+
deprecated class UntrustedFlowSource = RemoteFlowSource;
262+
258263
/**
259264
* The methods as Remote user controllable source which are part of the incoming URL.
260265
*/
261-
class UntrustedFlowSource extends UntrustedFlowSource::Range instanceof DataFlow::Node {
262-
UntrustedFlowSource() {
266+
class RemoteFlowSource extends RemoteFlowSource::Range instanceof DataFlow::Node {
267+
RemoteFlowSource() {
263268
exists(Method m |
264269
m.hasQualifiedName(packagePath(), "URI",
265270
["FullURI", "LastPathSegment", "Path", "PathOriginal", "QueryString", "String"]) and
@@ -273,13 +278,18 @@ module Fasthttp {
273278
* Provide modeling for fasthttp.Args Type.
274279
*/
275280
module Args {
281+
/**
282+
* DEPRECATED: Use `RemoteFlowSource` instead.
283+
*/
284+
deprecated class UntrustedFlowSource = RemoteFlowSource;
285+
276286
/**
277287
* The methods as Remote user controllable source which are part of the incoming URL Parameters.
278288
*
279289
* When support for lambdas has been implemented we should model "VisitAll".
280290
*/
281-
class UntrustedFlowSource extends UntrustedFlowSource::Range instanceof DataFlow::Node {
282-
UntrustedFlowSource() {
291+
class RemoteFlowSource extends RemoteFlowSource::Range instanceof DataFlow::Node {
292+
RemoteFlowSource() {
283293
exists(Method m |
284294
m.hasQualifiedName(packagePath(), "Args",
285295
["Peek", "PeekBytes", "PeekMulti", "PeekMultiBytes", "QueryString", "String"]) and
@@ -386,11 +396,16 @@ module Fasthttp {
386396
* Provide modeling for fasthttp.Request Type.
387397
*/
388398
module Request {
399+
/**
400+
* DEPRECATED: Use `RemoteFlowSource` instead.
401+
*/
402+
deprecated class UntrustedFlowSource = RemoteFlowSource;
403+
389404
/**
390405
* The methods as Remote user controllable source which can be many part of request.
391406
*/
392-
class UntrustedFlowSource extends UntrustedFlowSource::Range instanceof DataFlow::Node {
393-
UntrustedFlowSource() {
407+
class RemoteFlowSource extends RemoteFlowSource::Range instanceof DataFlow::Node {
408+
RemoteFlowSource() {
394409
exists(Method m |
395410
m.hasQualifiedName(packagePath(), "Request",
396411
[
@@ -463,13 +478,18 @@ module Fasthttp {
463478
override Http::ResponseWriter getResponseWriter() { none() }
464479
}
465480

481+
/**
482+
* DEPRECATED: Use `RemoteFlowSource` instead.
483+
*/
484+
deprecated class UntrustedFlowSource = RemoteFlowSource;
485+
466486
/**
467487
* The methods as Remote user controllable source which are generally related to HTTP request.
468488
*
469489
* When support for lambdas has been implemented we should model "VisitAll", "VisitAllCookie", "VisitAllInOrder", "VisitAllTrailer".
470490
*/
471-
class UntrustedFlowSource extends UntrustedFlowSource::Range instanceof DataFlow::Node {
472-
UntrustedFlowSource() {
491+
class RemoteFlowSource extends RemoteFlowSource::Range instanceof DataFlow::Node {
492+
RemoteFlowSource() {
473493
exists(Method m |
474494
m.hasQualifiedName(packagePath(), "RequestCtx",
475495
[
@@ -486,13 +506,18 @@ module Fasthttp {
486506
* Provide Methods of fasthttp.RequestHeader which mostly used as remote user controlled sources.
487507
*/
488508
module RequestHeader {
509+
/**
510+
* DEPRECATED: Use `RemoteFlowSource` instead.
511+
*/
512+
deprecated class UntrustedFlowSource = RemoteFlowSource;
513+
489514
/**
490515
* The methods as Remote user controllable source which are mostly related to HTTP Request Headers.
491516
*
492517
* When support for lambdas has been implemented we should model "VisitAll", "VisitAllCookie", "VisitAllInOrder", "VisitAllTrailer".
493518
*/
494-
class UntrustedFlowSource extends UntrustedFlowSource::Range instanceof DataFlow::Node {
495-
UntrustedFlowSource() {
519+
class RemoteFlowSource extends RemoteFlowSource::Range instanceof DataFlow::Node {
520+
RemoteFlowSource() {
496521
exists(Method m |
497522
m.hasQualifiedName(packagePath(), "RequestHeader",
498523
[

go/ql/lib/semmle/go/frameworks/Gin.qll

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ private module Gin {
1010
string packagePath() { result = package("github.com/gin-gonic/gin", "") }
1111

1212
/**
13-
* Data from a `Context` struct, considered as a source of untrusted flow.
13+
* Data from a `Context` struct, considered as a source of remote flow.
1414
*/
15-
private class GithubComGinGonicGinContextSource extends UntrustedFlowSource::Range {
15+
private class GithubComGinGonicGinContextSource extends RemoteFlowSource::Range {
1616
GithubComGinGonicGinContextSource() {
1717
// Method calls:
1818
exists(DataFlow::MethodCallNode call, string methodName |
@@ -39,7 +39,7 @@ private module Gin {
3939
/**
4040
* A call to a method on `Context` struct that unmarshals data into a target.
4141
*/
42-
private class GithubComGinGonicGinContextBindSource extends UntrustedFlowSource::Range {
42+
private class GithubComGinGonicGinContextBindSource extends RemoteFlowSource::Range {
4343
GithubComGinGonicGinContextBindSource() {
4444
exists(DataFlow::MethodCallNode call, string methodName |
4545
call.getTarget().hasQualifiedName(packagePath(), "Context", methodName) and

go/ql/lib/semmle/go/frameworks/GoKit.qll

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module GoKit {
3535
DataFlow::exprNode(result.(FuncLit)) = getAnEndpointFactoryResult()
3636
}
3737

38-
private class EndpointRequest extends UntrustedFlowSource::Range {
38+
private class EndpointRequest extends RemoteFlowSource::Range {
3939
EndpointRequest() { this = DataFlow::parameterNode(getAnEndpointFunction().getParameter(1)) }
4040
}
4141
}

go/ql/lib/semmle/go/frameworks/GoMicro.qll

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ module GoMicro {
142142
/**
143143
* A set of remote requests from a service handler.
144144
*/
145-
class Request extends UntrustedFlowSource::Range instanceof DataFlow::ParameterNode {
145+
class Request extends RemoteFlowSource::Range instanceof DataFlow::ParameterNode {
146146
Request() {
147147
exists(ServiceHandler handler |
148148
this.asParameter().isParameterOf(handler.getFuncDecl(), 1) and

go/ql/lib/semmle/go/frameworks/GoRestfulHttp.qll

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ private module GoRestfulHttp {
2727
/**
2828
* A model of go-restful's `Request` object as a source of user-controlled data.
2929
*/
30-
private class GoRestfulSource extends UntrustedFlowSource::Range {
30+
private class GoRestfulSource extends RemoteFlowSource::Range {
3131
GoRestfulSource() { this = any(GoRestfulSourceMethod g).getACall() }
3232
}
3333

3434
/**
3535
* A model of go-restful's `Request.ReadEntity` method as a source of user-controlled data.
3636
*/
37-
private class GoRestfulReadEntitySource extends UntrustedFlowSource::Range {
37+
private class GoRestfulReadEntitySource extends RemoteFlowSource::Range {
3838
GoRestfulReadEntitySource() {
3939
exists(DataFlow::MethodCallNode call |
4040
call.getTarget().hasQualifiedName(packagePath(), "Request", "ReadEntity")

go/ql/lib/semmle/go/frameworks/Gqlgen.qll

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module Gqlgen {
3939
}
4040

4141
/** A parameter of a resolver method which receives untrusted input. */
42-
class ResolverParameter extends UntrustedFlowSource::Range instanceof DataFlow::ParameterNode {
42+
class ResolverParameter extends RemoteFlowSource::Range instanceof DataFlow::ParameterNode {
4343
ResolverParameter() {
4444
this.asParameter() = any(ResolverImplementationMethod h).getAnUntrustedParameter()
4545
}

go/ql/lib/semmle/go/frameworks/Mux.qll

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import go
99
*/
1010
module Mux {
1111
/** An access to a Mux middleware variable. */
12-
class RequestVars extends DataFlow::UntrustedFlowSource::Range, DataFlow::CallNode {
12+
class RequestVars extends DataFlow::RemoteFlowSource::Range, DataFlow::CallNode {
1313
RequestVars() {
1414
this.getTarget().hasQualifiedName(package("github.com/gorilla/mux", ""), "Vars")
1515
}

0 commit comments

Comments
 (0)