Skip to content

Commit 1d8051e

Browse files
author
Max Schaefer
committed
JavaScript: Further improve handling of re-exports in API graphs.
1 parent d054206 commit 1d8051e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,16 @@ module API {
645645
rhs(_, nd) and
646646
result = nd.getALocalSource()
647647
or
648+
// additional backwards step from `require('m')` to `exports` or `module.exports` in m
649+
exists(Import imp | imp.getImportedModuleNode() = trackDefNode(nd, t.continue()) |
650+
result.(ExportsAsSourceNode).getModule() = imp.getImportedModule()
651+
or
652+
exists(ModuleAsSourceNode mod |
653+
mod.getModule() = imp.getImportedModule() and
654+
result = mod.(DataFlow::SourceNode).getAPropertyRead("exports")
655+
)
656+
)
657+
or
648658
exists(DataFlow::TypeBackTracker t2 | result = trackDefNode(nd, t2).backtrack(t2, t))
649659
}
650660

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
| 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)