Skip to content

Commit 50bf246

Browse files
committed
Rust: Adjust the taint reach metric for better stability.
1 parent 3af10d2 commit 50bf246

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

rust/ql/src/queries/summary/TaintReach.qll

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import rust
77
private import codeql.rust.Concepts
88
private import codeql.rust.dataflow.DataFlow
99
private import codeql.rust.dataflow.TaintTracking
10+
private import codeql.rust.dataflow.internal.Node
1011

1112
/**
1213
* A taint configuration for taint reach (flow to any node from any modeled source).
@@ -21,11 +22,17 @@ private module TaintReachFlow = TaintTracking::Global<TaintReachConfig>;
2122

2223
/**
2324
* Gets the total number of data flow nodes that taint reaches (from any source).
25+
*
26+
* We don't include flow summary nodes, as their number is unstable (varies when models
27+
* are added).
2428
*/
25-
int getTaintedNodesCount() { result = count(DataFlow::Node n | TaintReachFlow::flowTo(n)) }
29+
int getTaintedNodesCount() { result = count(DataFlow::Node n | TaintReachFlow::flowTo(n) and not n instanceof FlowSummaryNode) }
2630

2731
/**
2832
* Gets the proportion of data flow nodes that taint reaches (from any source),
2933
* expressed as a count per million nodes.
34+
*
35+
* We don't include flow summary nodes, as their number is unstable (varies when models
36+
* are added).
3037
*/
31-
float getTaintReach() { result = (getTaintedNodesCount() * 1000000.0) / count(DataFlow::Node n) }
38+
float getTaintReach() { result = (getTaintedNodesCount() * 1000000.0) / count(DataFlow::Node n | not n instanceof FlowSummaryNode) }

0 commit comments

Comments
 (0)