File tree Expand file tree Collapse file tree 4 files changed +25
-1
lines changed
test/library-tests/TaintTracking Expand file tree Collapse file tree 4 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -3,4 +3,6 @@ lgtm,codescanning
33 Affected packages are
44 [ array-from] ( https://npmjs.com/package/array-from ) ,
55 [ array.prototype.find] ( https://npmjs.com/package/array.prototype.find ) ,
6- [ array-find] ( https://npmjs.com/package/array-find )
6+ [ array-find] ( https://npmjs.com/package/array-find ) ,
7+ [ arrify] ( https://npmjs.com/package/arrify ) ,
8+ [ array-ify] ( https://npmjs.com/package/array-ify )
Original file line number Diff line number Diff line change @@ -342,4 +342,15 @@ private module ArrayLibraries {
342342 result = DataFlow:: moduleImport ( [ "array.prototype.find" , "array-find" ] ) .getACall ( ) and
343343 array = result .getArgument ( 0 )
344344 }
345+
346+ /**
347+ * A taint step through the `arrify` library, or other libraries that (maybe) convert values into arrays.
348+ */
349+ private class ArrayifyStep extends TaintTracking:: SharedTaintStep {
350+ override predicate step ( DataFlow:: Node pred , DataFlow:: Node succ ) {
351+ exists ( API:: CallNode call | call = API:: moduleImport ( [ "arrify" , "array-ify" ] ) .getACall ( ) |
352+ pred = call .getArgument ( 0 ) and succ = call
353+ )
354+ }
355+ }
345356}
Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ typeInferenceMismatch
1212| array-mutation.js:31:33:31:40 | source() | array-mutation.js:32:8:32:8 | h |
1313| array-mutation.js:35:36:35:43 | source() | array-mutation.js:36:8:36:8 | i |
1414| array-mutation.js:39:17:39:24 | source() | array-mutation.js:40:8:40:8 | j |
15+ | arrays.js:2:15:2:22 | source() | arrays.js:5:10:5:20 | arrify(foo) |
16+ | arrays.js:2:15:2:22 | source() | arrays.js:8:10:8:22 | arrayIfy(foo) |
1517| booleanOps.js:2:11:2:18 | source() | booleanOps.js:4:8:4:8 | x |
1618| booleanOps.js:2:11:2:18 | source() | booleanOps.js:13:10:13:10 | x |
1719| booleanOps.js:2:11:2:18 | source() | booleanOps.js:19:10:19:10 | x |
Original file line number Diff line number Diff line change 1+ function test ( ) {
2+ var foo = source ( ) ;
3+
4+ const arrify = require ( "arrify" ) ;
5+ sink ( arrify ( foo ) ) ; // NOT OK
6+
7+ const arrayIfy = require ( "array-ify" ) ;
8+ sink ( arrayIfy ( foo ) ) ; // NOT OK
9+ }
You can’t perform that action at this time.
0 commit comments