Skip to content

Commit f644194

Browse files
committed
Add package predicates
1 parent 06fac54 commit f644194

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

ql/src/experimental/frameworks/Fiber.qll

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ import go
1212
* - [`github.com/gofiber/utils@v0.1.0`](https://pkg.go.dev/github.com/gofiber/utils@v0.1.0)
1313
*/
1414
private module Fiber {
15+
string fiberPackagePath() { result = package("github.com/gofiber/fiber", "") }
16+
17+
string utilsPackagePath() { result = package("github.com/gofiber/utils", "") }
18+
1519
/**
1620
* Models taint-tracking through functions.
1721
*/
@@ -22,94 +26,94 @@ private module Fiber {
2226
TaintTrackingFunctionModels() {
2327
// Taint-tracking models for package: github.com/gofiber/fiber@v1.14.6
2428
// signature: func NewError(code int, message ...string) *Error
25-
this.hasQualifiedName(package("github.com/gofiber/fiber", ""), "NewError") and
29+
this.hasQualifiedName(fiberPackagePath(), "NewError") and
2630
inp.isParameter(any(int i | i >= 1)) and
2731
out.isResult()
2832
or
2933
// Taint-tracking models for package: github.com/gofiber/utils@v0.1.0
3034
(
3135
// signature: func GetBytes(s string) []byte
32-
this.hasQualifiedName(package("github.com/gofiber/utils", ""), "GetBytes") and
36+
this.hasQualifiedName(utilsPackagePath(), "GetBytes") and
3337
inp.isParameter(0) and
3438
out.isResult()
3539
or
3640
// signature: func GetString(b []byte) string
37-
this.hasQualifiedName(package("github.com/gofiber/utils", ""), "GetString") and
41+
this.hasQualifiedName(utilsPackagePath(), "GetString") and
3842
inp.isParameter(0) and
3943
out.isResult()
4044
or
4145
// signature: func ImmutableString(s string) string
42-
this.hasQualifiedName(package("github.com/gofiber/utils", ""), "ImmutableString") and
46+
this.hasQualifiedName(utilsPackagePath(), "ImmutableString") and
4347
inp.isParameter(0) and
4448
out.isResult()
4549
or
4650
// signature: func SafeBytes(b []byte) []byte
47-
this.hasQualifiedName(package("github.com/gofiber/utils", ""), "SafeBytes") and
51+
this.hasQualifiedName(utilsPackagePath(), "SafeBytes") and
4852
inp.isParameter(0) and
4953
out.isResult()
5054
or
5155
// signature: func SafeString(s string) string
52-
this.hasQualifiedName(package("github.com/gofiber/utils", ""), "SafeString") and
56+
this.hasQualifiedName(utilsPackagePath(), "SafeString") and
5357
inp.isParameter(0) and
5458
out.isResult()
5559
or
5660
// signature: func ToLower(b string) string
57-
this.hasQualifiedName(package("github.com/gofiber/utils", ""), "ToLower") and
61+
this.hasQualifiedName(utilsPackagePath(), "ToLower") and
5862
inp.isParameter(0) and
5963
out.isResult()
6064
or
6165
// signature: func ToLowerBytes(b []byte) []byte
62-
this.hasQualifiedName(package("github.com/gofiber/utils", ""), "ToLowerBytes") and
66+
this.hasQualifiedName(utilsPackagePath(), "ToLowerBytes") and
6367
inp.isParameter(0) and
6468
out.isResult()
6569
or
6670
// signature: func ToUpper(b string) string
67-
this.hasQualifiedName(package("github.com/gofiber/utils", ""), "ToUpper") and
71+
this.hasQualifiedName(utilsPackagePath(), "ToUpper") and
6872
inp.isParameter(0) and
6973
out.isResult()
7074
or
7175
// signature: func ToUpperBytes(b []byte) []byte
72-
this.hasQualifiedName(package("github.com/gofiber/utils", ""), "ToUpperBytes") and
76+
this.hasQualifiedName(utilsPackagePath(), "ToUpperBytes") and
7377
inp.isParameter(0) and
7478
out.isResult()
7579
or
7680
// signature: func Trim(s string, cutset byte) string
77-
this.hasQualifiedName(package("github.com/gofiber/utils", ""), "Trim") and
81+
this.hasQualifiedName(utilsPackagePath(), "Trim") and
7882
inp.isParameter(0) and
7983
out.isResult()
8084
or
8185
// signature: func TrimBytes(b []byte, cutset byte) []byte
82-
this.hasQualifiedName(package("github.com/gofiber/utils", ""), "TrimBytes") and
86+
this.hasQualifiedName(utilsPackagePath(), "TrimBytes") and
8387
inp.isParameter(0) and
8488
out.isResult()
8589
or
8690
// signature: func TrimLeft(s string, cutset byte) string
87-
this.hasQualifiedName(package("github.com/gofiber/utils", ""), "TrimLeft") and
91+
this.hasQualifiedName(utilsPackagePath(), "TrimLeft") and
8892
inp.isParameter(0) and
8993
out.isResult()
9094
or
9195
// signature: func TrimLeftBytes(b []byte, cutset byte) []byte
92-
this.hasQualifiedName(package("github.com/gofiber/utils", ""), "TrimLeftBytes") and
96+
this.hasQualifiedName(utilsPackagePath(), "TrimLeftBytes") and
9397
inp.isParameter(0) and
9498
out.isResult()
9599
or
96100
// signature: func TrimRight(s string, cutset byte) string
97-
this.hasQualifiedName(package("github.com/gofiber/utils", ""), "TrimRight") and
101+
this.hasQualifiedName(utilsPackagePath(), "TrimRight") and
98102
inp.isParameter(0) and
99103
out.isResult()
100104
or
101105
// signature: func TrimRightBytes(b []byte, cutset byte) []byte
102-
this.hasQualifiedName(package("github.com/gofiber/utils", ""), "TrimRightBytes") and
106+
this.hasQualifiedName(utilsPackagePath(), "TrimRightBytes") and
103107
inp.isParameter(0) and
104108
out.isResult()
105109
or
106110
// signature: func UnsafeBytes(s string) (bs []byte)
107-
this.hasQualifiedName(package("github.com/gofiber/utils", ""), "UnsafeBytes") and
111+
this.hasQualifiedName(utilsPackagePath(), "UnsafeBytes") and
108112
inp.isParameter(0) and
109113
out.isResult()
110114
or
111115
// signature: func UnsafeString(b []byte) string
112-
this.hasQualifiedName(package("github.com/gofiber/utils", ""), "UnsafeString") and
116+
this.hasQualifiedName(utilsPackagePath(), "UnsafeString") and
113117
inp.isParameter(0) and
114118
out.isResult()
115119
)
@@ -129,7 +133,7 @@ private module Fiber {
129133

130134
Redirect() {
131135
// HTTP redirect models for package: github.com/gofiber/fiber@v1.14.6
132-
package = package("github.com/gofiber/fiber", "") and
136+
package = fiberPackagePath() and
133137
// Receiver type: Ctx
134138
(
135139
// signature: func (*Ctx).Redirect(location string, status ...int)
@@ -173,7 +177,7 @@ private module Fiber {
173177
headerSetterCall = met.getACall() and
174178
receiverNode = headerSetterCall.getReceiver()
175179
|
176-
package = package("github.com/gofiber/fiber", "") and
180+
package = fiberPackagePath() and
177181
(
178182
// Receiver type: Ctx
179183
receiverName = "Ctx" and
@@ -220,7 +224,7 @@ private module Fiber {
220224
bodySetterCall = met.getACall() and
221225
receiverNode = bodySetterCall.getReceiver()
222226
|
223-
package = package("github.com/gofiber/fiber", "") and
227+
package = fiberPackagePath() and
224228
(
225229
// Receiver type: Ctx
226230
receiverName = "Ctx" and
@@ -263,7 +267,7 @@ private module Fiber {
263267
bodySetterCall = met.getACall() and
264268
receiverNode = bodySetterCall.getReceiver()
265269
|
266-
package = package("github.com/gofiber/fiber", "") and
270+
package = fiberPackagePath() and
267271
(
268272
// Receiver type: Ctx
269273
receiverName = "Ctx" and
@@ -304,7 +308,7 @@ private module Fiber {
304308
// Methods on types of package: github.com/gofiber/fiber@v1.14.6
305309
exists(string receiverName, string methodName, Method mtd, FunctionOutput out |
306310
this = out.getExitNode(mtd.getACall()) and
307-
mtd.hasQualifiedName(package("github.com/gofiber/fiber", ""), receiverName, methodName)
311+
mtd.hasQualifiedName(fiberPackagePath(), receiverName, methodName)
308312
|
309313
receiverName = "Ctx" and
310314
(
@@ -385,7 +389,7 @@ private module Fiber {
385389
// Structs of package: github.com/gofiber/fiber@v1.14.6
386390
exists(string structName, string fields, DataFlow::Field fld |
387391
this = fld.getARead() and
388-
fld.hasQualifiedName(package("github.com/gofiber/fiber", ""), structName, fields)
392+
fld.hasQualifiedName(fiberPackagePath(), structName, fields)
389393
|
390394
structName = "Cookie" and
391395
fields = ["Domain", "Name", "Path", "SameSite", "Value"]

0 commit comments

Comments
 (0)