File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed
test/query-tests/diagnostics Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import codeql.rust.security.SensitiveData
1212import codeql.rust.security.WeakSensitiveDataHashingExtensions
1313import codeql.rust.Diagnostics
1414import Stats
15+ import TaintReach
1516
1617from string key , int value
1718where
5960 or
6061 key = "Taint sources - active" and value = count ( ActiveThreatModelSource s )
6162 or
63+ key = "Taint reach - nodes tainted" and value = getTaintedNodesCount ( )
64+ or
65+ key = "Taint reach - per million nodes" and value = getTaintReach ( ) .floor ( )
66+ or
6267 key = "Sensitive data" and value = count ( SensitiveData d )
6368 or
6469 key = "Taint sinks - query sinks" and value = getQuerySinksCount ( )
Original file line number Diff line number Diff line change 1+ /**
2+ * Taint reach computation. Taint reach is the proportion of all dataflow nodes that can be reached
3+ * via taint flow from any active thread model source. It's usually expressed per million nodes.
4+ */
5+
6+ import rust
7+ private import codeql.rust.Concepts
8+ private import codeql.rust.dataflow.DataFlow
9+ private import codeql.rust.dataflow.TaintTracking
10+
11+ /**
12+ * A taint configuration for taint reach (flow to any node from any modelled source).
13+ */
14+ private module TaintReachConfig implements DataFlow:: ConfigSig {
15+ predicate isSource ( DataFlow:: Node node ) { node instanceof ActiveThreatModelSource }
16+
17+ predicate isSink ( DataFlow:: Node node ) { any ( ) }
18+ }
19+
20+ private module TaintReachFlow = TaintTracking:: Global< TaintReachConfig > ;
21+
22+ /**
23+ * Gets the total number of dataflow nodes that taint reaches (from any source).
24+ */
25+ int getTaintedNodesCount ( ) { result = count ( DataFlow:: Node n | TaintReachFlow:: flowTo ( n ) ) }
26+
27+ /**
28+ * Gets the proportion of dataflow nodes that taint reaches (from any source),
29+ * expressed as a count per million nodes.
30+ */
31+ float getTaintReach ( ) { result = ( getTaintedNodesCount ( ) * 1000000.0 ) / count ( DataFlow:: Node n ) }
Original file line number Diff line number Diff line change 1515| Macro calls - total | 9 |
1616| Macro calls - unresolved | 1 |
1717| Sensitive data | 0 |
18+ | Taint reach - nodes tainted | 0 |
19+ | Taint reach - per million nodes | 0 |
1820| Taint sinks - cryptographic operations | 0 |
1921| Taint sinks - query sinks | 0 |
2022| Taint sources - active | 0 |
You can’t perform that action at this time.
0 commit comments