Rule Definition
Executing code at run-time using eval or new Function() is considered to be very dangerous because it allows execution of an arbitrary code. It is recommended not to use these options unless no other approach is left.
Remediation
Refactor the source code to avoid executing arbitrary source code.
Violation Code Sample
var obj_val = { a: 2, b: 3 };
var propName = getPropName();
eval( 'var result = obj_val.' + propName );
Fixed Code Sample
var obj_val = { a: 2, b: 3 };
var propName = getPropName();
var result = obj_val[ propName ];
Related Technologies
Technical Criterion
CWE-78 - Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.