@@ -7,6 +7,7 @@ import rust
7
7
private import codeql.rust.Concepts
8
8
private import codeql.rust.dataflow.DataFlow
9
9
private import codeql.rust.dataflow.TaintTracking
10
+ private import codeql.rust.dataflow.internal.Node
10
11
11
12
/**
12
13
* A taint configuration for taint reach (flow to any node from any modeled source).
@@ -21,11 +22,27 @@ private module TaintReachFlow = TaintTracking::Global<TaintReachConfig>;
21
22
22
23
/**
23
24
* 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).
24
28
*/
25
- int getTaintedNodesCount ( ) { result = count ( DataFlow:: Node n | TaintReachFlow:: flowTo ( n ) ) }
29
+ int getTaintedNodesCount ( ) {
30
+ result = count ( DataFlow:: Node n | TaintReachFlow:: flowTo ( n ) and not n instanceof FlowSummaryNode )
31
+ }
32
+
33
+ /**
34
+ * Gets the total number of data flow nodes.
35
+ *
36
+ * We don't include flow summary nodes, as their number is unstable (varies when models
37
+ * are added).
38
+ */
39
+ int getTotalNodesCount ( ) { result = count ( DataFlow:: Node n | not n instanceof FlowSummaryNode ) }
26
40
27
41
/**
28
42
* Gets the proportion of data flow nodes that taint reaches (from any source),
29
43
* expressed as a count per million nodes.
44
+ *
45
+ * We don't include flow summary nodes, as their number is unstable (varies when models
46
+ * are added).
30
47
*/
31
- float getTaintReach ( ) { result = ( getTaintedNodesCount ( ) * 1000000.0 ) / count ( DataFlow :: Node n ) }
48
+ float getTaintReach ( ) { result = ( getTaintedNodesCount ( ) * 1000000.0 ) / getTotalNodesCount ( ) }
0 commit comments