Skip to content

Inject protection code for any loop detected, to prevent open loops.

License

Notifications You must be signed in to change notification settings

dantemessy/openloopkiller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Inject protection code for any loop detected, to prevent open loops.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published