mirror of
https://github.com/github/codeql.git
synced 2025-12-18 01:33:15 +01:00
WIP: Flask View class modeling for restplus
Based on some DBs I had that contained dependencies
This commit is contained in:
44
python/ql/src/meta/ClassHierarchy/Find.ql
Normal file
44
python/ql/src/meta/ClassHierarchy/Find.ql
Normal file
@@ -0,0 +1,44 @@
|
||||
import python
|
||||
import semmle.python.dataflow.new.DataFlow
|
||||
private import semmle.python.ApiGraphs
|
||||
import semmle.python.frameworks.internal.SubclassFinder::NotExposed
|
||||
private import semmle.python.frameworks.Flask
|
||||
private import semmle.python.frameworks.FastApi
|
||||
private import semmle.python.frameworks.Django
|
||||
import semmle.python.frameworks.data.internal.ApiGraphModelsExtensions as Extensions
|
||||
|
||||
class FlaskViewClasses extends FindSubclassesSpec {
|
||||
FlaskViewClasses() { this = "flask.View~Subclass" }
|
||||
|
||||
override API::Node getAlreadyModeledClass() { result = Flask::Views::View::subclassRef() }
|
||||
}
|
||||
|
||||
class FlaskMethodViewClasses extends FindSubclassesSpec {
|
||||
FlaskMethodViewClasses() { this = "flask.MethodView~Subclass" }
|
||||
|
||||
override API::Node getAlreadyModeledClass() { result = Flask::Views::MethodView::subclassRef() }
|
||||
|
||||
override FlaskViewClasses getSuperClass() { any() }
|
||||
}
|
||||
|
||||
bindingset[fullyQualified]
|
||||
predicate fullyQualifiedToYamlFormat(string fullyQualified, string type2, string path) {
|
||||
exists(int firstDot | firstDot = fullyQualified.indexOf(".", 0, 0) |
|
||||
type2 = fullyQualified.prefix(firstDot) and
|
||||
path =
|
||||
("Member[" + fullyQualified.suffix(firstDot + 1).replaceAll(".", "].Member[") + "]")
|
||||
.replaceAll(".Member[__init__].", "")
|
||||
.replaceAll("Member[__init__].", "")
|
||||
)
|
||||
}
|
||||
|
||||
from FindSubclassesSpec spec, string newModelFullyQualified, string type2, string path, Module mod
|
||||
where
|
||||
newModel(spec, newModelFullyQualified, _, mod, _) and
|
||||
not exists(FindSubclassesSpec subclass | subclass.getSuperClass() = spec |
|
||||
newModel(subclass, newModelFullyQualified, _, mod, _)
|
||||
) and
|
||||
not exists(mod.getLocation().getFile().getRelativePath()) and
|
||||
fullyQualifiedToYamlFormat(newModelFullyQualified, type2, path) and
|
||||
not Extensions::typeModel(spec, type2, path)
|
||||
select spec.(string), type2, path
|
||||
Reference in New Issue
Block a user