Skip to content

Commit 5afead5

Browse files
tausbnRasmusWL
authored andcommitted
Python: Add Pycurl model
1 parent f1a7231 commit 5afead5

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,30 @@
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 `pycurl` PyPI package.
1518
*
1619
* See
1720
* - https://pypi.org/project/pycurl/
1821
* - https://pycurl.io/docs/latest/
1922
*/
20-
private module Pycurl {
23+
module Pycurl {
2124
/**
2225
* Provides models for the `pycurl.Curl` class
2326
*
2427
* See https://pycurl.io/docs/latest/curl.html.
2528
*/
2629
module Curl {
2730
/** Gets a reference to the `pycurl.Curl` class. */
28-
private API::Node classRef() { result = API::moduleImport("pycurl").getMember("Curl") }
31+
API::Node classRef() {
32+
result = API::moduleImport("pycurl").getMember("Curl")
33+
or
34+
result = ModelOutput::getATypeNode("pycurl.Curl~Subclass").getASubclass*()
35+
}
2936

3037
/** Gets a reference to an instance of `pycurl.Curl`. */
3138
private API::Node instance() { result = classRef().getReturn() }

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ private import semmle.python.frameworks.Httpx
2222
private import semmle.python.frameworks.Invoke
2323
private import semmle.python.frameworks.MarkupSafe
2424
private import semmle.python.frameworks.Multidict
25+
private import semmle.python.frameworks.Pycurl
2526
import semmle.python.frameworks.data.internal.ApiGraphModelsExtensions as Extensions
2627

2728
class FlaskViewClasses extends FindSubclassesSpec {
@@ -317,6 +318,12 @@ class Multidict extends FindSubclassesSpec {
317318
override API::Node getAlreadyModeledClass() { result = Multidict::MultiDictProxy::classRef() }
318319
}
319320

321+
class PyCurl extends FindSubclassesSpec {
322+
PyCurl() { this = "pycurl.Curl~Subclass" }
323+
324+
override API::Node getAlreadyModeledClass() { result = Pycurl::Curl::classRef() }
325+
}
326+
320327
bindingset[fullyQualified]
321328
predicate fullyQualifiedToYamlFormat(string fullyQualified, string type2, string path) {
322329
exists(int firstDot | firstDot = fullyQualified.indexOf(".", 0, 0) |

0 commit comments

Comments
 (0)