Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
luke10481 committed Nov 13, 2023
1 parent 903b9c4 commit ec080eb
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions flask接口识别.txt
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."

0 comments on commit ec080eb

Please sign in to comment.