Skip to content

Commit d054206

Browse files
author
Max Schaefer
committed
JavaScript: Improve handling of re-exports in API graphs.
1 parent 96bf82e commit d054206

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

javascript/ql/src/semmle/javascript/ApiGraphs.qll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,11 +419,20 @@ module API {
419419
exists(DataFlow::Node def, DataFlow::SourceNode pred |
420420
rhs(base, def) and pred = trackDefNode(def)
421421
|
422+
// from `x` to a definition of `x.prop`
422423
exists(DataFlow::PropWrite pw | pw = pred.getAPropertyWrite() |
423424
lbl = Label::memberFromRef(pw) and
424425
rhs = pw.getRhs()
425426
)
426427
or
428+
// special case: from `require('m')` to an export of `prop` in `m`
429+
exists(Import imp, Module m, string prop |
430+
pred = imp.getImportedModuleNode() and
431+
m = imp.getImportedModule() and
432+
lbl = Label::member(prop) and
433+
rhs = m.getAnExportedValue(prop)
434+
)
435+
or
427436
exists(DataFlow::FunctionNode fn | fn = pred |
428437
not fn.getFunction().isAsync() and
429438
lbl = Label::return() and
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
| lib/stuff.js:1:19:1:103 | /* use ... )))) */ | def (member other (member exports (module reexport))) has no outgoing edge labelled member bar; it has no outgoing edges at all. |
21
| lib/utils.js:1:38:1:120 | /* use ... )))) */ | def (member util (member exports (module reexport))) has no outgoing edge labelled member id; it has no outgoing edges at all. |

0 commit comments

Comments
 (0)