mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Python: Model rest_framework.exceptions.APIException
Only models the subclasses of `APIException` that share the same interface as `APIException` itself with regard to the `getBody` predicate.
This commit is contained in:
committed by
Rasmus Wriedt Larsen
parent
1f66659ff2
commit
43fe9ca31d
@@ -334,6 +334,23 @@ module RestFramework {
|
||||
* See https://www.django-rest-framework.org/api-guide/exceptions/#api-reference
|
||||
*/
|
||||
module ApiException {
|
||||
API::Node classRef() {
|
||||
exists(string className |
|
||||
className in [
|
||||
"APIException", "ValidationError", "ParseError", "AuthenticationFailed",
|
||||
"NotAuthenticated", "PermissionDenied", "NotFound", "NotAcceptable"
|
||||
] and
|
||||
result =
|
||||
API::moduleImport("rest_framework")
|
||||
.getMember("exceptions")
|
||||
.getMember(className)
|
||||
.getASubclass*()
|
||||
)
|
||||
or
|
||||
result =
|
||||
ModelOutput::getATypeNode("rest_framework.exceptions.APIException~Subclass").getASubclass*()
|
||||
}
|
||||
|
||||
/** A direct instantiation of `rest_framework.exceptions.ApiException` or subclass. */
|
||||
private class ClassInstantiation extends Http::Server::HttpResponse::Range,
|
||||
DataFlow::CallCfgNode
|
||||
@@ -351,6 +368,8 @@ module RestFramework {
|
||||
.getMember("exceptions")
|
||||
.getMember(className)
|
||||
.getACall()
|
||||
or
|
||||
this = classRef().getACall() and className = "APIException"
|
||||
}
|
||||
|
||||
override DataFlow::Node getBody() {
|
||||
|
||||
@@ -445,6 +445,12 @@ class DjangoFileField extends FindSubclassesSpec {
|
||||
}
|
||||
}
|
||||
|
||||
class RestFrameworkApiException extends FindSubclassesSpec {
|
||||
RestFrameworkApiException() { this = "rest_framework.exceptions.APIException~Subclass" }
|
||||
|
||||
override API::Node getAlreadyModeledClass() { result = RestFramework::ApiException::classRef() }
|
||||
}
|
||||
|
||||
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