Wednesday 24 May 2017

Check condition from backend (if-else) without eval

I have node script and backend, the script contains certain data and it got some conditions from backend.

For ex node script:

var data={
  count: 10,
  length: 27,
  days: 3
};
var condition = 'count > 10 && length < 3'; // <=== this condition got from backend
if( ... condition ...) {
  // action 1
} else {
  // action 2
}

Can I get condition result without eval? Because data from backend evals is unsafe for server. Or is there a way to run this condition in the sandbox?



via MixerOID

No comments:

Post a Comment