Skip to content

Commit 17aa289

Browse files
committed
python: model (xpathEval from) libxml2
1 parent e8649d8 commit 17aa289

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

docs/codeql/support/reusables/frameworks.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,5 @@ Python built-in support
204204
pycryptodomex, Cryptography library
205205
rsa, Cryptography library
206206
MarkupSafe, Escaping Library
207+
libxml2, XML processing library
207208
lxml, XML processing library

python/ql/lib/semmle/python/Frameworks.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ private import semmle.python.frameworks.FlaskSqlAlchemy
2222
private import semmle.python.frameworks.Idna
2323
private import semmle.python.frameworks.Invoke
2424
private import semmle.python.frameworks.Jmespath
25+
private import semmle.python.frameworks.Libxml2
2526
private import semmle.python.frameworks.Lxml
2627
private import semmle.python.frameworks.MarkupSafe
2728
private import semmle.python.frameworks.Multidict
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Provides classes modeling security-relevant aspects of the `libxml2` PyPI package.
3+
*
4+
* See
5+
* - https://pypi.org/project/libxml2-python3/
6+
* - http://xmlsoft.org/python.html
7+
*/
8+
9+
private import python
10+
private import semmle.python.dataflow.new.DataFlow
11+
private import semmle.python.Concepts
12+
private import semmle.python.ApiGraphs
13+
14+
/**
15+
* Provides classes modeling security-relevant aspects of the `libxml2` PyPI package
16+
*
17+
* See
18+
* - https://pypi.org/project/libxml2-python3/
19+
* - http://xmlsoft.org/python.html
20+
*/
21+
private module Libxml2 {
22+
/**
23+
* A call to the `xpathEval` method of a parsed document.
24+
*
25+
* import libxml2
26+
* tree = libxml2.parseFile("file.xml")
27+
* r = tree.xpathEval('`sink`')
28+
*
29+
* See http://xmlsoft.org/python.html
30+
*/
31+
class XpathEvalCall extends XPathExecution::Range, DataFlow::CallCfgNode {
32+
XpathEvalCall() {
33+
this =
34+
API::moduleImport("libxml2")
35+
.getMember("parseFile")
36+
.getReturn()
37+
.getMember("xpathEval")
38+
.getACall()
39+
}
40+
41+
override DataFlow::Node getXPath() { result = this.getArg(0) }
42+
43+
// TODO: implement when we get call nodes
44+
override DataFlow::Node getTree() { none() }
45+
46+
override string getName() { result = "libxml2" }
47+
}
48+
}

0 commit comments

Comments
 (0)