Skip to content

Commit 33c553b

Browse files
committed
Add flow summaries and entry points for TextDecoder
1 parent fd02b45 commit 33c553b

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

+1
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
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

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ legacyDataFlowDifference
4646
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:34:10:34:23 | transferedView | only flow with NEW data flow library |
4747
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:38:10:38:24 | transferedView2 | only flow with NEW data flow library |
4848
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:50:10:50:12 | str | only flow with NEW data flow library |
49+
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:54:10:54:13 | str2 | only flow with NEW data flow library |
4950
| 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 |
5051
consistencyIssue
5152
| nested-props.js:20 | expected an alert, but found none | NOT OK - but not found | Consistency |
5253
| stringification-read-steps.js:17 | expected an alert, but found none | NOT OK | Consistency |
5354
| stringification-read-steps.js:25 | expected an alert, but found none | NOT OK | Consistency |
5455
| typed-arrays.js:44 | expected an alert, but found none | NOT OK -- Should be flagged but it is not. | Consistency |
55-
| typed-arrays.js:54 | expected an alert, but found none | NOT OK | Consistency |
5656
flow
5757
| access-path-sanitizer.js:2:18:2:25 | source() | access-path-sanitizer.js:4:8:4:12 | obj.x |
5858
| addexpr.js:4:10:4:17 | source() | addexpr.js:7:8:7:8 | x |
@@ -349,6 +349,7 @@ flow
349349
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:34:10:34:23 | transferedView |
350350
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:38:10:38:24 | transferedView2 |
351351
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:50:10:50:12 | str |
352+
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:54:10:54:13 | str2 |
352353
| use-use-after-implicit-read.js:7:17:7:24 | source() | use-use-after-implicit-read.js:8:10:8:17 | captured |
353354
| use-use-after-implicit-read.js:7:17:7:24 | source() | use-use-after-implicit-read.js:15:10:15:10 | x |
354355
| xml.js:5:18:5:25 | source() | xml.js:8:14:8:17 | text |

0 commit comments

Comments
 (0)