Python: add some stdlib models

This commit is contained in:
Taus
2023-10-10 14:28:17 +00:00
committed by Rasmus Wriedt Larsen
parent 4879a931eb
commit 6093bb9fd4
2 changed files with 27 additions and 3 deletions

View File

@@ -182,8 +182,10 @@ module Stdlib {
*/
module SplitResult {
/** Gets a reference to the `urllib.parse.SplitResult` class. */
private API::Node classRef() {
API::Node classRef() {
result = API::moduleImport("urllib").getMember("parse").getMember("SplitResult")
or
result = ModelOutput::getATypeNode("urllib.parse.SplitResult~Subclass").getASubclass*()
}
/**
@@ -2306,7 +2308,7 @@ module StdlibPrivate {
*/
module HttpConnection {
/** Gets a reference to the `http.client.HttpConnection` class. */
private API::Node classRef() {
API::Node classRef() {
exists(string className | className in ["HTTPConnection", "HTTPSConnection"] |
// Python 3
result = API::moduleImport("http").getMember("client").getMember(className)
@@ -2317,6 +2319,8 @@ module StdlibPrivate {
result =
API::moduleImport("six").getMember("moves").getMember("http_client").getMember(className)
)
or
result = ModelOutput::getATypeNode("http.client.HTTPConnection~Subclass").getASubclass*()
}
/**
@@ -3550,8 +3554,10 @@ module StdlibPrivate {
*/
module StringIO {
/** Gets a reference to the `io.StringIO` class. */
private API::Node classRef() {
API::Node classRef() {
result = API::moduleImport("io").getMember(["StringIO", "BytesIO"])
or
result = ModelOutput::getATypeNode("io.StringIO~Subclass").getASubclass*()
}
/**

View File

@@ -362,6 +362,24 @@ class SqlAlchemySession extends FindSubclassesSpec {
override API::Node getAlreadyModeledClass() { result = SqlAlchemy::Session::classRef() }
}
class UrlLibParseSplitResult extends FindSubclassesSpec {
UrlLibParseSplitResult() { this = "urllib.parse.SplitResult~Subclass" }
override API::Node getAlreadyModeledClass() { result = Stdlib::SplitResult::classRef() }
}
class StdlibHttpConnection extends FindSubclassesSpec {
StdlibHttpConnection() { this = "http.client.HTTPConnection~Subclass" }
override API::Node getAlreadyModeledClass() { result = StdlibPrivate::HttpConnection::classRef() }
}
class StringIO extends FindSubclassesSpec {
StringIO() { this = "io.StringIO~Subclass" }
override API::Node getAlreadyModeledClass() { result = StdlibPrivate::StringIO::classRef() }
}
bindingset[fullyQualified]
predicate fullyQualifiedToYamlFormat(string fullyQualified, string type2, string path) {
exists(int firstDot | firstDot = fullyQualified.indexOf(".", 0, 0) |