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
12
12
import codeql.rust.security.WeakSensitiveDataHashingExtensions
13
13
import codeql.rust.Diagnostics
14
14
import Stats
15
+ import TaintReach
15
16
16
17
from string key , int value
17
18
where
59
60
or
60
61
key = "Taint sources - active" and value = count ( ActiveThreatModelSource s )
61
62
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
62
67
key = "Sensitive data" and value = count ( SensitiveData d )
63
68
or
64
69
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 15
15
| Macro calls - total | 9 |
16
16
| Macro calls - unresolved | 1 |
17
17
| Sensitive data | 0 |
18
+ | Taint reach - nodes tainted | 0 |
19
+ | Taint reach - per million nodes | 0 |
18
20
| Taint sinks - cryptographic operations | 0 |
19
21
| Taint sinks - query sinks | 0 |
20
22
| Taint sources - active | 0 |
You can’t perform that action at this time.
0 commit comments