1- /**
2- * Provides classes for performing local (intra-procedural) and
3- * global (inter-procedural) taint-tracking analyses.
4- *
5- * We define _taint propagation_ informally to mean that a substantial part of
6- * the information from the source is preserved at the sink. For example, taint
7- * propagates from `x` to `x + 100`, but it does not propagate from `x` to `x >
8- * 100` since we consider a single bit of information to be too little.
9- */
101import TaintTrackingParameter:: Public
112private import TaintTrackingParameter:: Private
123
@@ -18,7 +9,7 @@ private import TaintTrackingParameter::Private
189 *
1910 * A taint-tracking configuration is a special data flow configuration
2011 * (`DataFlow::Configuration`) that allows for flow through nodes that do not
21- * necessarily preserve values but are still relevant from a taint- tracking
12+ * necessarily preserve values but are still relevant from a taint tracking
2213 * perspective. (For example, string concatenation, where one of the operands
2314 * is tainted.)
2415 *
@@ -30,7 +21,9 @@ private import TaintTrackingParameter::Private
3021 * MyAnalysisConfiguration() { this = "MyAnalysisConfiguration" }
3122 * // Override `isSource` and `isSink`.
3223 * // Optionally override `isSanitizer`.
33- * // Optionally override `isSanitizerEdge`.
24+ * // Optionally override `isSanitizerIn`.
25+ * // Optionally override `isSanitizerOut`.
26+ * // Optionally override `isSanitizerGuard`.
3427 * // Optionally override `isAdditionalTaintStep`.
3528 * }
3629 * ```
@@ -42,57 +35,78 @@ private import TaintTrackingParameter::Private
4235 * exists(MyAnalysisConfiguration cfg | cfg.hasFlow(source, sink))
4336 * ```
4437 *
45- * Multiple configurations can coexist, but it is unsupported to depend on a
46- * `TaintTracking::Configuration` or a `DataFlow::Configuration` in the
38+ * Multiple configurations can coexist, but it is unsupported to depend on
39+ * another `TaintTracking::Configuration` or a `DataFlow::Configuration` in the
4740 * overridden predicates that define sources, sinks, or additional steps.
48- * Instead, the dependency should go to a `TaintTracking2::Configuration` or
49- * a `DataFlow{2,3,4} ::Configuration`.
41+ * Instead, the dependency should go to a `TaintTracking2::Configuration` or a
42+ * `DataFlow2::Configuration`, `DataFlow3 ::Configuration`, etc .
5043 */
5144abstract class Configuration extends DataFlow:: Configuration {
5245 bindingset [ this ]
5346 Configuration ( ) { any ( ) }
5447
55- /** Holds if `source` is a taint source. */
48+ /**
49+ * Holds if `source` is a relevant taint source.
50+ *
51+ * The smaller this predicate is, the faster `hasFlow()` will converge.
52+ */
5653 // overridden to provide taint-tracking specific qldoc
5754 abstract override predicate isSource ( DataFlow:: Node source ) ;
5855
59- /** Holds if `sink` is a taint sink. */
56+ /**
57+ * Holds if `sink` is a relevant taint sink.
58+ *
59+ * The smaller this predicate is, the faster `hasFlow()` will converge.
60+ */
6061 // overridden to provide taint-tracking specific qldoc
6162 abstract override predicate isSink ( DataFlow:: Node sink ) ;
6263
63- /**
64- * Holds if taint should not flow into `node`.
65- */
64+ /** Holds if the node `node` is a taint sanitizer. */
6665 predicate isSanitizer ( DataFlow:: Node node ) { none ( ) }
6766
68- /** Holds if data flow from `node1` to `node2` is prohibited. */
69- predicate isSanitizerEdge ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
70- none ( )
67+ final override predicate isBarrier ( DataFlow:: Node node ) {
68+ isSanitizer ( node ) or
69+ defaultTaintBarrier ( node )
70+ }
71+
72+ /** DEPRECATED: override `isSanitizerIn` and `isSanitizerOut` instead. */
73+ deprecated predicate isSanitizerEdge ( DataFlow:: Node node1 , DataFlow:: Node node2 ) { none ( ) }
74+
75+ deprecated final override predicate isBarrierEdge ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
76+ isSanitizerEdge ( node1 , node2 )
7177 }
7278
79+ /** Holds if data flow into `node` is prohibited. */
80+ predicate isSanitizerIn ( DataFlow:: Node node ) { none ( ) }
81+
82+ final override predicate isBarrierIn ( DataFlow:: Node node ) { isSanitizerIn ( node ) }
83+
84+ /** Holds if data flow out of `node` is prohibited. */
85+ predicate isSanitizerOut ( DataFlow:: Node node ) { none ( ) }
86+
87+ final override predicate isBarrierOut ( DataFlow:: Node node ) { isSanitizerOut ( node ) }
88+
89+ /** Holds if data flow through nodes guarded by `guard` is prohibited. */
90+ predicate isSanitizerGuard ( DataFlow:: BarrierGuard guard ) { none ( ) }
91+
92+ final override predicate isBarrierGuard ( DataFlow:: BarrierGuard guard ) { isSanitizerGuard ( guard ) }
93+
7394 /**
74- * Holds if the additional taint propagation step
75- * from `source` to `target` must be taken into account in the analysis.
76- * This step will only be followed if `target` is not in the `isSanitizer`
77- * predicate.
95+ * Holds if the additional taint propagation step from `node1` to `node2`
96+ * must be taken into account in the analysis.
7897 */
79- predicate isAdditionalTaintStep ( DataFlow:: Node source ,
80- DataFlow:: Node target )
81- { none ( ) }
82-
83- final override
84- predicate isBarrier ( DataFlow:: Node node ) { isSanitizer ( node ) }
98+ predicate isAdditionalTaintStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) { none ( ) }
8599
86- /** DEPRECATED: use `isSanitizerEdge` instead. */
87- override deprecated
88- predicate isBarrierEdge ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
89- this .isSanitizerEdge ( node1 , node2 )
100+ final override predicate isAdditionalFlowStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
101+ isAdditionalTaintStep ( node1 , node2 ) or
102+ defaultAdditionalTaintStep ( node1 , node2 )
90103 }
91104
92- final override
93- predicate isAdditionalFlowStep ( DataFlow:: Node source , DataFlow:: Node target ) {
94- this .isAdditionalTaintStep ( source , target )
95- or
96- localTaintStep ( source , target )
105+ /**
106+ * Holds if taint may flow from `source` to `sink` for this configuration.
107+ */
108+ // overridden to provide taint-tracking specific qldoc
109+ override predicate hasFlow ( DataFlow:: Node source , DataFlow:: Node sink ) {
110+ super .hasFlow ( source , sink )
97111 }
98112}
0 commit comments