CodeQL Python query runs extremely slow on medium-sized project using TaintTracking::Global
- Ngôn ngữ chính
- CodeQL
- Star
- 10.1k
- Fork
- 2.1k
- Merge trung bình
- 2 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 141
Mô tả
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!
Hướng dẫn đóng góp
Hướng nghiên cứu
Không có tệp repository hoặc test nào được nêu tên. Hãy bắt đầu bằng cách tái hiện truy vấn TaintTracking::Global đã cho đối với dự án CVE-2024-23637, sau đó kiểm tra các định nghĩa source và sink, bao gồm cách sử dụng getQualifiedName trong VSCode. Được xem là hoàn thành khi đã ghi lại nguyên nhân về hiệu năng hoặc hướng dẫn tối ưu hóa, cùng với cách đặt tên sink Python chính xác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python, vscode
- Lĩnh vực
- devtools, security
- Loại issue
- Lỗi
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100