11/**
22 * Provides a taint-tracking configuration for detecting "Code injection" vulnerabilities.
33 *
4- * Note, for performance reasons: only import this file if `Configuration` is needed,
5- * otherwise `CodeInjectionCustomizations` should be imported instead.
4+ * Note, for performance reasons: only import this file if
5+ * `CodeInjectionFlow` is needed, otherwise
6+ * `CodeInjectionCustomizations` should be imported instead.
67 */
78
89import codeql.ruby.DataFlow
@@ -12,8 +13,9 @@ import codeql.ruby.dataflow.BarrierGuards
1213
1314/**
1415 * A taint-tracking configuration for detecting "Code injection" vulnerabilities.
16+ * DEPRECATED: Use `CodeInjectionFlow` instead
1517 */
16- class Configuration extends TaintTracking:: Configuration {
18+ deprecated class Configuration extends TaintTracking:: Configuration {
1719 Configuration ( ) { this = "CodeInjection" }
1820
1921 override predicate isSource ( DataFlow:: Node source , DataFlow:: FlowState state ) {
@@ -40,3 +42,30 @@ class Configuration extends TaintTracking::Configuration {
4042 guard instanceof SanitizerGuard
4143 }
4244}
45+
46+ private module Config implements DataFlow:: StateConfigSig {
47+ class FlowState = DataFlow:: FlowState ;
48+
49+ predicate isSource ( DataFlow:: Node source , FlowState state ) {
50+ state = source .( Source ) .getAFlowState ( )
51+ }
52+
53+ predicate isSink ( DataFlow:: Node sink , FlowState state ) { state = sink .( Sink ) .getAFlowState ( ) }
54+
55+ predicate isBarrier ( DataFlow:: Node node ) {
56+ node instanceof Sanitizer and not exists ( node .( Sanitizer ) .getAFlowState ( ) )
57+ or
58+ node instanceof StringConstCompareBarrier
59+ or
60+ node instanceof StringConstArrayInclusionCallBarrier
61+ }
62+
63+ predicate isBarrier ( DataFlow:: Node node , DataFlow:: FlowState state ) {
64+ node .( Sanitizer ) .getAFlowState ( ) = state
65+ }
66+ }
67+
68+ /**
69+ * Taint-tracking for detecting "Code injection" vulnerabilities.
70+ */
71+ module CodeInjectionFlow = TaintTracking:: GlobalWithState< Config > ;
0 commit comments