Skip to content

Commit 1269a98

Browse files
tausbnRasmusWL
authored andcommitted
Python: Add Tornado models
1 parent 6093bb9 commit 1269a98

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

python/ql/lib/semmle/python/frameworks/Tornado.qll

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,11 @@ module Tornado {
218218
*/
219219
module Application {
220220
/** Gets a reference to the `tornado.web.Application` class. */
221-
API::Node classRef() { result = web().getMember("Application") }
221+
API::Node classRef() {
222+
result = web().getMember("Application")
223+
or
224+
result = ModelOutput::getATypeNode("tornado.web.Application~Subclass").getASubclass*()
225+
}
222226

223227
/**
224228
* A source of instances of `tornado.web.Application`, extend this class to model new instances.
@@ -275,7 +279,12 @@ module Tornado {
275279
*/
276280
module HttpServerRequest {
277281
/** Gets a reference to the `tornado.httputil.HttpServerRequest` class. */
278-
API::Node classRef() { result = httputil().getMember("HttpServerRequest") }
282+
API::Node classRef() {
283+
result = httputil().getMember("HttpServerRequest")
284+
or
285+
result =
286+
ModelOutput::getATypeNode("tornado.httputil.HttpServerRequest~Subclass").getASubclass*()
287+
}
279288

280289
/**
281290
* A source of instances of `tornado.httputil.HttpServerRequest`, extend this class to model new instances.

python/ql/src/meta/ClassHierarchy/Find.ql

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ private import semmle.python.frameworks.Multidict
2525
private import semmle.python.frameworks.Pycurl
2626
private import semmle.python.frameworks.RestFramework
2727
private import semmle.python.frameworks.SqlAlchemy
28+
private import semmle.python.frameworks.Tornado
2829
import semmle.python.frameworks.data.internal.ApiGraphModelsExtensions as Extensions
2930

3031
class FlaskViewClasses extends FindSubclassesSpec {
@@ -380,6 +381,22 @@ class StringIO extends FindSubclassesSpec {
380381
override API::Node getAlreadyModeledClass() { result = StdlibPrivate::StringIO::classRef() }
381382
}
382383

384+
class TornadoApplication extends FindSubclassesSpec {
385+
TornadoApplication() { this = "tornado.web.Application~Subclass" }
386+
387+
override API::Node getAlreadyModeledClass() {
388+
result = Tornado::TornadoModule::Web::Application::classRef()
389+
}
390+
}
391+
392+
class TornadoRequest extends FindSubclassesSpec {
393+
TornadoRequest() { this = "tornado.httputil.HttpServerRequest~Subclass" }
394+
395+
override API::Node getAlreadyModeledClass() {
396+
result = Tornado::TornadoModule::HttpUtil::HttpServerRequest::classRef()
397+
}
398+
}
399+
383400
bindingset[fullyQualified]
384401
predicate fullyQualifiedToYamlFormat(string fullyQualified, string type2, string path) {
385402
exists(int firstDot | firstDot = fullyQualified.indexOf(".", 0, 0) |

0 commit comments

Comments
 (0)