swoops / eval_villain

A Firefox Web Extension to improve the discovery of DOM XSS.
GNU General Public License v3.0
249 stars 35 forks source link

Using Reflect.apply when proxying #1

Closed mikesamuel closed 5 years ago

mikesamuel commented 5 years ago

This avoids problems proxying functions with local modifications as in

function f() {
  console.log('f');
}
f.apply = function () { console.log('g'); }

const p = new Proxy(
    f,
    {
      apply(target, thisArg, args) {
        return target.apply(thisArg, args);
      }
    });
// Logs g
p();

const q = new Proxy(
    f,
    {
      apply(target, thisArg, args) {
        return Reflect.apply(target, thisArg, args);
      }
    });
// Logs f
q();
swoops commented 5 years ago

Thank you very much. I appreciate you looking at my code.

mikesamuel commented 5 years ago

Yw. It was nice chatting with you at bsides.