-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathBun.qll
More file actions
62 lines (53 loc) · 2.1 KB
/
Bun.qll
File metadata and controls
62 lines (53 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* Provides classes modeling security-relevant aspects of the `Bun` package.
*/
import go
/**
* Provides classes modeling security-relevant aspects of the `Bun` package.
*/
private module Bun {
private string packagePath() { result = package("github.com/uptrace/bun", "") }
private class RawQuerySources extends SourceNode {
RawQuerySources() {
// func (q *RawQuery) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error)
// func (q *RawQuery) Scan(ctx context.Context, dest ...interface{}) error
exists(DataFlow::CallNode cn, int i |
cn.getTarget().(Method).hasQualifiedName(packagePath(), "RawQuery", ["Exec", "Scan"]) and
i >= 1
|
this = cn.getSyntacticArgument(i)
)
}
override string getThreatModel() { result = "database" }
}
private class SelectQuerySources extends SourceNode {
SelectQuerySources() {
// func (q *SelectQuery) Exec(ctx context.Context, dest ...interface{}) (res sql.Result, err error)
// func (q *SelectQuery) Scan(ctx context.Context, dest ...interface{}) error
// func (q *SelectQuery) ScanAndCount(ctx context.Context, dest ...interface{}) (int, error)
exists(DataFlow::CallNode cn, int i |
cn.getTarget()
.(Method)
.hasQualifiedName(packagePath(), "SelectQuery", ["Exec", "Scan", "ScanAndCount"]) and
i >= 1
|
this = cn.getSyntacticArgument(i)
)
}
override string getThreatModel() { result = "database" }
}
private class DBScanRows extends TaintTracking::FunctionModel, Method {
FunctionInput inp;
FunctionOutput outp;
DBScanRows() {
// func (db *DB) ScanRow(ctx context.Context, rows *sql.Rows, dest ...interface{}) error
// func (db *DB) ScanRows(ctx context.Context, rows *sql.Rows, dest ...interface{}) error
this.hasQualifiedName(packagePath(), "DB", ["ScanRow", "ScanRows"]) and
inp.isParameter(1) and
outp.isParameter(any(int i | i >= 2))
}
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
input = inp and output = outp
}
}
}