1.0.4 • Published 2 years ago

open-loop-killer v1.0.4

Weekly downloads
1
License
MIT
Repository
github
Last release
2 years ago

Open Loop Killer

Prevent your code from open loops by injecting protection code for any loop detected

NPM Version NPM Downloads

Install

npm i open-loop-killer

Usage

  • Runs Untrusted code securely with no open loops issue.
  • Add one more layer of safety for your code.

How does it work

  • Compile the code to make sure it valid.
  • Convert it to AST.
  • Find any loop to inject the protection code to it.
  • Convert AST to String.

Example

const {injector} = require('open-loop-killer');

let code = `
    while(true){
    }
`
let injectedCode = injector(code));

Injected Code Be Like:

let _9ui = Date.now();
while (true) {
    if (Date.now() - _9ui > 1000) {
        throw new Error('Open Loop Detected!');
    }
    {
    }
}

License

MIT