99import swift
1010import codeql.swift.dataflow.FlowSources
1111import codeql.swift.security.SensitiveExprs
12- import codeql.swift.dataflow.DataFlow
13- import codeql.swift.dataflow.TaintTracking
1412import codeql.swift.regex.Regex
1513
16- /**
17- * A taint configuration for tainted data reaching any node.
18- */
19- module TaintReachConfig implements DataFlow:: ConfigSig {
20- predicate isSource ( DataFlow:: Node node ) { node instanceof FlowSource }
21-
22- predicate isSink ( DataFlow:: Node node ) { any ( ) }
23- }
24-
25- module TaintReachFlow = TaintTracking:: Global< TaintReachConfig > ;
26-
27- /**
28- * Gets the total number of dataflow nodes that taint reaches (from any source).
29- */
30- int taintedNodesCount ( ) { result = count ( DataFlow:: Node n | TaintReachFlow:: flowTo ( n ) ) }
31-
32- /**
33- * Gets the proportion of dataflow nodes that taint reaches (from any source),
34- * expressed as a count per million nodes.
35- */
36- float taintReach ( ) { result = ( taintedNodesCount ( ) * 1000000.0 ) / count ( DataFlow:: Node n ) }
37-
3814predicate statistic ( string what , string value ) {
3915 what = "Files" and value = count ( File f ) .toString ( )
4016 or
@@ -52,12 +28,6 @@ predicate statistic(string what, string value) {
5228 or
5329 what = "Sensitive expressions" and value = count ( SensitiveExpr e ) .toString ( )
5430 or
55- what = "Dataflow nodes (total)" and value = count ( DataFlow:: Node n ) .toString ( )
56- or
57- what = "Dataflow nodes (tainted)" and value = taintedNodesCount ( ) .toString ( )
58- or
59- what = "Taint reach (per million nodes)" and value = taintReach ( ) .toString ( )
60- or
6131 what = "Regular expression evals" and value = count ( RegexEval e ) .toString ( )
6232 or
6333 what = "Regular expression evals with associated regex" and
0 commit comments