Python: CG trace: Add some tests using classes · ByteDecoder/codeql@89e8202 · GitHub
Skip to content

Commit 89e8202

Browse files
committed
Python: CG trace: Add some tests using classes
1 parent eeeadad commit 89e8202

3 files changed

Lines changed: 53 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions

python/tools/recorded-call-graph-metrics/ql/RecordedCalls.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ class XMLRecordedCall extends XMLElement {
2424
// 2. result.getCall() issubset this.getCall()
2525
not exists(Call call | call = result.getCall() | not this.getCall() = call)
2626
}
27+
28+
override string toString() {
29+
result = this.getName() + " (<..>/" + this.getXMLCall().get_filename_data().regexpCapture(".*/([^/]+)$", 1) + ":" + this.getXMLCall().get_linenum_data() + ")"
30+
}
2731
}
2832

2933
class XMLCall extends XMLElement {
@@ -74,6 +78,10 @@ class XMLPythonCallee extends XMLCallee {
7478

7579
Function getCallee() {
7680
result.getLocation().hasLocationInfo(this.get_filename_data(), this.get_linenum_data(), _, _, _)
81+
or
82+
// if function has decorator, the call will be recorded going to the first
83+
result.getADecorator().getLocation().hasLocationInfo(this.get_filename_data(), this.get_linenum_data(), _, _, _)
84+
7785
}
7886
}
7987

python/tools/recorded-call-graph-metrics/recreate-db.sh

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)