2
2
* Provides a taint-tracking configuration for reasoning about code
3
3
* constructed from library input vulnerabilities.
4
4
*
5
- * Note, for performance reasons: only import this file if `Configuration` is needed,
6
- * otherwise `UnsafeCodeConstructionCustomizations` should be imported instead.
5
+ * Note, for performance reasons: only import this file if
6
+ * `UnsafeCodeConstructionFlow` is needed, otherwise
7
+ * `UnsafeCodeConstructionCustomizations` should be imported instead.
7
8
*/
8
9
9
10
import codeql.ruby.DataFlow
@@ -13,8 +14,9 @@ private import codeql.ruby.dataflow.BarrierGuards
13
14
14
15
/**
15
16
* A taint-tracking configuration for detecting code constructed from library input vulnerabilities.
17
+ * DEPRECATED: Use `UnsafeCodeConstructionFlow`
16
18
*/
17
- class Configuration extends TaintTracking:: Configuration {
19
+ deprecated class Configuration extends TaintTracking:: Configuration {
18
20
Configuration ( ) { this = "UnsafeShellCommandConstruction" }
19
21
20
22
override predicate isSource ( DataFlow:: Node source ) { source instanceof Source }
@@ -37,3 +39,28 @@ class Configuration extends TaintTracking::Configuration {
37
39
set .isElementOfTypeOrUnknown ( "int" )
38
40
}
39
41
}
42
+
43
+ private module UnsafeCodeConstructionConfig implements DataFlow:: ConfigSig {
44
+ predicate isSource ( DataFlow:: Node source ) { source instanceof Source }
45
+
46
+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof Sink }
47
+
48
+ predicate isBarrier ( DataFlow:: Node node ) {
49
+ node instanceof StringConstCompareBarrier or
50
+ node instanceof StringConstArrayInclusionCallBarrier
51
+ }
52
+
53
+ // override to require the path doesn't have unmatched return steps
54
+ DataFlow:: FlowFeature getAFeature ( ) { result instanceof DataFlow:: FeatureHasSourceCallContext }
55
+
56
+ predicate allowImplicitRead ( DataFlow:: Node node , DataFlow:: ContentSet set ) {
57
+ // allow implicit reads of array elements
58
+ isSink ( node ) and
59
+ set .isElementOfTypeOrUnknown ( "int" )
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Taint-tracking for detecting code constructed from library input vulnerabilities.
65
+ */
66
+ module UnsafeCodeConstructionFlow = TaintTracking:: Global< UnsafeCodeConstructionConfig > ;
0 commit comments