This repository was archived by the owner on Jan 5, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +104
-0
lines changed Expand file tree Collapse file tree 5 files changed +104
-0
lines changed Original file line number Diff line number Diff line change @@ -37,4 +37,7 @@ import semmle.go.frameworks.SystemCommandExecutors
37
37
import semmle.go.frameworks.Testing
38
38
import semmle.go.frameworks.WebSocket
39
39
import semmle.go.frameworks.XPath
40
+ import semmle.go.frameworks.thirdpartlib.HTTP
41
+ import semmle.go.frameworks.thirdpartlib.SQL
42
+ import semmle.go.frameworks.thirdpartlib.Encoding
40
43
import semmle.go.security.FlowSources
Original file line number Diff line number Diff line change @@ -231,3 +231,4 @@ private module StdlibHttp {
231
231
}
232
232
}
233
233
}
234
+
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Provides classes modeling security-relevant aspects of the third-part libraries.
3
+ */
4
+
5
+ import go
6
+
7
+ module ThirdPartEncodingJson {
8
+ /** Provides models of some functions in the `github.com/json-iterator/go` package. */
9
+ class JsoniterUnmarshalingFunction extends TaintTracking:: FunctionModel , UnmarshalingFunction:: Range {
10
+
11
+ JsoniterUnmarshalingFunction ( ) {
12
+ this .hasQualifiedName ( "github.com/json-iterator/go" , "Unmarshal" )
13
+ }
14
+
15
+ override DataFlow:: FunctionInput getAnInput ( ) { result .isParameter ( 0 ) }
16
+ override DataFlow:: FunctionOutput getOutput ( ) { result .isParameter ( 1 ) }
17
+
18
+ override string getFormat ( ) { result = "JSON" }
19
+
20
+ override predicate hasTaintFlow ( DataFlow:: FunctionInput inp , DataFlow:: FunctionOutput outp ) {
21
+ inp = getAnInput ( ) and outp = getOutput ( )
22
+ }
23
+ }
24
+ }
25
+
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Provides classes for working with HTTP-related concepts such as requests and responses.
3
+ */
4
+
5
+ import go
6
+
7
+ module ThirdPartHttpLib {
8
+ /**
9
+ * Source from go-resultful
10
+ * Document: https://github.com/emicklei/go-restful
11
+ */
12
+ class GoRestfulSource extends DataFlow:: Node , UntrustedFlowSource:: Range {
13
+ GoRestfulSource ( ) {
14
+ exists (
15
+ Method meth , string name |
16
+ meth .hasQualifiedName ( "github.com/emicklei/go-restful" , "Request" , name ) and
17
+ asExpr ( ) = meth .getACall ( ) .asExpr ( ) and
18
+ (
19
+ name = "QueryParameters" or name = "QueryParameter" or
20
+ name = "BodyParamater" or name = "HeaderParameter" or
21
+ name = "PathParameter" or name = "PathParameters"
22
+ )
23
+ )
24
+ }
25
+ }
26
+ }
27
+
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Provides classes for working with SQL-related concepts such as queries.
3
+ */
4
+
5
+ import go
6
+
7
+ module ThirdPartSQL {
8
+
9
+ /** Sinks of github.com/jinzhu/gorm */
10
+ class GormSink extends DataFlow:: Node , SQL:: QueryString:: Range {
11
+ GormSink ( ) {
12
+ exists (
13
+ Method meth , string name |
14
+ meth .hasQualifiedName ( "github.com/jinzhu/gorm" , "DB" , name ) and
15
+ asExpr ( ) = meth .getACall ( ) .getArgument ( 0 ) .asExpr ( ) and
16
+ (
17
+ name = "Where" or name = "Raw" or name = "Order" or name = "Not" or name = "Or" or
18
+ name = "Select" or name = "Table" or name = "Group" or name = "Having" or name = "Joins"
19
+ )
20
+ )
21
+ }
22
+ }
23
+
24
+ /** Sinks of github.com/jmoiron/sqlx */
25
+ class SqlxSink extends DataFlow:: Node , SQL:: QueryString:: Range {
26
+ SqlxSink ( ) {
27
+ exists (
28
+ Method meth , string name , int n |
29
+ (
30
+ meth .hasQualifiedName ( "github.com/jmoiron/sqlx" , "DB" , name ) or
31
+ meth .hasQualifiedName ( "github.com/jmoiron/sqlx" , "Tx" , name )
32
+ ) and this = meth .getACall ( ) .getArgument ( n ) |
33
+ (
34
+ ( name = "Select" or name = "Get" ) and n = 1
35
+ )
36
+ or
37
+ (
38
+ (
39
+ name = "MustExec" or name = "Queryx" or
40
+ name = "NamedExec" or name = "NamedQuery"
41
+ )
42
+ and n = 0
43
+ )
44
+ )
45
+ }
46
+ }
47
+
48
+ }
You can’t perform that action at this time.
0 commit comments