Skip to content

Commit f55d7d6

Browse files
committed
python: model XPathEvaluator
1 parent 3bb17be commit f55d7d6

File tree

2 files changed

+16
-1
lines changed
  • python/ql
    • lib/semmle/python/frameworks
    • test/library-tests/frameworks/lxml

2 files changed

+16
-1
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,19 @@ private module Lxml {
7070

7171
override string getName() { result = "lxml.etree" }
7272
}
73+
74+
class XPathEvaluatorCall extends XPathExecution::Range, DataFlow::CallCfgNode {
75+
XPathEvaluatorCall() {
76+
this =
77+
API::moduleImport("lxml")
78+
.getMember("etree")
79+
.getMember("XPathEvaluator")
80+
.getReturn()
81+
.getACall()
82+
}
83+
84+
override DataFlow::Node getXPath() { result = this.getArg(0) }
85+
86+
override string getName() { result = "lxml.etree" }
87+
}
7388
}

python/ql/test/library-tests/frameworks/lxml/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ def test_ETXpath_class():
1818
def test_XPathEvaluator_class():
1919
root = etree.XML("<root><a>TEXT</a></root>")
2020
search_root = etree.XPathEvaluator(root)
21-
text = search_root("path")[0] # $ MISSING: getXPath="path"
21+
text = search_root("path")[0] # $ getXPath="path"

0 commit comments

Comments
 (0)