Skip to content

Commit 5b0e26c

Browse files
committed
JS: Use API graphs a few more places
1 parent 4ff135e commit 5b0e26c

File tree

1 file changed

+9
-14
lines changed
  • javascript/ql/lib/semmle/javascript/frameworks

1 file changed

+9
-14
lines changed

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,9 @@ module Vue {
228228
* extended objects and mixins.
229229
*/
230230
pragma[nomagic]
231-
DataFlow::SourceNode getOptionSource(string name) { result = getOption(name).getALocalSource() }
231+
DataFlow::SourceNode getOptionSource(string name) {
232+
result = getOptions().getMember(name).getAValueReachingRhs()
233+
}
232234

233235
/**
234236
* Gets the template element used by this component, if any.
@@ -239,15 +241,9 @@ module Vue {
239241
* Gets the node for the `data` option object of this component.
240242
*/
241243
DataFlow::Node getData() {
242-
exists(DataFlow::Node data | data = getOption("data") |
243-
result = data
244-
or
245-
// a constructor variant is available for all component definitions
246-
exists(DataFlow::FunctionNode f |
247-
f.flowsTo(data) and
248-
result = f.getAReturn()
249-
)
250-
)
244+
result = getOption("data")
245+
or
246+
result = getOptionSource("data").(DataFlow::FunctionNode).getReturnNode()
251247
or
252248
result = getAsClassComponent().getAReceiverNode()
253249
or
@@ -292,10 +288,9 @@ module Vue {
292288
* Gets the function responding to changes to the given `propName`.
293289
*/
294290
DataFlow::FunctionNode getWatchHandler(string propName) {
295-
exists(DataFlow::SourceNode watcher | watcher = getWatch().getAPropertySource(propName) |
296-
result = watcher
297-
or
298-
result = watcher.getAPropertySource("handler")
291+
exists(API::Node propWatch |
292+
propWatch = getOptions().getMember("watch").getMember(propName) and
293+
result = [propWatch, propWatch.getMember("handler")].getAValueReachingRhs()
299294
)
300295
}
301296

0 commit comments

Comments
 (0)