Skip to content

Commit 9cfbe6f

Browse files
authored
Merge pull request #4980 from erik-krogh/defaultExport
Approved by esbena
2 parents 3877f03 + a44aefa commit 9cfbe6f

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed

javascript/ql/src/semmle/javascript/PackageExports.qll

+4
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,9 @@ private DataFlow::Node getAValueExportedByPackage() {
7878
private DataFlow::Node getAnExportFromModule(Module mod) {
7979
result.analyze().getAValue() = mod.(NodeModule).getAModuleExportsValue()
8080
or
81+
result = mod.(Closure::ClosureModule).getExportsVariable().getAnAssignedExpr().flow()
82+
or
83+
result.analyze().getAValue() = mod.(AmdModule).getDefine().getAModuleExportsValue()
84+
or
8185
result = mod.getAnExportedValue(_)
8286
}

javascript/ql/test/query-tests/Performance/ReDoS/PolynomialBackTracking.expected

+2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
| highlight.js:38:54:38:59 | [^()]* | Strings starting with 'A((' and with many repetitions of ''' can start matching anywhere after the start of the preceeding [^()]* |
2525
| highlight.js:38:64:38:69 | [^()]* | Strings starting with 'A(' and with many repetitions of ''' can start matching anywhere after the start of the preceeding [^()]* |
2626
| highlight.js:39:22:39:24 | \\w* | Strings starting with 'A' and with many repetitions of 'A' can start matching anywhere after the start of the preceeding [a-zA-Z_]\\w*\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{ |
27+
| lib/closure.js:4:6:4:7 | u* | Strings with many repetitions of 'u' can start matching anywhere after the start of the preceeding u*o |
2728
| lib/lib.js:1:15:1:16 | a* | Strings with many repetitions of 'a' can start matching anywhere after the start of the preceeding a*b |
29+
| lib/lib.js:8:3:8:4 | f* | Strings with many repetitions of 'f' can start matching anywhere after the start of the preceeding f*g |
2830
| polynomial-redos.js:7:24:7:26 | \\s+ | Strings with many repetitions of ' ' can start matching anywhere after the start of the preceeding \\s+$ |
2931
| polynomial-redos.js:8:17:8:18 | * | Strings with many repetitions of ' ' can start matching anywhere after the start of the preceeding *, * |
3032
| polynomial-redos.js:9:19:9:21 | \\s* | Strings with many repetitions of ' ' can start matching anywhere after the start of the preceeding \\s*\\n\\s* |

javascript/ql/test/query-tests/Performance/ReDoS/PolynomialReDoS.expected

+18
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
nodes
2+
| lib/closure.js:3:21:3:21 | x |
3+
| lib/closure.js:3:21:3:21 | x |
4+
| lib/closure.js:4:16:4:16 | x |
5+
| lib/closure.js:4:16:4:16 | x |
26
| lib/lib.js:3:28:3:31 | name |
37
| lib/lib.js:3:28:3:31 | name |
48
| lib/lib.js:4:14:4:17 | name |
59
| lib/lib.js:4:14:4:17 | name |
10+
| lib/lib.js:7:19:7:22 | name |
11+
| lib/lib.js:7:19:7:22 | name |
12+
| lib/lib.js:8:13:8:16 | name |
13+
| lib/lib.js:8:13:8:16 | name |
614
| polynomial-redos.js:5:6:5:32 | tainted |
715
| polynomial-redos.js:5:16:5:32 | req.query.tainted |
816
| polynomial-redos.js:5:16:5:32 | req.query.tainted |
@@ -146,10 +154,18 @@ nodes
146154
| polynomial-redos.js:124:12:124:17 | result |
147155
| polynomial-redos.js:124:12:124:17 | result |
148156
edges
157+
| lib/closure.js:3:21:3:21 | x | lib/closure.js:4:16:4:16 | x |
158+
| lib/closure.js:3:21:3:21 | x | lib/closure.js:4:16:4:16 | x |
159+
| lib/closure.js:3:21:3:21 | x | lib/closure.js:4:16:4:16 | x |
160+
| lib/closure.js:3:21:3:21 | x | lib/closure.js:4:16:4:16 | x |
149161
| lib/lib.js:3:28:3:31 | name | lib/lib.js:4:14:4:17 | name |
150162
| lib/lib.js:3:28:3:31 | name | lib/lib.js:4:14:4:17 | name |
151163
| lib/lib.js:3:28:3:31 | name | lib/lib.js:4:14:4:17 | name |
152164
| lib/lib.js:3:28:3:31 | name | lib/lib.js:4:14:4:17 | name |
165+
| lib/lib.js:7:19:7:22 | name | lib/lib.js:8:13:8:16 | name |
166+
| lib/lib.js:7:19:7:22 | name | lib/lib.js:8:13:8:16 | name |
167+
| lib/lib.js:7:19:7:22 | name | lib/lib.js:8:13:8:16 | name |
168+
| lib/lib.js:7:19:7:22 | name | lib/lib.js:8:13:8:16 | name |
153169
| polynomial-redos.js:5:6:5:32 | tainted | polynomial-redos.js:7:2:7:8 | tainted |
154170
| polynomial-redos.js:5:6:5:32 | tainted | polynomial-redos.js:7:2:7:8 | tainted |
155171
| polynomial-redos.js:5:6:5:32 | tainted | polynomial-redos.js:8:2:8:8 | tainted |
@@ -288,7 +304,9 @@ edges
288304
| polynomial-redos.js:123:3:123:20 | result | polynomial-redos.js:124:12:124:17 | result |
289305
| polynomial-redos.js:123:13:123:20 | replaced | polynomial-redos.js:123:3:123:20 | result |
290306
#select
307+
| lib/closure.js:4:5:4:17 | /u*o/.test(x) | lib/closure.js:3:21:3:21 | x | lib/closure.js:4:16:4:16 | x | This $@ that depends on $@ may run slow on strings with many repetitions of 'u'. | lib/closure.js:4:6:4:7 | u* | regular expression | lib/closure.js:3:21:3:21 | x | library input |
291308
| lib/lib.js:4:2:4:18 | regexp.test(name) | lib/lib.js:3:28:3:31 | name | lib/lib.js:4:14:4:17 | name | This $@ that depends on $@ may run slow on strings with many repetitions of 'a'. | lib/lib.js:1:15:1:16 | a* | regular expression | lib/lib.js:3:28:3:31 | name | library input |
309+
| lib/lib.js:8:2:8:17 | /f*g/.test(name) | lib/lib.js:7:19:7:22 | name | lib/lib.js:8:13:8:16 | name | This $@ that depends on $@ may run slow on strings with many repetitions of 'f'. | lib/lib.js:8:3:8:4 | f* | regular expression | lib/lib.js:7:19:7:22 | name | library input |
292310
| polynomial-redos.js:7:2:7:34 | tainted ... /g, '') | polynomial-redos.js:5:16:5:32 | req.query.tainted | polynomial-redos.js:7:2:7:8 | tainted | This $@ that depends on $@ may run slow on strings with many repetitions of ' '. | polynomial-redos.js:7:24:7:26 | \\s+ | regular expression | polynomial-redos.js:5:16:5:32 | req.query.tainted | a user-provided value |
293311
| polynomial-redos.js:8:2:8:23 | tainted ... *, */) | polynomial-redos.js:5:16:5:32 | req.query.tainted | polynomial-redos.js:8:2:8:8 | tainted | This $@ that depends on $@ may run slow on strings with many repetitions of ' '. | polynomial-redos.js:8:17:8:18 | * | regular expression | polynomial-redos.js:5:16:5:32 | req.query.tainted | a user-provided value |
294312
| polynomial-redos.js:9:2:9:34 | tainted ... g, ' ') | polynomial-redos.js:5:16:5:32 | req.query.tainted | polynomial-redos.js:9:2:9:8 | tainted | This $@ that depends on $@ may run slow on strings with many repetitions of ' '. | polynomial-redos.js:9:19:9:21 | \\s* | regular expression | polynomial-redos.js:5:16:5:32 | req.query.tainted | a user-provided value |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
goog.module('x.y.z.closure2');
2+
3+
exports = function (x) {
4+
/u*o/.test(x); // NOT OK
5+
}

javascript/ql/test/query-tests/Performance/ReDoS/lib/lib.js

+10
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,13 @@ var regexp = /a*b/;
33
module.exports = function (name) {
44
regexp.test(name); // NOT OK
55
};
6+
7+
function bar(reg, name) {
8+
/f*g/.test(name); // NOT OK
9+
}
10+
11+
if (typeof define !== 'undefined' && define.amd) { // AMD
12+
define([], function () {return bar});
13+
}
14+
15+
module.exports.closure = require("./closure")

0 commit comments

Comments
 (0)