-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import python | ||
import semmle.python.web.flask.General | ||
|
||
/** | ||
* 定义一个类来代表 Flask 的 HTTP 请求参数。 | ||
*/ | ||
class FlaskHttpRequestParam extends HTTP::RequestParam { | ||
FlaskHttpRequestParam() { | ||
// 查找形如 `request.args.get('...')` 的模式 | ||
this.asExpr() = any(CallNode call | | ||
call.getNode().getFunc().(Attribute).getName() = "get" and | ||
call.getNode().getFunc().(Attribute).getObject().(Name).getId() = "args" and | ||
call.getNode().getScope() instanceof FlaskRouteHandler | ||
).getArg(0) | ||
} | ||
} | ||
|
||
/** | ||
* 扩展标准的 isSource 函数,以包括 Flask HTTP 请求参数作为潜在的数据源。 | ||
*/ | ||
predicate isFlaskSource(DataFlow::Node source) { | ||
source instanceof FlaskHttpRequestParam | ||
} | ||
|
||
from isFlaskSource(src) | ||
select src, "This is a potential source of user input." |