Skip to content

Commit 0c52b5a

Browse files
committed
Added summary flow for StringFromCharCode
1 parent a3e4e62 commit 0c52b5a

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,19 @@ class StringSplitHashOrQuestionMark extends SummarizedCallable {
9999
)
100100
}
101101
}
102+
103+
class StringFromCharCode extends SummarizedCallable {
104+
StringFromCharCode() { this = "String#fromCharCode" }
105+
106+
override DataFlow::CallNode getACall() {
107+
result = DataFlow::globalVarRef("String").getAPropertyRead("fromCharCode").getACall()
108+
}
109+
110+
override predicate propagatesFlow(string input, string output, boolean preservesValue) {
111+
preservesValue = true and
112+
(
113+
input = "Argument[0..]" and
114+
output = "ReturnValue"
115+
)
116+
}
117+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ legacyDataFlowDifference
4040
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:11:10:11:12 | arr | only flow with NEW data flow library |
4141
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:15:10:15:10 | z | only flow with NEW data flow library |
4242
| 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:42:10:42:30 | typedAr ... ring(y) | only flow with NEW data flow library |
4344
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:48:10:48:12 | str | only flow with NEW data flow library |
4445
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:52:10:52:13 | str2 | only flow with NEW data flow library |
4546
| 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 |
@@ -51,7 +52,6 @@ consistencyIssue
5152
| typed-arrays.js:28 | expected an alert, but found none | NOT OK -- Should be flagged but it is not. | Consistency |
5253
| typed-arrays.js:32 | expected an alert, but found none | NOT OK -- Should be flagged but it is not. | Consistency |
5354
| typed-arrays.js:36 | expected an alert, but found none | NOT OK -- Should be flagged but it is not. | Consistency |
54-
| typed-arrays.js:42 | expected an alert, but found none | NOT OK -- Should be flagged but it is not. | Consistency |
5555
flow
5656
| access-path-sanitizer.js:2:18:2:25 | source() | access-path-sanitizer.js:4:8:4:12 | obj.x |
5757
| addexpr.js:4:10:4:17 | source() | addexpr.js:7:8:7:8 | x |
@@ -342,6 +342,7 @@ flow
342342
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:11:10:11:12 | arr |
343343
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:15:10:15:10 | z |
344344
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:18:10:18:12 | sub |
345+
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:42:10:42:30 | typedAr ... ring(y) |
345346
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:48:10:48:12 | str |
346347
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:52:10:52:13 | str2 |
347348
| use-use-after-implicit-read.js:7:17:7:24 | source() | use-use-after-implicit-read.js:8:10:8:17 | captured |

javascript/ql/test/library-tests/TaintTracking/typed-arrays.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function test() {
3939
return function (a) { return String.fromCharCode.apply(null, a); };
4040
})();
4141

42-
sink(typedArrayToString(y)); // NOT OK -- Should be flagged but it is not.
42+
sink(typedArrayToString(y)); // NOT OK
4343

4444
let str = '';
4545
for (let i = 0; i < y.length; i++)

0 commit comments

Comments
 (0)