Files
codeql/javascript/ql/test/query-tests/Security/CWE-094/CodeInjection/lib/index.js
2022-02-07 13:34:18 +01:00

15 lines
366 B
JavaScript

export function unsafeDeserialize(data) {
return eval("(" + data + ")"); // NOT OK
}
export function unsafeGetter(obj, name) {
return eval("obj." + name); // NOT OK
}
export function safeAssignment(obj, value) {
eval("obj.foo = " + JSON.stringify(value)); // OK
}
global.unsafeDeserialize = function (data) {
return eval("(" + data + ")"); // NOT OK
}