33 * being interpreted as code.
44 *
55 * Note, for performance reasons: only import this file if
6- * `HardcodedDataInterpretedAsCode::Configuration ` is needed, otherwise
6+ * `HardcodedDataInterpretedAsCodeFlow ` is needed, otherwise
77 * `HardcodedDataInterpretedAsCodeCustomizations` should be imported instead.
88 */
99
@@ -16,11 +16,9 @@ import HardcodedDataInterpretedAsCodeCustomizations::HardcodedDataInterpretedAsC
1616 * A taint-tracking configuration for reasoning about hard-coded data
1717 * being interpreted as code.
1818 *
19- * We extend `DataFlow::Configuration` rather than
20- * `TaintTracking::Configuration`, so that we can set the flow state to
21- * `"taint"` on a taint step.
19+ * DEPRECATED: Use `HardcodedDataInterpretedAsCodeFlow` instead
2220 */
23- class Configuration extends DataFlow:: Configuration {
21+ deprecated class Configuration extends DataFlow:: Configuration {
2422 Configuration ( ) { this = "HardcodedDataInterpretedAsCode" }
2523
2624 override predicate isSource ( DataFlow:: Node source , DataFlow:: FlowState label ) {
@@ -46,3 +44,34 @@ class Configuration extends DataFlow::Configuration {
4644 stateTo = FlowState:: taint ( )
4745 }
4846}
47+
48+ /*
49+ * We implement `DataFlow::ConfigSig` rather than
50+ * `TaintTracking::ConfigSig`, so that we can set the flow state to
51+ * `"taint"` on a taint step.
52+ */
53+
54+ private module Config implements DataFlow:: StateConfigSig {
55+ class FlowState = DataFlow:: FlowState ;
56+
57+ predicate isSource ( DataFlow:: Node source , FlowState label ) { source .( Source ) .getLabel ( ) = label }
58+
59+ predicate isSink ( DataFlow:: Node sink , FlowState label ) { sink .( Sink ) .getLabel ( ) = label }
60+
61+ predicate isBarrier ( DataFlow:: Node node ) { node instanceof Sanitizer }
62+
63+ predicate isAdditionalFlowStep (
64+ DataFlow:: Node nodeFrom , DataFlow:: FlowState stateFrom , DataFlow:: Node nodeTo ,
65+ DataFlow:: FlowState stateTo
66+ ) {
67+ defaultAdditionalTaintStep ( nodeFrom , nodeTo ) and
68+ // This is a taint step, so the flow state becomes `taint`.
69+ stateFrom = [ FlowState:: data ( ) , FlowState:: taint ( ) ] and
70+ stateTo = FlowState:: taint ( )
71+ }
72+ }
73+
74+ /**
75+ * Taint-tracking for reasoning about hard-coded data being interpreted as code.
76+ */
77+ module HardcodedDataInterpretedAsCodeFlow = DataFlow:: GlobalWithState< Config > ;
0 commit comments