@@ -31,6 +31,20 @@ module XmlEntityInjection {
3131 */
3232 abstract class SanitizerGuard extends DataFlow:: BarrierGuard { }
3333
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+
3448 /**
3549 * A data flow sink for XML parsing libraries.
3650 *
@@ -85,11 +99,16 @@ module XmlEntityInjection {
8599 */
86100 class StringConstCompareAsSanitizerGuard extends SanitizerGuard , StringConstCompare { }
87101
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+ }
94113 }
95114}
0 commit comments