I want to parse through a javascript and find all the variable declarations, attributions, and calls to functions from a specific library.
What would be the best approach:regular expressions, lexer, use something already done that does that (does it exist?)….?
What I want in fact is to be assured that an object namespace and methods are not modified, and this through a static analysis.
You can not do it with regexes and probably you also do not want to write you own implementation of ecma-standard 262 (It is a total overkill).
As for me I dig google’s V8 javascript engine, more precisely PyV8. I suggest you can use it.
If you had problems there is the code I used to install (pip installation had an error for my x64 system, so I used sources):
As I remember these commands did not make errors for me. (I copypasted it but it worked)
Answer to the question itself:
More complex hello wolrd example, list some varibales of the global object:
(In browsers you should call you global object – Window)
This code will output: