@@ -98,6 +98,17 @@ abstract class Configuration extends string {
98
98
*/
99
99
predicate isSource ( DataFlow:: Node source ) { none ( ) }
100
100
101
+ /**
102
+ * Gets the flow label to associate with sources added by the 1-argument `isSource` predicate.
103
+ *
104
+ * For taint-tracking configurations, this defaults to `taint` and for other data-flow configurations
105
+ * it defaults to `data`.
106
+ *
107
+ * Overriding this predicate is rarely needed, and overriding the 2-argument `isSource` predicate
108
+ * should be preferred when possible.
109
+ */
110
+ FlowLabel getDefaultSourceLabel ( ) { result = FlowLabel:: data ( ) }
111
+
101
112
/**
102
113
* Holds if `source` is a source of flow labeled with `lbl` that is relevant
103
114
* for this configuration.
@@ -668,11 +679,7 @@ private predicate exploratoryFlowStep(
668
679
*/
669
680
private predicate isSource ( DataFlow:: Node nd , DataFlow:: Configuration cfg , FlowLabel lbl ) {
670
681
( cfg .isSource ( nd ) or nd .( AdditionalSource ) .isSourceFor ( cfg ) ) and
671
- (
672
- if cfg instanceof TaintTracking:: Configuration
673
- then lbl = FlowLabel:: taint ( )
674
- else lbl = FlowLabel:: data ( )
675
- )
682
+ lbl = cfg .getDefaultSourceLabel ( )
676
683
or
677
684
nd .( AdditionalSource ) .isSourceFor ( cfg , lbl )
678
685
or
@@ -684,11 +691,7 @@ private predicate isSource(DataFlow::Node nd, DataFlow::Configuration cfg, FlowL
684
691
*/
685
692
private predicate isSink ( DataFlow:: Node nd , DataFlow:: Configuration cfg , FlowLabel lbl ) {
686
693
( cfg .isSink ( nd ) or nd .( AdditionalSink ) .isSinkFor ( cfg ) ) and
687
- (
688
- if cfg instanceof TaintTracking:: Configuration
689
- then lbl = FlowLabel:: taint ( )
690
- else lbl = FlowLabel:: data ( )
691
- )
694
+ lbl = any ( StandardFlowLabel f )
692
695
or
693
696
nd .( AdditionalSink ) .isSinkFor ( cfg , lbl )
694
697
or
0 commit comments