Skip to content

Commit edb9b47

Browse files
authored
Merge pull request #18047 from Napalys/napalys/ES2023-string-protytpe-toWellFormed
JS: Added taint-step String.prototype.toWellFormed ES2023 feature
2 parents c80a45f + 43eda58 commit edb9b47

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Added taint-steps for `String.prototype.toWellFormed`.

javascript/ql/lib/semmle/javascript/dataflow/TaintTracking.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ module TaintTracking {
612612
"italics", "link", "padEnd", "padStart", "repeat", "replace", "replaceAll", "slice",
613613
"small", "split", "strike", "sub", "substr", "substring", "sup",
614614
"toLocaleLowerCase", "toLocaleUpperCase", "toLowerCase", "toUpperCase", "trim",
615-
"trimLeft", "trimRight"
615+
"trimLeft", "trimRight", "toWellFormed"
616616
]
617617
or
618618
// sorted, interesting, properties of Object.prototype

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ typeInferenceMismatch
209209
| static-capture-groups.js:2:17:2:24 | source() | static-capture-groups.js:27:14:27:22 | RegExp.$1 |
210210
| static-capture-groups.js:32:17:32:24 | source() | static-capture-groups.js:38:10:38:18 | RegExp.$1 |
211211
| static-capture-groups.js:42:12:42:19 | source() | static-capture-groups.js:43:14:43:22 | RegExp.$1 |
212+
| string-immutable-operations.js:2:13:2:20 | source() | string-immutable-operations.js:3:10:3:25 | x.toWellFormed() |
213+
| string-immutable-operations.js:2:13:2:20 | source() | string-immutable-operations.js:6:10:6:20 | wellFormedX |
214+
| string-immutable-operations.js:2:13:2:20 | source() | string-immutable-operations.js:9:10:9:26 | concatWellFormedX |
215+
| string-immutable-operations.js:11:10:11:17 | source() | string-immutable-operations.js:11:10:11:32 | source( ... ormed() |
212216
| string-replace.js:3:13:3:20 | source() | string-replace.js:14:10:14:13 | data |
213217
| string-replace.js:3:13:3:20 | source() | string-replace.js:18:10:18:13 | data |
214218
| string-replace.js:3:13:3:20 | source() | string-replace.js:21:6:21:41 | safe(). ... taint) |
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function test() {
2+
let x = source();
3+
sink(x.toWellFormed()); // NOT OK
4+
5+
const wellFormedX = x.toWellFormed();
6+
sink(wellFormedX); // NOT OK
7+
8+
const concatWellFormedX = "/" + wellFormedX + "!";
9+
sink(concatWellFormedX); // NOT OK
10+
11+
sink(source().toWellFormed()); // NOT OK
12+
}

0 commit comments

Comments
 (0)