github / codeql

CodeQL: the libraries and queries that power security researchers around the world, as well as code scanning in GitHub Advanced Security
https://codeql.github.com
MIT License
7.73k stars 1.55k forks source link

Rust: Include `self` parameters in the CFG #18041

Closed paldepind closed 5 days ago

paldepind commented 5 days ago

Currently self parameters are not included in the CFG. This PR adds them.

This example:

    fn add(&mut self, a: i64, b: i64) {
        self.n += a + b;
    }

results in this CFG (previously the 2nd and 3rd node where not there):

flowchart TD
1["enter add"]
10["BlockExpr"]
11["self"]
12["FieldExpr"]
13["... += ..."]
14["ExprStmt"]
15["a"]
16["... + ..."]
17["b"]
2["exit add"]
3["exit add (normal)"]
4["SelfParam"]
5["self"]
6["a"]
7["Param"]
8["b"]
9["Param"]

1 --> 5
3 --> 2
4 --> 6
5 --> 4
6 -- match --> 7
7 --> 8
8 -- match --> 9
9 --> 14
10 --> 3
11 --> 12
12 --> 15
13 --> 10
14 --> 11
15 --> 17
16 --> 13
17 --> 16
paldepind commented 5 days ago

DCA looks fine I think. There seems to be an extraction error for googleapis-tonic, but that must be unrelated.