Skip to content

Commit 5cd0996

Browse files
committed
JS: Deprecate getOwnOptionsObject()
1 parent 7be4b76 commit 5cd0996

File tree

1 file changed

+5
-37
lines changed
  • javascript/ql/lib/semmle/javascript/frameworks

1 file changed

+5
-37
lines changed

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

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -190,25 +190,27 @@ module Vue {
190190
}
191191

192192
/**
193+
* DEPRECATED. Use `getOwnOptions().getARhs()`.
194+
*
193195
* Gets the options passed to the Vue object, such as the object literal `{...}` in `new Vue{{...})`
194196
* or the default export of a single-file component.
195197
*/
196-
DataFlow::Node getOwnOptionsObject() { none() } // overridden in subclasses
198+
deprecated DataFlow::Node getOwnOptionsObject() { none() } // overridden in subclasses
197199

198200
/**
199201
* Gets the class implementing this Vue component, if any.
200202
*
201203
* Specifically, this is a class annotated with `@Component` which flows to the options
202204
* object of this Vue component.
203205
*/
204-
ClassComponent getAsClassComponent() { result.flowsTo(getOwnOptionsObject()) }
206+
ClassComponent getAsClassComponent() { result = getOwnOptions().getAValueReachingRhs() }
205207

206208
/**
207209
* Gets the node for option `name` for this component, not including
208210
* those from extended objects and mixins.
209211
*/
210212
DataFlow::Node getOwnOption(string name) {
211-
result = getOwnOptionsObject().getALocalSource().getAPropertyWrite(name).getRhs()
213+
result = getOwnOptions().getMember(name).getARhs()
212214
}
213215

214216
/**
@@ -378,8 +380,6 @@ module Vue {
378380

379381
override API::Node getOwnOptions() { result = def.getParameter(0) }
380382

381-
override DataFlow::Node getOwnOptionsObject() { result = def.getArgument(0) }
382-
383383
override Template::Element getTemplateElement() { none() }
384384

385385
override Component getABaseComponent() {
@@ -426,8 +426,6 @@ module Vue {
426426

427427
override API::Node getOwnOptions() { result = extend.getParameter(0) }
428428

429-
override DataFlow::Node getOwnOptionsObject() { result = extend.getArgument(0) }
430-
431429
override Template::Element getTemplateElement() { none() }
432430

433431
override Component getABaseComponent() {
@@ -473,8 +471,6 @@ module Vue {
473471

474472
override API::Node getOwnOptions() { result = def.getParameter(1) }
475473

476-
override DataFlow::Node getOwnOptionsObject() { result = def.getArgument(1) }
477-
478474
override Template::Element getTemplateElement() { none() }
479475
}
480476

@@ -547,34 +543,6 @@ module Vue {
547543
result.getARhs() = getModule().getDefaultOrBulkExport()
548544
}
549545

550-
override DataFlow::Node getOwnOptionsObject() {
551-
exists(ExportDefaultDeclaration decl |
552-
decl.getTopLevel() = getModule() and
553-
result = DataFlow::valueNode(decl.getOperand())
554-
)
555-
}
556-
557-
override DataFlow::Node getOwnOption(string name) {
558-
// The options of a single file component are defined by the exported object of the script element.
559-
// Our current module model does not support reads on this object very well, so we use custom steps for the common cases for now.
560-
exists(Module m, DefiniteAbstractValue abstractOptions |
561-
any(AnalyzedPropertyWrite write).writes(abstractOptions, name, result) and
562-
m = getModule()
563-
|
564-
// ES2015 exports
565-
exists(ExportDeclaration export, DataFlow::AnalyzedNode exported |
566-
export.getEnclosingModule() = m and
567-
abstractOptions = exported.getAValue()
568-
|
569-
exported = export.(BulkReExportDeclaration).getSourceNode("default") or
570-
exported.asExpr() = export.(ExportDefaultDeclaration).getOperand()
571-
)
572-
or
573-
// Node.js exports
574-
abstractOptions = m.(NodeModule).getAModuleExportsValue()
575-
)
576-
}
577-
578546
override string toString() { result = file.toString() }
579547
}
580548

0 commit comments

Comments
 (0)