File tree Expand file tree Collapse file tree
test/library-tests/TaintTracking Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ lgtm,codescanning
2+ * The dataflow libraries now model dataflow through more JSON utility libraries.
3+ Affected packages are
4+ [ json2csv] ( https://npmjs.com/package/json2csv )
Original file line number Diff line number Diff line change @@ -34,3 +34,22 @@ class JsonStringifyCall extends DataFlow::CallNode {
3434 */
3535 DataFlow:: SourceNode getOutput ( ) { result = this }
3636}
37+
38+ /**
39+ * A taint step through the [`json2csv`](https://www.npmjs.com/package/json2csv) library.
40+ */
41+ class JSON2CSVTaintStep extends TaintTracking:: SharedTaintStep {
42+ override predicate step ( DataFlow:: Node pred , DataFlow:: Node succ ) {
43+ exists ( API:: CallNode call |
44+ call =
45+ API:: moduleImport ( "json2csv" )
46+ .getMember ( "Parser" )
47+ .getInstance ( )
48+ .getMember ( "parse" )
49+ .getACall ( )
50+ |
51+ pred = call .getArgument ( 0 ) and
52+ succ = call
53+ )
54+ }
55+ }
Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ typeInferenceMismatch
9090| json-stringify.js:2:16:2:23 | source() | json-stringify.js:16:8:16:38 | require ... source) |
9191| json-stringify.js:2:16:2:23 | source() | json-stringify.js:17:8:17:39 | require ... source) |
9292| json-stringify.js:2:16:2:23 | source() | json-stringify.js:18:8:18:40 | require ... source) |
93+ | json-stringify.js:2:16:2:23 | source() | json-stringify.js:21:8:21:46 | new jso ... source) |
9394| json-stringify.js:3:15:3:22 | source() | json-stringify.js:8:8:8:31 | jsonStr ... (taint) |
9495| nested-props.js:4:13:4:20 | source() | nested-props.js:5:10:5:14 | obj.x |
9596| nested-props.js:9:18:9:25 | source() | nested-props.js:10:10:10:16 | obj.x.y |
Original file line number Diff line number Diff line change @@ -16,4 +16,7 @@ function foo() {
1616 sink ( require ( "util" ) . inspect ( source ) ) ; // NOT OK
1717 sink ( require ( "pretty-format" ) ( source ) ) ; // NOT OK
1818 sink ( require ( "object-inspect" ) ( source ) ) ; // NOT OK
19+
20+ const json2csv = require ( 'json2csv' ) ;
21+ sink ( new json2csv . Parser ( opts ) . parse ( source ) ) ; // NOT OK
1922}
You can’t perform that action at this time.
0 commit comments