@@ -31,6 +31,20 @@ module XmlEntityInjection {
31
31
*/
32
32
abstract class SanitizerGuard extends DataFlow:: BarrierGuard { }
33
33
34
+ /**
35
+ * A unit class for adding additional taint steps.
36
+ *
37
+ * Extend this class to add additional taint steps that should apply to `XmlEntityInjection`
38
+ * taint configuration.
39
+ */
40
+ class AdditionalTaintStep extends Unit {
41
+ /**
42
+ * Holds if the step from `nodeFrom` to `nodeTo` should be considered a taint
43
+ * step for `XmlEntityInjection` configuration.
44
+ */
45
+ abstract predicate step ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) ;
46
+ }
47
+
34
48
/**
35
49
* A data flow sink for XML parsing libraries.
36
50
*
@@ -85,11 +99,16 @@ module XmlEntityInjection {
85
99
*/
86
100
class StringConstCompareAsSanitizerGuard extends SanitizerGuard , StringConstCompare { }
87
101
88
- predicate ioAdditionalTaintStep ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
89
- exists ( DataFlow:: CallCfgNode ioCalls |
90
- ioCalls = API:: moduleImport ( "io" ) .getMember ( [ "StringIO" , "BytesIO" ] ) .getACall ( ) and
91
- nodeFrom = ioCalls .getArg ( 0 ) and
92
- nodeTo = ioCalls
93
- )
102
+ /**
103
+ * A taint step for `io`'s `StringIO` and `BytesIO` methods.
104
+ */
105
+ class IoAdditionalTaintStep extends AdditionalTaintStep {
106
+ override predicate step ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
107
+ exists ( DataFlow:: CallCfgNode ioCalls |
108
+ ioCalls = API:: moduleImport ( "io" ) .getMember ( [ "StringIO" , "BytesIO" ] ) .getACall ( ) and
109
+ nodeFrom = ioCalls .getArg ( 0 ) and
110
+ nodeTo = ioCalls
111
+ )
112
+ }
94
113
}
95
114
}
0 commit comments