Skip to content

Commit e64d083

Browse files
committed
Rust: Lets also output the total number of nodes to make understanding this easier.
1 parent 50bf246 commit e64d083

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ predicate taintStats(string key, int value) {
189189
or
190190
key = "Taint reach - nodes tainted" and value = getTaintedNodesCount()
191191
or
192+
key = "Taint reach - total non-summary nodes" and value = getTotalNodesCount()
193+
or
192194
key = "Taint reach - per million nodes" and value = getTaintReach().floor()
193195
or
194196
key = "Taint sinks - query sinks" and value = getQuerySinksCount()

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,17 @@ private module TaintReachFlow = TaintTracking::Global<TaintReachConfig>;
2626
* We don't include flow summary nodes, as their number is unstable (varies when models
2727
* are added).
2828
*/
29-
int getTaintedNodesCount() { result = count(DataFlow::Node n | TaintReachFlow::flowTo(n) and not n instanceof FlowSummaryNode) }
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) }
3040

3141
/**
3242
* Gets the proportion of data flow nodes that taint reaches (from any source),
@@ -35,4 +45,4 @@ int getTaintedNodesCount() { result = count(DataFlow::Node n | TaintReachFlow::f
3545
* We don't include flow summary nodes, as their number is unstable (varies when models
3646
* are added).
3747
*/
38-
float getTaintReach() { result = (getTaintedNodesCount() * 1000000.0) / count(DataFlow::Node n | not n instanceof FlowSummaryNode) }
48+
float getTaintReach() { result = (getTaintedNodesCount() * 1000000.0) / getTotalNodesCount() }

0 commit comments

Comments
 (0)