Skip to content

Commit 54c780b

Browse files
authored
Merge pull request github#11853 from erik-krogh/assignMore
JS: add local flow when recognizing Object.assign calls for library-inputs
2 parents 72a11e7 + 62b69bb commit 54c780b

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

javascript/ql/lib/semmle/javascript/PackageExports.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ private DataFlow::Node getAValueExportedByPackage() {
200200
or
201201
// Object.assign and friends
202202
exists(ExtendCall assign |
203-
getAValueExportedByPackage() = [assign, assign.getDestinationOperand()] and
203+
getAValueExportedByPackage() = [assign, assign.getDestinationOperand().getALocalSource()]
204+
|
204205
result = assign.getASourceOperand()
205206
)
206207
or

javascript/ql/test/query-tests/Security/CWE-400/ReDoS/PolynomialBackTracking.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
| lib/lib.js:36:3:36:4 | f* | Strings with many repetitions of 'f' can start matching anywhere after the start of the preceeding f*g |
3636
| lib/lib.js:42:29:42:30 | f* | Strings with many repetitions of 'f' can start matching anywhere after the start of the preceeding f*g |
3737
| lib/lib.js:45:29:45:30 | f* | Strings with many repetitions of 'f' can start matching anywhere after the start of the preceeding f*g |
38+
| lib/lib.js:53:6:53:7 | f* | Strings with many repetitions of 'f' can start matching anywhere after the start of the preceeding f*g |
3839
| lib/moduleLib/moduleLib.js:2:3:2:4 | a* | Strings with many repetitions of 'a' can start matching anywhere after the start of the preceeding a*b |
3940
| lib/otherLib/js/src/index.js:2:3:2:4 | a* | Strings with many repetitions of 'a' can start matching anywhere after the start of the preceeding a*b |
4041
| lib/snapdragon.js:7:28:7:29 | a* | Strings starting with 'a' and with many repetitions of 'a' can start matching anywhere after the start of the preceeding aa*$ |

javascript/ql/test/query-tests/Security/CWE-400/ReDoS/PolynomialReDoS.expected

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ nodes
3737
| lib/lib.js:44:12:44:25 | name.substr(1) |
3838
| lib/lib.js:45:17:45:20 | name |
3939
| lib/lib.js:45:17:45:20 | name |
40+
| lib/lib.js:52:22:52:25 | name |
41+
| lib/lib.js:52:22:52:25 | name |
42+
| lib/lib.js:53:16:53:19 | name |
43+
| lib/lib.js:53:16:53:19 | name |
4044
| lib/moduleLib/moduleLib.js:1:28:1:31 | name |
4145
| lib/moduleLib/moduleLib.js:1:28:1:31 | name |
4246
| lib/moduleLib/moduleLib.js:2:13:2:16 | name |
@@ -273,6 +277,10 @@ edges
273277
| lib/lib.js:44:5:44:25 | name | lib/lib.js:45:17:45:20 | name |
274278
| lib/lib.js:44:12:44:15 | name | lib/lib.js:44:12:44:25 | name.substr(1) |
275279
| lib/lib.js:44:12:44:25 | name.substr(1) | lib/lib.js:44:5:44:25 | name |
280+
| lib/lib.js:52:22:52:25 | name | lib/lib.js:53:16:53:19 | name |
281+
| lib/lib.js:52:22:52:25 | name | lib/lib.js:53:16:53:19 | name |
282+
| lib/lib.js:52:22:52:25 | name | lib/lib.js:53:16:53:19 | name |
283+
| lib/lib.js:52:22:52:25 | name | lib/lib.js:53:16:53:19 | name |
276284
| lib/moduleLib/moduleLib.js:1:28:1:31 | name | lib/moduleLib/moduleLib.js:2:13:2:16 | name |
277285
| lib/moduleLib/moduleLib.js:1:28:1:31 | name | lib/moduleLib/moduleLib.js:2:13:2:16 | name |
278286
| lib/moduleLib/moduleLib.js:1:28:1:31 | name | lib/moduleLib/moduleLib.js:2:13:2:16 | name |
@@ -471,6 +479,7 @@ edges
471479
| lib/lib.js:36:2:36:17 | /f*g/.test(name) | lib/lib.js:32:32:32:40 | arguments | lib/lib.js:36:13:36:16 | name | This $@ that depends on $@ may run slow on strings with many repetitions of 'f'. | lib/lib.js:36:3:36:4 | f* | regular expression | lib/lib.js:32:32:32:40 | arguments | library input |
472480
| lib/lib.js:42:17:42:33 | name.match(/f*g/) | lib/lib.js:41:32:41:35 | name | lib/lib.js:42:17:42:20 | name | This $@ that depends on $@ may run slow on strings with many repetitions of 'f'. | lib/lib.js:42:29:42:30 | f* | regular expression | lib/lib.js:41:32:41:35 | name | library input |
473481
| lib/lib.js:45:17:45:33 | name.match(/f*g/) | lib/lib.js:41:32:41:35 | name | lib/lib.js:45:17:45:20 | name | This $@ that depends on $@ may run slow on strings with many repetitions of 'f'. | lib/lib.js:45:29:45:30 | f* | regular expression | lib/lib.js:41:32:41:35 | name | library input |
482+
| lib/lib.js:53:5:53:20 | /f*g/.test(name) | lib/lib.js:52:22:52:25 | name | lib/lib.js:53:16:53:19 | name | This $@ that depends on $@ may run slow on strings with many repetitions of 'f'. | lib/lib.js:53:6:53:7 | f* | regular expression | lib/lib.js:52:22:52:25 | name | library input |
474483
| lib/moduleLib/moduleLib.js:2:2:2:17 | /a*b/.test(name) | lib/moduleLib/moduleLib.js:1:28:1:31 | name | lib/moduleLib/moduleLib.js:2:13:2:16 | name | This $@ that depends on $@ may run slow on strings with many repetitions of 'a'. | lib/moduleLib/moduleLib.js:2:3:2:4 | a* | regular expression | lib/moduleLib/moduleLib.js:1:28:1:31 | name | library input |
475484
| lib/otherLib/js/src/index.js:2:2:2:17 | /a*b/.test(name) | lib/otherLib/js/src/index.js:1:28:1:31 | name | lib/otherLib/js/src/index.js:2:13:2:16 | name | This $@ that depends on $@ may run slow on strings with many repetitions of 'a'. | lib/otherLib/js/src/index.js:2:3:2:4 | a* | regular expression | lib/otherLib/js/src/index.js:1:28:1:31 | name | library input |
476485
| lib/snapdragon.js:7:15:7:32 | this.match(/aa*$/) | lib/snapdragon.js:3:34:3:38 | input | lib/snapdragon.js:7:15:7:18 | this | This $@ that depends on $@ may run slow on strings starting with 'a' and with many repetitions of 'a'. | lib/snapdragon.js:7:28:7:29 | a* | regular expression | lib/snapdragon.js:3:34:3:38 | input | library input |

javascript/ql/test/query-tests/Security/CWE-400/ReDoS/lib/lib.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,13 @@ module.exports.foo = function (name) {
4343

4444
name = name.substr(1);
4545
var data2 = name.match(/f*g/); // NOT OK
46-
}
46+
}
47+
48+
var indirectAssign = {};
49+
module.exports.indirectAssign = indirectAssign;
50+
51+
Object.assign(indirectAssign, {
52+
myThing: function (name) {
53+
/f*g/.test(name); // NOT OK
54+
},
55+
});

0 commit comments

Comments
 (0)