File tree Expand file tree Collapse file tree
javascript/ql/lib/semmle/javascript/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -280,13 +280,22 @@ module NameResolution {
280280 result = enum .getMemberByName ( name ) .getIdentifier ( )
281281 )
282282 or
283+ storeToVariable ( result , name , mod .( Closure:: ClosureModule ) .getExportsVariable ( ) )
284+ }
285+
286+ /**
287+ * Holds if `value` is stored in `target.prop`. Only needs to recognise assignments
288+ * that are also recognised by JSDoc tooling such as the Closure compiler.
289+ */
290+ private predicate storeToVariable ( Expr value , string prop , LocalVariable target ) {
283291 exists ( AssignExpr assign |
284- assign
285- .getLhs ( )
286- .( PropAccess )
287- .accesses ( mod .( Closure:: ClosureModule ) .getExportsVariable ( ) .getAnAccess ( ) , name ) and
288- result = assign .getRhs ( )
292+ // exports.name = value
293+ assign .getLhs ( ) .( PropAccess ) .accesses ( target .getAnAccess ( ) , prop ) and
294+ value = assign .getRhs ( )
289295 )
296+ or
297+ // exports = { name: value }
298+ value = target .getAnAssignedExpr ( ) .( ObjectExpr ) .getPropertyByName ( prop ) .getInit ( )
290299 }
291300
292301 /** Steps that only apply for this configuration. */
You can’t perform that action at this time.
0 commit comments