CodeWitness

Audit dynamic expression evaluation

The expression comes from outside the application and is executed as JavaScript.

function calculate(expression) {
  return eval(expression);
}

Avoid turning untrusted text into code. Model the request as data and support only explicitly allowed operations.

What is the safest replacement for evaluating caller-supplied code?