mirror of
https://github.com/github/codeql.git
synced 2026-02-19 00:13:44 +01:00
WIP rest of modeling done so far
This commit is contained in:
@@ -7,6 +7,14 @@ private import semmle.python.frameworks.FastApi
|
||||
private import semmle.python.frameworks.Django
|
||||
import semmle.python.frameworks.data.internal.ApiGraphModelsExtensions as Extensions
|
||||
|
||||
// FIXME: I think the implementation below for `getAlreadyModeledClass` is wrong, since
|
||||
// it uses `.getASubclass*()` for flask/fastAPI (and initially also Django, I just fixed
|
||||
// it for django while discovering this problem). Basically, I fear that it if library
|
||||
// defines class A and B, where B is a subclass of A, the automated modeling might only
|
||||
// find B...
|
||||
//
|
||||
// I doesn't seem to be the case, which is probably why I didn't discover this, but on
|
||||
// top of my head I can't really tell why.
|
||||
class FlaskViewClasses extends FindSubclassesSpec {
|
||||
FlaskViewClasses() { this = "flask.View~Subclass" }
|
||||
|
||||
@@ -21,6 +29,36 @@ class FlaskMethodViewClasses extends FindSubclassesSpec {
|
||||
override FlaskViewClasses getSuperClass() { any() }
|
||||
}
|
||||
|
||||
class FastApiRouter extends FindSubclassesSpec {
|
||||
FastApiRouter() { this = "fastapi.APIRouter~Subclass" }
|
||||
|
||||
override API::Node getAlreadyModeledClass() { result = FastApi::ApiRouter::cls() }
|
||||
}
|
||||
|
||||
class DjangoForms extends FindSubclassesSpec {
|
||||
DjangoForms() { this = "django.forms.BaseForm~Subclass" }
|
||||
|
||||
override API::Node getAlreadyModeledClass() {
|
||||
result = any(Django::Forms::Form::ModeledSubclass subclass)
|
||||
}
|
||||
}
|
||||
|
||||
class DjangoView extends FindSubclassesSpec {
|
||||
DjangoView() { this = "Django.Views.View~Subclass" }
|
||||
|
||||
override API::Node getAlreadyModeledClass() {
|
||||
result = any(Django::Views::View::ModeledSubclass subclass)
|
||||
}
|
||||
}
|
||||
|
||||
class DjangoField extends FindSubclassesSpec {
|
||||
DjangoField() { this = "Django.Forms.Field~Subclass" }
|
||||
|
||||
override API::Node getAlreadyModeledClass() {
|
||||
result = any(Django::Forms::Field::ModeledSubclass subclass)
|
||||
}
|
||||
}
|
||||
|
||||
bindingset[fullyQualified]
|
||||
predicate fullyQualifiedToYamlFormat(string fullyQualified, string type2, string path) {
|
||||
exists(int firstDot | firstDot = fullyQualified.indexOf(".", 0, 0) |
|
||||
|
||||
Reference in New Issue
Block a user