-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathPeewee.qll
More file actions
196 lines (189 loc) · 6.11 KB
/
Peewee.qll
File metadata and controls
196 lines (189 loc) · 6.11 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/**
* Provides classes modeling security-relevant aspects of the `peewee` PyPI package.
* See
* - https://pypi.org/project/peewee/
* - https://docs.peewee-orm.com/en/latest/index.html
*/
private import python
private import semmle.python.dataflow.new.DataFlow
private import semmle.python.dataflow.new.TaintTracking
private import semmle.python.Concepts
private import semmle.python.ApiGraphs
private import semmle.python.frameworks.PEP249
private import semmle.python.frameworks.data.ModelsAsData
/**
* INTERNAL: Do not use.
*
* Provides models for the `peewee` PyPI package.
* See
* - https://pypi.org/project/peewee/
* - https://docs.peewee-orm.com/en/latest/index.html
*/
module Peewee {
/** Provides models for the `peewee.Database` class and subclasses. */
module Database {
/** Gets a reference to the `peewee.Database` class or any subclass. */
API::Node subclassRef() {
result = API::moduleImport("peewee").getMember("Database").getASubclass*()
or
// known subclasses
result =
API::moduleImport("peewee")
.getMember(["SqliteDatabase", "MySQLDatabase", "PostgresqlDatabase"])
.getASubclass*()
or
// Other known subclasses, semi auto generated by using
// ```ql
// class DBClass extends Class, SelfRefMixin {
// DBClass() {
// exists(this.getLocation().getFile().getRelativePath()) and
// this.getName().matches("%Database") and
// this.getABase().(Name).getId().matches("%Database")
// }
// }
//
// from DBClass dbClass, Module mod
// where
// dbClass.getScope() = mod
// select mod.getName()+ "." + dbClass.getName()
// ```
result =
API::moduleImport("playhouse")
.getMember("apsw_ext")
.getMember("APSWDatabase")
.getASubclass*()
or
result =
API::moduleImport("playhouse")
.getMember("cockroachdb")
.getMember("CockroachDatabase")
.getASubclass*()
or
result =
API::moduleImport("playhouse")
.getMember("cockroachdb")
.getMember("PooledCockroachDatabase")
.getASubclass*()
or
result =
API::moduleImport("playhouse")
.getMember("mysql_ext")
.getMember("MySQLConnectorDatabase")
.getASubclass*()
or
result =
API::moduleImport("playhouse")
.getMember("pool")
.getMember("PooledCSqliteExtDatabase")
.getASubclass*()
or
result =
API::moduleImport("playhouse")
.getMember("pool")
.getMember("PooledMySQLDatabase")
.getASubclass*()
or
result =
API::moduleImport("playhouse")
.getMember("pool")
.getMember("PooledPostgresqlDatabase")
.getASubclass*()
or
result =
API::moduleImport("playhouse")
.getMember("pool")
.getMember("PooledPostgresqlExtDatabase")
.getASubclass*()
or
result =
API::moduleImport("playhouse")
.getMember("pool")
.getMember("PooledSqliteDatabase")
.getASubclass*()
or
result =
API::moduleImport("playhouse")
.getMember("pool")
.getMember("PooledSqliteExtDatabase")
.getASubclass*()
or
result =
API::moduleImport("playhouse")
.getMember("pool")
.getMember("_PooledPostgresqlDatabase")
.getASubclass*()
or
result =
API::moduleImport("playhouse")
.getMember("pool")
.getMember("_PooledSqliteDatabase")
.getASubclass*()
or
result =
API::moduleImport("playhouse")
.getMember("postgres_ext")
.getMember("PostgresqlExtDatabase")
.getASubclass*()
or
result =
API::moduleImport("playhouse")
.getMember("sqlcipher_ext")
.getMember("SqlCipherDatabase")
.getASubclass*()
or
result =
API::moduleImport("playhouse")
.getMember("sqlcipher_ext")
.getMember("SqlCipherExtDatabase")
.getASubclass*()
or
result =
API::moduleImport("playhouse")
.getMember("sqlite_ext")
.getMember("CSqliteExtDatabase")
.getASubclass*()
or
result =
API::moduleImport("playhouse")
.getMember("sqlite_ext")
.getMember("SqliteExtDatabase")
.getASubclass*()
or
result =
API::moduleImport("playhouse")
.getMember("sqliteq")
.getMember("SqliteQueueDatabase")
.getASubclass*()
or
result = ModelOutput::getATypeNode("peewee.Database~Subclass").getASubclass*()
}
/** Gets a reference to an instance of `peewee.Database` or any subclass. */
API::Node instance() { result = subclassRef().getReturn() }
}
/**
* A call to the `connection` method on a `peewee.Database` instance.
* https://docs.peewee-orm.com/en/latest/peewee/api.html#Database.connection.
*/
class PeeweeDatabaseConnectionCall extends PEP249::DatabaseConnection {
PeeweeDatabaseConnectionCall() {
this = Database::instance().getMember("connection").getReturn()
}
}
/**
* A call to the `cursor` method on a `peewee.Database` instance.
* https://docs.peewee-orm.com/en/latest/peewee/api.html#Database.cursor.
*/
class PeeweeDatabaseCursorCall extends PEP249::DatabaseCursor {
PeeweeDatabaseCursorCall() { this = Database::instance().getMember("cursor").getReturn() }
}
/**
* A call to the `execute_sql` method on a `peewee.Database` instance.
* See https://docs.peewee-orm.com/en/latest/peewee/api.html#Database.execute_sql.
*/
class PeeweeDatabaseExecuteSqlCall extends SqlExecution::Range, DataFlow::CallCfgNode {
PeeweeDatabaseExecuteSqlCall() {
this = Database::instance().getMember("execute_sql").getACall()
}
override DataFlow::Node getSql() { result in [this.getArg(0), this.getArgByName("sql")] }
}
}