Whether the codeql result contains function call chain information.
- 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ả
test code:
```
[root@*** test_case]# cat f_open_test_0.cpp
#include
#include
using namespace std;
const char * do_getenv1(const char * name) {
return getenv(name);
}
[root@*** test_case]# cat f_open_test_a.cpp
#include "f_open_test_0.cpp"
extern const char * do_getenv1(const char *);
const char * do_getenv() {
return do_getenv1("FILENAME1");
}
[root@*** test_case]# cat f_open_test_b.cpp
#include "f_open_test_a.cpp"
extern const char * do_getenv();
int main(){
const char * filename1 = do_getenv();
FILE * file1 = fopen(filename1, "r");
}
```
running rule:
fopen-flow-from-getenv.ql
but results file don't contain the function call chain, results like this:
```
"results": [{
"ruleId": "cpp/huawei/member-variable-to-resource-leak",
"ruleIndex": 0,
"rule": {
"id": "cpp/huawei/member-variable-to-resource-leak",
"index": 0
},
"message": {
"text": "This 'fopen' uses data from [call to 'getenv'](1)."
},
"locations": [{
"physicalLocation": {
"artifactLocation": {
"uri": "f_open_test_b.cpp",
"uriBaseId": "%SRCROOT%",
"index": 0
},
"region": {
"startLine": 6,
"startColumn": 26,
"endColumn": 35
},
"contextRegion": {
"startLine": 4,
"endLine": 8,
"snippet": {
"text": "int main(){\n const char * filename1 = do_getenv();\n FILE * file1 = fopen(filename1, \"r\");\n}\n\n"
}
}
}
}],
"partialFingerprints": {
"primaryLocationLineHash": "6f35e497d744c2f6:1",
"primaryLocationStartColumnFingerprint": "21"
},
"relatedLocations": [{
"id": 1,
"physicalLocation": {
"artifactLocation": {
"uri": "f_open_test_0.cpp",
"uriBaseId": "%SRCROOT%",
"index": 1
},
"region": {
"startLine": 6,
"startColumn": 12,
"endColumn": 18
},
"contextRegion": {
"startLine": 4,
"endLine": 7,
"snippet": {
"text": "\nconst char * do_getenv1(const char * name) {\n return getenv(name);\n}\n"
}
}
},
"message": {
"text": "call to 'getenv'"
}
}]
}],
"columnKind": "utf16CodeUnits",
"properties": {
"semmle.formatSpecifier": "sarif-latest"
}
}]
```
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện ví dụ với f_open_test_0.cpp, f_open_test_a.cpp và f_open_test_b.cpp bằng fopen-flow-from-getenv.ql, sau đó kiểm tra kết quả SARIF được tạo và mục relatedLocations tương ứng. Xác định xem chuỗi lời gọi hàm mong đợi có được thể hiện trong kết quả hay không, đồng thời ghi lại hành vi hoặc thay đổi còn thiếu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- cpp
- Lĩnh vực
- devtools, security
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- 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
- 35/100