Skip to content

Commit 3e0e374

Browse files
committed
Rust: Remove unnecessary edges.
1 parent 4d0c53d commit 3e0e374

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

rust/ql/src/queries/security/CWE-696/BadCtorInitialization.ql

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,17 @@ class StdCall extends Expr {
4040
class PathElement = AstNode;
4141

4242
query predicate edges(PathElement pred, PathElement succ) {
43-
// starting edge
43+
// starting edge (`#[ctor]` / `#[dtor]` attribute to call)
4444
exists(CtorAttr ctor, Function f, CallExprBase call |
4545
f.getAnAttr() = ctor and
4646
call.getEnclosingCallable() = f and
47-
pred = ctor and // source
48-
succ = call // flow or sink node
47+
pred = ctor and
48+
succ = call
4949
)
5050
or
51-
// transitive edge
51+
// transitive edge (call to call)
5252
exists(Function f |
53+
edges(_, pred) and
5354
pred.(CallExprBase).getStaticTarget() = f and
5455
succ.(CallExprBase).getEnclosingCallable() = f
5556
)

rust/ql/test/query-tests/security/CWE-696/BadCTorInitialization.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,5 @@ edges
5050
| test.rs:147:5:147:20 | call_target3_1(...) | test.rs:126:9:126:16 | stderr(...) |
5151
| test.rs:147:5:147:20 | call_target3_1(...) | test.rs:126:9:126:44 | ... .write_all(...) |
5252
| test.rs:151:1:151:7 | Attr | test.rs:153:5:153:12 | bad3_3(...) |
53-
| test.rs:157:5:157:20 | call_target3_1(...) | test.rs:126:9:126:16 | stderr(...) |
54-
| test.rs:157:5:157:20 | call_target3_1(...) | test.rs:126:9:126:44 | ... .write_all(...) |
5553
| test.rs:169:1:169:7 | Attr | test.rs:171:5:171:15 | ... .write(...) |
5654
| test.rs:169:1:169:7 | Attr | test.rs:171:5:171:15 | ...::stdout(...) |

0 commit comments

Comments
 (0)