Prevent your code from open loops by injecting protection code for any loop detected
npm i open-loop-killer
- Runs Untrusted code securely with no open loops issue.
- Add one more layer of safety for your code.
- 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.
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!');
}
{
}
}