Skip to content

Commit b97c618

Browse files
committed
Add flow summaries and entry points for TextDecoder
1 parent f28478e commit b97c618

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ private import Strings
1313
private import DynamicImportStep
1414
private import UrlSearchParams
1515
private import TypedArrays
16+
private import Decoders
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
private import javascript
2+
private import semmle.javascript.dataflow.FlowSummary
3+
private import semmle.javascript.dataflow.InferredTypes
4+
private import semmle.javascript.dataflow.internal.DataFlowPrivate as Private
5+
private import FlowSummaryUtil
6+
7+
private class TextDecoderEntryPoint extends API::EntryPoint {
8+
TextDecoderEntryPoint() { this = "global.TextDecoder" }
9+
10+
override DataFlow::SourceNode getASource() { result = DataFlow::globalVarRef("TextDecoder") }
11+
}
12+
13+
pragma[nomagic]
14+
API::Node textDecoderConstructorRef() { result = any(TextDecoderEntryPoint e).getANode() }
15+
16+
class DecodeLike extends SummarizedCallable {
17+
DecodeLike() { this = "TextDecoder#decode" }
18+
19+
override InstanceCall getACall() {
20+
result =
21+
textDecoderConstructorRef().getAnInstantiation().getReturn().getMember("decode").getACall()
22+
}
23+
24+
override predicate propagatesFlow(string input, string output, boolean preservesValue) {
25+
preservesValue = true and
26+
input = "Argument[0]" and
27+
output = "ReturnValue"
28+
}
29+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ legacyDataFlowDifference
4545
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:30:10:30:23 | transferedView | only flow with NEW data flow library |
4646
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:34:10:34:24 | transferedView2 | only flow with NEW data flow library |
4747
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:46:10:46:12 | str | only flow with NEW data flow library |
48+
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:50:10:50:13 | str2 | only flow with NEW data flow library |
4849
| 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 |
4950
consistencyIssue
5051
| nested-props.js:20 | expected an alert, but found none | NOT OK - but not found | Consistency |
5152
| stringification-read-steps.js:17 | expected an alert, but found none | NOT OK | Consistency |
5253
| stringification-read-steps.js:25 | expected an alert, but found none | NOT OK | Consistency |
5354
| typed-arrays.js:40 | expected an alert, but found none | NOT OK -- Should be flagged but it is not. | Consistency |
54-
| typed-arrays.js:50 | expected an alert, but found none | NOT OK | 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 |
@@ -347,6 +347,7 @@ flow
347347
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:30:10:30:23 | transferedView |
348348
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:34:10:34:24 | transferedView2 |
349349
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:46:10:46:12 | str |
350+
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:50:10:50:13 | str2 |
350351
| use-use-after-implicit-read.js:7:17:7:24 | source() | use-use-after-implicit-read.js:8:10:8:17 | captured |
351352
| use-use-after-implicit-read.js:7:17:7:24 | source() | use-use-after-implicit-read.js:15:10:15:10 | x |
352353
| xml.js:5:18:5:25 | source() | xml.js:8:14:8:17 | text |

0 commit comments

Comments
 (0)