@@ -99,19 +99,6 @@ class CreateXmlReader extends Function {
99
99
}
100
100
}
101
101
102
- /**
103
- * The `AbstractDOMParser.parse`, `DOMLSParserClass.parse`, `SAXParser.parse`
104
- * or `SAX2XMLReader.parse` method.
105
- */
106
- class ParseFunction extends Function {
107
- ParseFunction ( ) {
108
- this .getClassAndName ( "parse" ) instanceof AbstractDOMParserClass or
109
- this .getClassAndName ( "parse" ) instanceof DomLSParserClass or
110
- this .getClassAndName ( "parse" ) instanceof SaxParserClass or
111
- this .getClassAndName ( "parse" ) instanceof Sax2XmlReader
112
- }
113
- }
114
-
115
102
/**
116
103
* The `XercesDOMParser` interface for the Xerces XML library.
117
104
*/
@@ -130,9 +117,9 @@ class XercesDomParserLibrary extends XmlLibrary {
130
117
}
131
118
132
119
override predicate configurationSink ( DataFlow:: Node node , string flowstate ) {
133
- // sink is the read of the qualifier of a call to `parse`.
120
+ // sink is the read of the qualifier of a call to `AbstractDOMParser. parse`.
134
121
exists ( Call call |
135
- call .getTarget ( ) instanceof ParseFunction and
122
+ call .getTarget ( ) . getClassAndName ( "parse" ) instanceof AbstractDOMParserClass and
136
123
call .getQualifier ( ) = node .asConvertedExpr ( )
137
124
) and
138
125
flowstate instanceof XercesFlowState and
@@ -156,7 +143,13 @@ class CreateLSParserLibrary extends XmlLibrary {
156
143
}
157
144
158
145
override predicate configurationSink ( DataFlow:: Node node , string flowstate ) {
159
- none ( ) // uses the existing sinks from `XercesDomParserLibrary`
146
+ // sink is the read of the qualifier of a call to `DOMLSParserClass.parse`.
147
+ exists ( Call call |
148
+ call .getTarget ( ) .getClassAndName ( "parse" ) instanceof DomLSParserClass and
149
+ call .getQualifier ( ) = node .asConvertedExpr ( )
150
+ ) and
151
+ flowstate instanceof XercesFlowState and
152
+ not encodeXercesFlowState ( flowstate , 1 , 1 ) // safe configuration
160
153
}
161
154
}
162
155
@@ -178,7 +171,13 @@ class SaxParserLibrary extends XmlLibrary {
178
171
}
179
172
180
173
override predicate configurationSink ( DataFlow:: Node node , string flowstate ) {
181
- none ( ) // uses the existing sinks from `XercesDomParserLibrary`
174
+ // sink is the read of the qualifier of a call to `SAXParser.parse`.
175
+ exists ( Call call |
176
+ call .getTarget ( ) .getClassAndName ( "parse" ) instanceof SaxParserClass and
177
+ call .getQualifier ( ) = node .asConvertedExpr ( )
178
+ ) and
179
+ flowstate instanceof XercesFlowState and
180
+ not encodeXercesFlowState ( flowstate , 1 , 1 ) // safe configuration
182
181
}
183
182
}
184
183
@@ -198,7 +197,13 @@ class Sax2XmlReaderLibrary extends XmlLibrary {
198
197
}
199
198
200
199
override predicate configurationSink ( DataFlow:: Node node , string flowstate ) {
201
- none ( ) // uses the existing sinks from `XercesDomParserLibrary`
200
+ // sink is the read of the qualifier of a call to `SAX2XMLReader.parse`.
201
+ exists ( Call call |
202
+ call .getTarget ( ) .getClassAndName ( "parse" ) instanceof Sax2XmlReader and
203
+ call .getQualifier ( ) = node .asConvertedExpr ( )
204
+ ) and
205
+ flowstate instanceof XercesFlowState and
206
+ not encodeXercesFlowState ( flowstate , 1 , 1 ) // safe configuration
202
207
}
203
208
}
204
209
0 commit comments