github / github/codeql

To trace variables changed

未关闭
#9,761 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
question
主要语言
CodeQL
星标
10.1k
派生
2.1k
平均合并
2 天 15 小时
30 天内合并 PR
141

描述

A snippet:
```
void impl_write_extend(int _b,int _c) {
printf("%d", _b);

if(_b>10 && _b<10) {

_b = 10;
}

_c = 20;
}

void impl_write(int _a) {
_a = 30;
impl_write_extend(_a, _a);
}
```

I expected to make a following path :

> 1. impl_write(int _a)
> 2. _a = 30
> 3. impl_write_extend(_a, _a)
> 4. void impl_write_extend(int _b,int _c)
> 5. if(_b>10 && _b<10)
> 6. _b = 10;

A below query is not working as my intention:

```
import cpp
import semmle.code.cpp.dataflow.TaintTracking
import semmle.code.cpp.security.Security
import DataFlow::PathGraph

class VA_TO_VA extends TaintTracking::Configuration {
VA_TO_VA() { this = "VA_TO_VA" }

override predicate isSource(DataFlow::Node source) {

exists(VariableAccess va|
va = source.asExpr()
)
}

override predicate isSink(DataFlow::Node node) {
exists(AssignExpr ae|
ae.getLValue() = node.asExpr()
)
}
}

from DataFlow::PathNode source, DataFlow::PathNode sink, VA_TO_VA config
where config.hasFlowPath(source, sink)
select sink, source, sink, "VA_TO_VA"
```

AssignExpr can not be used as a node in the tainted flow?

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。