|
1 | 1 | /**
|
2 | 2 | * Provides classes modeling security-relevant aspects of the `urllib3` PyPI package.
|
3 |
| - * See https://urllib3.readthedocs.io/en/stable/reference/ |
| 3 | + * |
| 4 | + * See |
| 5 | + * - https://pypi.org/project/urllib3/ |
| 6 | + * - https://urllib3.readthedocs.io/en/stable/reference/ |
4 | 7 | */
|
5 | 8 |
|
6 | 9 | private import python
|
7 | 10 | private import semmle.python.Concepts
|
8 | 11 | private import semmle.python.ApiGraphs
|
9 | 12 |
|
10 | 13 | /**
|
11 |
| - * Provides models for the `Urllib3` PyPI package. |
12 |
| - * see https://urllib3.readthedocs.io/en/stable/reference/ |
| 14 | + * Provides models for the `urllib3` PyPI package. |
| 15 | + * |
| 16 | + * See |
| 17 | + * - https://pypi.org/project/urllib3/ |
| 18 | + * - https://urllib3.readthedocs.io/en/stable/reference/ |
13 | 19 | */
|
14 | 20 | private module Urllib3 {
|
15 | 21 | /**
|
16 |
| - * Provides models for the `urllib3.PoolManager` class |
| 22 | + * Provides models for the `urllib3.request.RequestMethods` class and subclasses, such |
| 23 | + * as the `urllib3.PoolManager` class |
17 | 24 | *
|
18 |
| - * See https://urllib3.readthedocs.io/en/stable/reference/urllib3.poolmanager.html. |
| 25 | + * See |
| 26 | + * - https://urllib3.readthedocs.io/en/stable/reference/urllib3.request.html#urllib3.request.RequestMethods |
| 27 | + * |
| 28 | + * |
| 29 | + * https://urllib3.readthedocs.io/en/stable/reference/urllib3.poolmanager.html. |
19 | 30 | */
|
20 | 31 | module PoolManager {
|
21 | 32 | /** Gets a reference to the `urllib3.PoolManager` class. */
|
22 |
| - private API::Node classRef() { result = API::moduleImport("urllib3").getMember("PoolManager") } |
| 33 | + private API::Node classRef() { |
| 34 | + result = |
| 35 | + API::moduleImport("urllib3") |
| 36 | + .getMember(["PoolManager", "ProxyManager", "HTTPConnectionPool", "HTTPSConnectionPool"]) |
| 37 | + or |
| 38 | + result = |
| 39 | + API::moduleImport("urllib3") |
| 40 | + .getMember("request") |
| 41 | + .getMember("RequestMethods") |
| 42 | + .getASubclass+() |
| 43 | + } |
23 | 44 |
|
24 |
| - /** Gets a reference to an instance of `urllib3.PoolManager`. */ |
| 45 | + /** Gets a reference to an instance of a `urllib3.request.RequestMethods` subclass. */ |
25 | 46 | private API::Node instance() { result = classRef().getReturn() }
|
26 | 47 |
|
| 48 | + /** |
| 49 | + * A call to a method making an outgoing request. |
| 50 | + * |
| 51 | + * See |
| 52 | + * - https://urllib3.readthedocs.io/en/stable/reference/urllib3.request.html#urllib3.request.RequestMethods |
| 53 | + * - https://urllib3.readthedocs.io/en/stable/reference/urllib3.connectionpool.html#urllib3.HTTPConnectionPool.urlopen |
| 54 | + */ |
27 | 55 | private class RequestCall extends HTTP::Client::Request::Range, DataFlow::CallCfgNode {
|
28 | 56 | RequestCall() {
|
29 | 57 | this =
|
30 |
| - instance().getMember(["request", "request_encode_url", "request_encode_body"]).getACall() |
31 |
| - } |
32 |
| - |
33 |
| - override DataFlow::Node getAUrlPart() { result in [this.getArg(1), this.getArgByName("url")] } |
34 |
| - |
35 |
| - override string getFramework() { result = "urllib3.PoolManager" } |
36 |
| - |
37 |
| - override predicate disablesCertificateValidation( |
38 |
| - DataFlow::Node disablingNode, DataFlow::Node argumentOrigin |
39 |
| - ) { |
40 |
| - // TODO: Look into disabling certificate validation |
41 |
| - none() |
| 58 | + instance() |
| 59 | + .getMember(["request", "request_encode_url", "request_encode_body", "urlopen"]) |
| 60 | + .getACall() |
42 | 61 | }
|
43 |
| - } |
44 |
| - |
45 |
| - private class UrlOpenCall extends HTTP::Client::Request::Range, DataFlow::CallCfgNode { |
46 |
| - UrlOpenCall() { this = instance().getMember("urlopen").getACall() } |
47 | 62 |
|
48 | 63 | override DataFlow::Node getAUrlPart() { result in [this.getArg(1), this.getArgByName("url")] }
|
49 | 64 |
|
|
0 commit comments