mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Merge pull request #18790 from asgerf/js/no-implicit-array-taint
JS: Do not taint whole array when storing into ArrayElement
This commit is contained in:
@@ -20,6 +20,7 @@ reverseRead
|
||||
| tst.js:267:28:267:31 | map3 | Origin of readStep is missing a PostUpdateNode. |
|
||||
argHasPostUpdate
|
||||
postWithInFlow
|
||||
| file://:0:0:0:0 | [summary] to write: Argument[0] in _.tap | PostUpdateNode should not be the target of local flow. |
|
||||
| file://:0:0:0:0 | [summary] to write: Argument[1] in Array method with flow into callback | PostUpdateNode should not be the target of local flow. |
|
||||
| file://:0:0:0:0 | [summary] to write: Argument[1] in Array#filter | PostUpdateNode should not be the target of local flow. |
|
||||
| file://:0:0:0:0 | [summary] to write: Argument[1] in Array#find / Array#findLast | PostUpdateNode should not be the target of local flow. |
|
||||
@@ -29,6 +30,7 @@ postWithInFlow
|
||||
| file://:0:0:0:0 | [summary] to write: Argument[1] in Array#reduce / Array#reduceRight | PostUpdateNode should not be the target of local flow. |
|
||||
| file://:0:0:0:0 | [summary] to write: Argument[2] in 'array.prototype.find' / 'array-find' | PostUpdateNode should not be the target of local flow. |
|
||||
| file://:0:0:0:0 | [summary] to write: Argument[2] in Array.from(arg, callback, [thisArg]) | PostUpdateNode should not be the target of local flow. |
|
||||
| file://:0:0:0:0 | [summary] to write: Argument[2] in _.reduce-like | PostUpdateNode should not be the target of local flow. |
|
||||
| file://:0:0:0:0 | [summary] to write: Argument[this] in Array#flatMap | PostUpdateNode should not be the target of local flow. |
|
||||
| file://:0:0:0:0 | [summary] to write: Argument[this] in Array#forEach / Map#forEach / Set#forEach | PostUpdateNode should not be the target of local flow. |
|
||||
| file://:0:0:0:0 | [summary] to write: Argument[this] in Array#map | PostUpdateNode should not be the target of local flow. |
|
||||
|
||||
@@ -20,3 +20,27 @@ function shiftTaint() {
|
||||
sink(array.shift()); // $ hasTaintFlow=shift.directly-tainted
|
||||
sink(array.shift()); // $ hasTaintFlow=shift.directly-tainted
|
||||
}
|
||||
|
||||
function implicitToString() {
|
||||
const array = [source('implicitToString.1')];
|
||||
array.push(source('implicitToString.2'))
|
||||
|
||||
sink(array + "foo"); // $ hasTaintFlow=implicitToString.1 hasTaintFlow=implicitToString.2
|
||||
sink("foo" + array); // $ hasTaintFlow=implicitToString.1 hasTaintFlow=implicitToString.2
|
||||
sink("" + array); // $ hasTaintFlow=implicitToString.1 hasTaintFlow=implicitToString.2
|
||||
sink(array + 1); // $ hasTaintFlow=implicitToString.1 hasTaintFlow=implicitToString.2
|
||||
sink(1 + array); // $ hasTaintFlow=implicitToString.1 hasTaintFlow=implicitToString.2
|
||||
sink(unknown() + array); // $ hasTaintFlow=implicitToString.1 hasTaintFlow=implicitToString.2
|
||||
sink(array + unknown()); // $ hasTaintFlow=implicitToString.1 hasTaintFlow=implicitToString.2
|
||||
|
||||
sink(`${array}`); // $ hasTaintFlow=implicitToString.1 hasTaintFlow=implicitToString.2
|
||||
sink(`${array} foo`); // $ hasTaintFlow=implicitToString.1 hasTaintFlow=implicitToString.2
|
||||
|
||||
sink(String(array)); // $ hasTaintFlow=implicitToString.1 hasTaintFlow=implicitToString.2
|
||||
|
||||
sink(array.toString()); // $ hasTaintFlow=implicitToString.1 hasTaintFlow=implicitToString.2
|
||||
sink(array.toString("utf8")); // $ hasTaintFlow=implicitToString.1 hasTaintFlow=implicitToString.2
|
||||
|
||||
sink(Array.prototype.toString.call(array)); // $ hasTaintFlow=implicitToString.1 hasTaintFlow=implicitToString.2
|
||||
sink(Object.prototype.toString.call(array)); // OK - returns "[object Array]"
|
||||
}
|
||||
|
||||
7
javascript/ql/test/library-tests/TripleDot/buffer.js
Normal file
7
javascript/ql/test/library-tests/TripleDot/buffer.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import 'dummy';
|
||||
|
||||
function t1() {
|
||||
const b1 = Buffer.from(source("t1.1"));
|
||||
const b2 = Buffer.from(source("t1.2"));
|
||||
sink(Buffer.concat([b1, b2]).toString("utf8")); // $ hasTaintFlow=t1.1 hasTaintFlow=t1.2
|
||||
}
|
||||
Reference in New Issue
Block a user