mozilla / scanjs

[DEPRECATED] Static analysis tool for javascript code.
Other
428 stars 39 forks source link

Newscanner member rules don't support statements like bar[foo] #112

Closed pauljt closed 2 years ago

pauljt commented 10 years ago

The member rule .foo, matches both of the following statements, when they mean different things. We need a more complex rule to properly support

bar.foo bar[foo]

and the following is not identified at all:

bar['foo']

mozfreddyb commented 10 years ago

Since bar.foo is the same as bar['foo'], so we should just catch that in this easy case. In the bar[foo] case it's not that easy to resolve foo, but we could at least highlight that something dynamic is going on :|

pauljt commented 10 years ago

Yeh - actually i vaguely remember this just working in esprima. But it should be easy enough to modify the rule template just to check what type the callee is (identified or memberexpression) and do a check based on that.