npm install iroh
or alternatively the browser distribution from here.
If you aren't familiar with the term dynamic analysis, then you can read about it here.
Iroh patches your code to be able to record everything happening inside it, but without changing the original program. You can add listeners to the patched code stage and then track and manipulate everything.
Iroh also keeps track of the call stack, which makes it possible to view the code's flow and visualize it within any kind of model.
Iroh supports strict mode
.
Since Iroh allows to intercept all calls in your code, even Function.toString
calls can be intercepted, which allows to remain JavaScript's original code reification feature. You can do the same for any other ways like String(ƒ)
or ƒ + ""
.
External (non-trackable) calls (e.g. eval
, Math.random
) get traced as external
.
Patched functions which get called from outside (e.g. setTimeout(ƒ)
) get traced as sloppy
.
The API exposes listeners for most AST node types. For example you can intercept all Calls
in your code and determine what happens before (e.g. track it's arguments) and after it's called (e.g. change it's return value based on the called function's name).
Iroh cannot record what's happening inside native calls, external or non-patched functions. If you want a function to be intercepted, then make sure to patch it as well.
The current main goal is to have full ES5
support.
Iroh is already successfully tested with jQuery
, acorn
and underscore
.
A subset of ES6 features is already supported.
Also node.js
support is ongoing since we can intercept require
calls.
For example, Iroh allows you to track, intercept and manipulate all data in your code during execution. You can collect and change types
, parameters
, return values
, allocated objects
, variables
, expressions
, function calls
and so on.
A simple textual model is used below to represent the code flow.
Since Iroh modifies your code heavily, Function.toString
calls would return the modified code instead of the original. See this example how this can be bypassed in just 3 lines of code.