Skip to content

Commit 1c10886

Browse files
committed
Add flow summaries for TypedArray methods set and subarray
1 parent d689a55 commit 1c10886

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

javascript/ql/lib/semmle/javascript/internal/flow_summaries/TypedArrays.qll

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,27 @@ class BufferTypedArray extends DataFlow::AdditionalFlowStep {
3636
)
3737
}
3838
}
39+
40+
class SetLike extends SummarizedCallable {
41+
SetLike() { this = "TypedArray#set" }
42+
43+
override InstanceCall getACall() { result.getMethodName() = "set" }
44+
45+
override predicate propagatesFlow(string input, string output, boolean preservesValue) {
46+
preservesValue = true and
47+
input = "Argument[0].ArrayElement" and
48+
output = "Argument[this].ArrayElement"
49+
}
50+
}
51+
52+
class SubArrayLike extends SummarizedCallable {
53+
SubArrayLike() { this = "TypedArray#subarray" }
54+
55+
override InstanceCall getACall() { result.getMethodName() = "subarray" }
56+
57+
override predicate propagatesFlow(string input, string output, boolean preservesValue) {
58+
preservesValue = true and
59+
input = "Argument[this].ArrayElement" and
60+
output = "ReturnValue.ArrayElement"
61+
}
62+
}

javascript/ql/test/library-tests/TaintTracking/BasicTaintTracking.expected

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ legacyDataFlowDifference
3838
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:5:10:5:10 | y | only flow with NEW data flow library |
3939
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:7:10:7:17 | y.buffer | only flow with NEW data flow library |
4040
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:11:10:11:12 | arr | only flow with NEW data flow library |
41+
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:15:10:15:10 | z | only flow with NEW data flow library |
42+
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:18:10:18:12 | sub | only flow with NEW data flow library |
43+
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:22:10:22:14 | clone | only flow with NEW data flow library |
4144
| use-use-after-implicit-read.js:7:17:7:24 | source() | use-use-after-implicit-read.js:15:10:15:10 | x | only flow with NEW data flow library |
4245
consistencyIssue
4346
| nested-props.js:20 | expected an alert, but found none | NOT OK - but not found | Consistency |
4447
| stringification-read-steps.js:17 | expected an alert, but found none | NOT OK | Consistency |
4548
| stringification-read-steps.js:25 | expected an alert, but found none | NOT OK | Consistency |
46-
| typed-arrays.js:15 | expected an alert, but found none | NOT OK | Consistency |
47-
| typed-arrays.js:18 | expected an alert, but found none | NOT OK | Consistency |
48-
| typed-arrays.js:22 | expected an alert, but found none | NOT OK | Consistency |
4949
flow
5050
| access-path-sanitizer.js:2:18:2:25 | source() | access-path-sanitizer.js:4:8:4:12 | obj.x |
5151
| addexpr.js:4:10:4:17 | source() | addexpr.js:7:8:7:8 | x |
@@ -334,6 +334,9 @@ flow
334334
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:5:10:5:10 | y |
335335
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:7:10:7:17 | y.buffer |
336336
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:11:10:11:12 | arr |
337+
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:15:10:15:10 | z |
338+
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:18:10:18:12 | sub |
339+
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:22:10:22:14 | clone |
337340
| use-use-after-implicit-read.js:7:17:7:24 | source() | use-use-after-implicit-read.js:8:10:8:17 | captured |
338341
| use-use-after-implicit-read.js:7:17:7:24 | source() | use-use-after-implicit-read.js:15:10:15:10 | x |
339342
| xml.js:5:18:5:25 | source() | xml.js:8:14:8:17 | text |

0 commit comments

Comments
 (0)