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

Skip to content

Commit dea61e1

Browse files
tausbnRasmusWL
authored andcommitted
Python: Add Urllib3 model
1 parent 1269a98 commit dea61e1

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@
99
private import python
1010
private import semmle.python.Concepts
1111
private import semmle.python.ApiGraphs
12+
private import semmle.python.frameworks.data.ModelsAsData
1213

1314
/**
15+
* INTERNAL: Do not use.
16+
*
1417
* Provides models for the `urllib3` PyPI package.
1518
*
1619
* See
1720
* - https://pypi.org/project/urllib3/
1821
* - https://urllib3.readthedocs.io/en/stable/reference/
1922
*/
20-
private module Urllib3 {
23+
module Urllib3 {
2124
/**
2225
* Provides models for the `urllib3.request.RequestMethods` class and subclasses, such
2326
* as the `urllib3.PoolManager` class
@@ -30,7 +33,7 @@ private module Urllib3 {
3033
*/
3134
module PoolManager {
3235
/** Gets a reference to the `urllib3.PoolManager` class. */
33-
private API::Node classRef() {
36+
API::Node classRef() {
3437
result =
3538
API::moduleImport("urllib3")
3639
.getMember(["PoolManager", "ProxyManager", "HTTPConnectionPool", "HTTPSConnectionPool"])
@@ -40,6 +43,8 @@ private module Urllib3 {
4043
.getMember("request")
4144
.getMember("RequestMethods")
4245
.getASubclass+()
46+
or
47+
result = ModelOutput::getATypeNode("urllib3.PoolManager~Subclass").getASubclass*()
4348
}
4449

4550
/**

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ private import semmle.python.frameworks.Pycurl
2626
private import semmle.python.frameworks.RestFramework
2727
private import semmle.python.frameworks.SqlAlchemy
2828
private import semmle.python.frameworks.Tornado
29+
private import semmle.python.frameworks.Urllib3
2930
import semmle.python.frameworks.data.internal.ApiGraphModelsExtensions as Extensions
3031

3132
class FlaskViewClasses extends FindSubclassesSpec {
@@ -397,6 +398,12 @@ class TornadoRequest extends FindSubclassesSpec {
397398
}
398399
}
399400

401+
class Urllib3PoolManager extends FindSubclassesSpec {
402+
Urllib3PoolManager() { this = "urllib3.PoolManager~Subclass" }
403+
404+
override API::Node getAlreadyModeledClass() { result = Urllib3::PoolManager::classRef() }
405+
}
406+
400407
bindingset[fullyQualified]
401408
predicate fullyQualifiedToYamlFormat(string fullyQualified, string type2, string path) {
402409
exists(int firstDot | firstDot = fullyQualified.indexOf(".", 0, 0) |

0 commit comments

Comments
 (0)