Skip to content

Commit 3fb422c

Browse files
committed
Split Jwt.qll into framework libraries, which makes more sense
1 parent 8afaa23 commit 3fb422c

File tree

7 files changed

+64
-46
lines changed

7 files changed

+64
-46
lines changed

go/ql/lib/go.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import semmle.go.frameworks.Fiber
4545
import semmle.go.frameworks.Gin
4646
import semmle.go.frameworks.GinCors
4747
import semmle.go.frameworks.Glog
48+
import semmle.go.frameworks.Gogf
4849
import semmle.go.frameworks.GoKit
4950
import semmle.go.frameworks.GoMicro
5051
import semmle.go.frameworks.GoRestfulHttp
@@ -61,6 +62,7 @@ import semmle.go.frameworks.Protobuf
6162
import semmle.go.frameworks.Revel
6263
import semmle.go.frameworks.Spew
6364
import semmle.go.frameworks.SQL
65+
import semmle.go.frameworks.Square
6466
import semmle.go.frameworks.Stdlib
6567
import semmle.go.frameworks.SystemCommandExecutors
6668
import semmle.go.frameworks.Testing

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/**
2-
* Provides classes for working with untrusted flow sources from the `github.com/gin-gonic/gin` package.
2+
* Provides classes for working with the `github.com/gin-gonic/gin` package.
33
*/
44

55
import go
6+
private import semmle.go.security.HardcodedCredentials
67

78
private module Gin {
89
/** Gets the package name `github.com/gin-gonic/gin`. */
@@ -75,4 +76,13 @@ private module Gin {
7576

7677
override DataFlow::Node getAPathArgument() { result = this.getArgument(pathArg) }
7778
}
79+
80+
private class GinJwtSign extends HardcodedCredentials::Sink {
81+
GinJwtSign() {
82+
exists(Field f |
83+
f.hasQualifiedName(package("github.com/appleboy/gin-jwt", ""), "GinJWTMiddleware", "Key") and
84+
f.getAWrite().getRhs() = this
85+
)
86+
}
87+
}
7888
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Provides classes for working with the `github.com/square/go-jose`, `github.com/go-jose/go-jose`,
3+
* and `gopkg.in/square-go-jose.v2` packages.
4+
*/
5+
6+
import go
7+
private import semmle.go.security.HardcodedCredentials
8+
9+
private module GoJose {
10+
private class GoJoseKey extends HardcodedCredentials::Sink {
11+
GoJoseKey() {
12+
exists(Field f, string pkg |
13+
pkg =
14+
[
15+
package("github.com/square/go-jose", ""), package("github.com/go-jose/go-jose", ""),
16+
"gopkg.in/square/go-jose.v2"
17+
]
18+
|
19+
f.hasQualifiedName(pkg, ["Recipient", "SigningKey"], "Key") and
20+
f.getAWrite().getRhs() = this
21+
)
22+
}
23+
}
24+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Provides classes for working the `github.com/gogf` package.
3+
*/
4+
5+
import go
6+
private import semmle.go.security.HardcodedCredentials
7+
8+
private module Gogf {
9+
private class GogfJwtSign extends HardcodedCredentials::Sink {
10+
GogfJwtSign() {
11+
exists(Field f |
12+
f.hasQualifiedName(package("github.com/gogf/gf-jwt", ""), "GfJWTMiddleware", "Key") and
13+
f.getAWrite().getRhs() = this
14+
)
15+
}
16+
}
17+
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44

55
import go
6+
private import semmle.go.security.HardcodedCredentials
67

78
private module Iris {
89
/** Gets the v1 module path `github.com/kataras/iris`. */
@@ -46,4 +47,13 @@ private module Iris {
4647

4748
override DataFlow::Node getAPathArgument() { result = this.getArgument(pathArg) }
4849
}
50+
51+
private class IrisJwt extends HardcodedCredentials::Sink {
52+
IrisJwt() {
53+
exists(Field f |
54+
f.hasQualifiedName(package("github.com/kataras/iris", "middleware/jwt"), "Signer", "Key") and
55+
f.getAWrite().getRhs() = this
56+
)
57+
}
58+
}
4959
}

go/ql/lib/semmle/go/security/HardcodedCredentials.qll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import go
88
private import semmle.go.StringOps
99
private import semmle.go.dataflow.ExternalFlow
10-
private import semmle.go.security.Jwt
1110

1211
/**
1312
* Provides default sources, sinks and sanitizers for reasoning about

go/ql/lib/semmle/go/security/Jwt.qll

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)