Skip to content

Commit 76c38a5

Browse files
committed
JS: Port vue() to API graphs
1 parent cf9ab83 commit 76c38a5

File tree

1 file changed

+22
-8
lines changed
  • javascript/ql/lib/semmle/javascript/frameworks

1 file changed

+22
-8
lines changed

javascript/ql/lib/semmle/javascript/frameworks/Vue.qll

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,43 @@
55
import javascript
66

77
module Vue {
8+
/** The global variable `Vue`, as an API graph entry point. */
9+
private class GlobalVueEntryPoint extends API::EntryPoint {
10+
GlobalVueEntryPoint() { this = "VueEntryPoint" }
11+
12+
override DataFlow::SourceNode getAUse() { result = DataFlow::globalVarRef("Vue") }
13+
14+
override DataFlow::Node getARhs() { none() }
15+
}
16+
817
/**
9-
* Gets a reference to the 'Vue' object.
18+
* Gets a reference to the `Vue` object.
1019
*/
11-
DataFlow::SourceNode vue() {
12-
result = DataFlow::globalVarRef("Vue")
20+
API::Node vueLibrary() {
21+
result = API::moduleImport("vue")
1322
or
14-
result = DataFlow::moduleImport("vue")
23+
result = API::root().getASuccessor(any(GlobalVueEntryPoint e))
1524
}
1625

26+
/**
27+
* Gets a reference to the 'Vue' object.
28+
*/
29+
DataFlow::SourceNode vue() { result = vueLibrary().getAnImmediateUse() }
30+
1731
/**
1832
* A call to `vue.extend`.
1933
*/
20-
private class VueExtend extends DataFlow::CallNode {
21-
VueExtend() { this = vue().getAMemberCall("extend") }
34+
private class VueExtend extends API::CallNode {
35+
VueExtend() { this = vueLibrary().getMember("extend").getACall() }
2236
}
2337

2438
private newtype TComponent =
25-
MkVueInstance(DataFlow::NewNode def) { def = vue().getAnInstantiation() } or
39+
MkVueInstance(DataFlow::NewNode def) { def = vueLibrary().getAnInstantiation() } or
2640
MkExtendedVue(VueExtend extend) or
2741
MkExtendedInstance(VueExtend extend, DataFlow::NewNode sub) {
2842
sub = extend.getAnInstantiation()
2943
} or
30-
MkComponentRegistration(DataFlow::CallNode def) { def = vue().getAMemberCall("component") } or
44+
MkComponentRegistration(DataFlow::CallNode def) { def = vueLibrary().getMember("component").getACall() } or
3145
MkSingleFileComponent(VueFile file)
3246

3347
/** Gets the name of a lifecycle hook method. */

0 commit comments

Comments
 (0)