Skip to content

Commit 7d8bb33

Browse files
committed
add support for destructuring object exports in getAnExportedValue
1 parent c1b5357 commit 7d8bb33

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

javascript/ql/src/semmle/javascript/ES2015Modules.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,13 @@ class ExportNamedDeclaration extends ExportDeclaration, @export_named_declaratio
395395
result = DataFlow::valueNode(d.getSource())
396396
)
397397
or
398+
exists(ObjectPattern obj | obj = getOperand().(DeclStmt).getADecl().getBindingPattern() |
399+
exists(DataFlow::PropRead read | read = result |
400+
read.getBase() = obj.flow() and
401+
name = read.getPropertyName()
402+
)
403+
)
404+
or
398405
exists(ExportSpecifier spec | spec = getASpecifier() and name = spec.getExportedName() |
399406
not exists(getImportedPath()) and result = DataFlow::valueNode(spec.getLocal())
400407
or

javascript/ql/test/library-tests/Modules/tests.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ test_Imports
7171
test_Module_exports
7272
| a.js:1:1:5:32 | <toplevel> | default | a.js:1:16:3:1 | functio ... n 23;\\n} |
7373
| a.js:1:1:5:32 | <toplevel> | x | a.js:5:18:5:20 | f() |
74+
| a.js:1:1:5:32 | <toplevel> | y | a.js:5:25:5:25 | y |
7475
| b.js:1:1:8:0 | <toplevel> | f2 | a.js:1:16:3:1 | functio ... n 23;\\n} |
7576
| b.js:1:1:8:0 | <toplevel> | g | b.js:5:10:5:10 | f |
7677
| e.js:1:1:4:0 | <toplevel> | g | a.js:1:16:3:1 | functio ... n 23;\\n} |
@@ -135,6 +136,7 @@ test_getLocalName
135136
test_getSourceNode
136137
| a.js:1:1:3:1 | export ... n 23;\\n} | default | a.js:1:16:3:1 | functio ... n 23;\\n} |
137138
| a.js:5:1:5:32 | export ... } = o; | x | a.js:5:18:5:20 | f() |
139+
| a.js:5:1:5:32 | export ... } = o; | y | a.js:5:25:5:25 | y |
138140
| b.js:5:1:5:18 | export { f as g }; | g | b.js:5:10:5:10 | f |
139141
| b.js:7:1:7:21 | export ... './a'; | f2 | a.js:1:16:3:1 | functio ... n 23;\\n} |
140142
| e.js:2:1:2:16 | export { x, y }; | x | e.js:2:10:2:10 | x |

0 commit comments

Comments
 (0)