Skip to content

Commit 9e01338

Browse files
committed
Query only vulnerable methods
1 parent 0be2c6b commit 9e01338

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

python/ql/src/experimental/semmle/python/frameworks/SqlAlchemy.qll

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,25 @@ private module SqlAlchemy {
8080
* See https://docs.sqlalchemy.org/en/14/orm/query.html?highlight=query#sqlalchemy.orm.Query
8181
*/
8282
private class SqlAlchemyQueryCall extends DataFlow::CallCfgNode, SqlExecution::Range {
83-
SqlAlchemyQueryCall() { this = getSqlAlchemyQueryInstance().getAMember().getACall() }
83+
SqlAlchemyQueryCall() {
84+
this =
85+
getSqlAlchemyQueryInstance()
86+
.getMember(any(SqlAlchemyVulnerableMethodNames methodName))
87+
.getACall()
88+
}
8489

8590
override DataFlow::Node getSql() { result = this.getArg(0) }
8691
}
8792

93+
/**
94+
* This class represents a list of methods vulnerable to sql injection.
95+
*
96+
* See https://github.com/jty-team/codeql/pull/2#issue-611592361
97+
*/
98+
private class SqlAlchemyVulnerableMethodNames extends string {
99+
SqlAlchemyVulnerableMethodNames() { this in ["filter", "filter_by", "group_by", "order_by"] }
100+
}
101+
88102
/**
89103
* Additional taint-steps for `sqlalchemy.text()`
90104
*

0 commit comments

Comments
 (0)