Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 947aa09

Browse files
tausbnRasmusWL
authored andcommitted
Python: Add aiohttp.ClientSession model
1 parent f5bed2d commit 947aa09

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ private import semmle.python.frameworks.internal.SelfRefMixin
1414
private import semmle.python.frameworks.Multidict
1515
private import semmle.python.frameworks.Yarl
1616
private import semmle.python.frameworks.internal.InstanceTaintStepsHelper
17+
private import semmle.python.frameworks.data.ModelsAsData
1718

1819
/**
1920
* INTERNAL: Do not use.
@@ -706,19 +707,23 @@ module AiohttpWebModel {
706707
}
707708

708709
/**
710+
* INTERNAL: Do not use.
711+
*
709712
* Provides models for the web server part (`aiohttp.client`) of the `aiohttp` PyPI package.
710713
* See https://docs.aiohttp.org/en/stable/client.html
711714
*/
712-
private module AiohttpClientModel {
715+
module AiohttpClientModel {
713716
/**
714717
* Provides models for the `aiohttp.ClientSession` class
715718
*
716719
* See https://docs.aiohttp.org/en/stable/client_reference.html#aiohttp.ClientSession.
717720
*/
718721
module ClientSession {
719722
/** Gets a reference to the `aiohttp.ClientSession` class. */
720-
private API::Node classRef() {
723+
API::Node classRef() {
721724
result = API::moduleImport("aiohttp").getMember("ClientSession")
725+
or
726+
result = ModelOutput::getATypeNode("aiohttp.ClientSession~Subclass").getASubclass*()
722727
}
723728

724729
/** Gets a reference to an instance of `aiohttp.ClientSession`. */

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ private import semmle.python.frameworks.Stdlib
1616
private import semmle.python.frameworks.Requests
1717
private import semmle.python.frameworks.Starlette
1818
private import semmle.python.frameworks.ClickhouseDriver
19+
private import semmle.python.frameworks.Aiohttp
1920
import semmle.python.frameworks.data.internal.ApiGraphModelsExtensions as Extensions
2021

2122
class FlaskViewClasses extends FindSubclassesSpec {
@@ -241,6 +242,14 @@ class ClickhouseClient extends FindSubclassesSpec {
241242
override API::Node getAlreadyModeledClass() { result = ClickhouseDriver::Client::subclassRef() }
242243
}
243244

245+
class AiohttpSession extends FindSubclassesSpec {
246+
AiohttpSession() { this = "aiohttp.ClientSession~Subclass" }
247+
248+
override API::Node getAlreadyModeledClass() {
249+
result = AiohttpClientModel::ClientSession::classRef()
250+
}
251+
}
252+
244253
bindingset[fullyQualified]
245254
predicate fullyQualifiedToYamlFormat(string fullyQualified, string type2, string path) {
246255
exists(int firstDot | firstDot = fullyQualified.indexOf(".", 0, 0) |

0 commit comments

Comments
 (0)