File tree Expand file tree Collapse file tree 3 files changed +27
-5
lines changed
javascript/ql/lib/semmle/javascript Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,23 @@ abstract class Module extends TopLevel {
111
111
cached
112
112
abstract DataFlow:: Node getAnExportedValue ( string name ) ;
113
113
114
+ /**
115
+ * Gets a value that is exported as the whole exports object of this module.
116
+ */
117
+ cached
118
+ DataFlow:: Node getABulkExportedNode ( ) { none ( ) } // overridden in subclasses
119
+
120
+ /**
121
+ * Gets the ES2015 `default` export from this module, or for other types of modules,
122
+ * gets a bulk exported node.
123
+ *
124
+ * This can be used to determine which value a default-import will likely refer to,
125
+ * as the interaction between different module types is not standardized.
126
+ */
127
+ DataFlow:: Node getDefaultOrBulkExport ( ) {
128
+ result = [ getAnExportedValue ( "default" ) , getABulkExportedNode ( ) ]
129
+ }
130
+
114
131
/**
115
132
* Gets the root folder relative to which the given import path (which must
116
133
* appear in this module) is resolved.
Original file line number Diff line number Diff line change @@ -99,6 +99,13 @@ class NodeModule extends Module {
99
99
)
100
100
}
101
101
102
+ override DataFlow:: Node getABulkExportedNode ( ) {
103
+ exists ( DataFlow:: PropWrite write |
104
+ write .getBase ( ) .asExpr ( ) = getModuleVariable ( ) .getAnAccess ( ) and
105
+ result = write .getRhs ( )
106
+ )
107
+ }
108
+
102
109
/** Gets a symbol that the module object inherits from its prototypes. */
103
110
private string getAnImplicitlyExportedSymbol ( ) {
104
111
exists ( ExternalConstructor ec | ec = getPrototypeOfExportedExpr ( ) |
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ module Vue {
21
21
override DataFlow:: SourceNode getAUse ( ) { none ( ) }
22
22
23
23
override DataFlow:: Node getARhs ( ) {
24
- result = any ( SingleFileComponent c ) .getModule ( ) .getAnExportedValue ( "default" )
24
+ result = any ( SingleFileComponent c ) .getModule ( ) .getDefaultOrBulkExport ( )
25
25
}
26
26
}
27
27
@@ -550,10 +550,8 @@ module Vue {
550
550
}
551
551
552
552
override API:: Node getOwnOptions ( ) {
553
- exists ( ExportDefaultDeclaration decl |
554
- decl .getTopLevel ( ) = getModule ( ) and
555
- result .getARhs ( ) = DataFlow:: valueNode ( decl .getOperand ( ) )
556
- )
553
+ // Use the entry point generated by `VueExportEntryPoint`
554
+ result .getARhs ( ) = getModule ( ) .getDefaultOrBulkExport ( )
557
555
}
558
556
559
557
override DataFlow:: Node getOwnOptionsObject ( ) {
You can’t perform that action at this time.
0 commit comments