github / github/codeql

CodeQL Python query runs extremely slow on medium-sized project using TaintTracking::Global

未關閉
#19,928 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
question
主要語言
CodeQL
星號
10.1k
分支
2.1k
平均合併
2 天 15 小時
30 天內合併 PR
141

描述

I'm experiencing very slow performance when running a CodeQL query on a Python project using `TaintTracking::Global`. The analysis never finishes, even after more than **2 hours**, on a project that I believe is not very large. Below are some details:

* **CVE project**: CVE-2024-23637
* **Python files**: 263
* **Total lines**: \~88,981
* **Sources**: < 200
* **Sinks**: < 200
* **Tracking config**: `TaintTracking::Global`

My query looks like this:

```ql
module RemoteToFileConfiguration implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) {
MySources::isSource(source)
}

predicate isSink(DataFlow::Node sink) {
MySinks::isMySink(sink)
}
}

module Flow = TaintTracking::Global;
import Flow::PathGraph

from Flow::PathNode source, Flow::PathNode sink
where Flow::flowPath(source, sink)
select sink.getNode(), source, sink, "Flow path from source to sink"
```

I defined sinks or sources like this (simplified):

```ql
module MySinks {
class Sink extends DataFlow::Node {
Sink() {
exists(FunctionValue func, Call call |
func.getQualifiedName() = "run_code" or
func.getQualifiedName() = "check_syntax_error" or
...
call.getFunc().pointsTo(func) and
this = DataFlow::exprNode(call.getAnArg())
)
}
}

predicate isMySink(DataFlow::Node sink) {
exists(Sink s | s = sink)
}
}
```

### My questions:

1. Why is the performance so slow in this case?
2. Are there any best practices for optimizing `TaintTracking::Global` on Python?
3. I tried using `func.getQualifiedName()` with a full path like `"Module xml.etree.ElementInclude.Function default_loader"`, but it didn’t work in VSCode (the function wasn't found). Is there a correct way to define sinks using fully qualified names for Python?

Thank you very much for any guidance or suggestions!

貢獻指南

開啟貢獻指南

研究方向

No repository file or test is named. Start by reproducing the shown TaintTracking::Global query against the CVE-2024-23637 project, then inspect the source and sink definitions, including the getQualifiedName usage in VSCode. Done means documenting the performance cause or optimization guidance and the correct Python sink naming approach.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python, vscode
領域
devtools, security
Issue 類型
缺陷
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
需要釐清
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。