File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed
src/semmle/javascript/frameworks
test/library-tests/TaintTracking Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -169,6 +169,31 @@ module XML {
169169 override predicate resolvesEntities ( XML:: EntityKind kind ) { kind = InternalEntity ( ) }
170170 }
171171
172+ /**
173+ * An invocation of `xml2js`.
174+ */
175+ private class Xml2JSInvocation extends XML:: ParserInvocation {
176+ js:: DataFlow:: CallNode call ;
177+
178+ Xml2JSInvocation ( ) {
179+ exists ( js:: API:: Node imp | imp = js:: API:: moduleImport ( "xml2js" ) |
180+ call = [ imp , imp .getMember ( "Parser" ) .getInstance ( ) ] .getMember ( "parseString" ) .getACall ( ) and
181+ this = call .asExpr ( )
182+ )
183+ }
184+
185+ override js:: Expr getSourceArgument ( ) { result = getArgument ( 0 ) }
186+
187+ override predicate resolvesEntities ( XML:: EntityKind kind ) {
188+ // sax-js (the parser used) does not expand entities.
189+ none ( )
190+ }
191+
192+ override js:: DataFlow:: Node getAResult ( ) {
193+ result = call .getABoundCallbackParameter ( call .getNumArgument ( ) - 1 , 1 )
194+ }
195+ }
196+
172197 private class XMLParserTaintStep extends js:: TaintTracking:: AdditionalTaintStep {
173198 XML:: ParserInvocation parser ;
174199
Original file line number Diff line number Diff line change @@ -146,3 +146,4 @@ typeInferenceMismatch
146146| tst.js:2:13:2:20 | source() | tst.js:47:10:47:30 | Buffer. ... 'hex') |
147147| tst.js:2:13:2:20 | source() | tst.js:48:10:48:22 | new Buffer(x) |
148148| xml.js:5:18:5:25 | source() | xml.js:8:14:8:17 | text |
149+ | xml.js:12:17:12:24 | source() | xml.js:13:14:13:19 | result |
Original file line number Diff line number Diff line change 77 parser . on ( "text" , text => {
88 sink ( text ) ; // NOT OK
99 } ) ;
10+
11+ var parseString = require ( 'xml2js' ) . parseString ;
12+ parseString ( source ( ) , function ( err , result ) {
13+ sink ( result ) ; // NOT OK
14+ } ) ;
1015} ) ( ) ;
You can’t perform that action at this time.
0 commit comments