Skip to content

module: isolate paths expecting to only use non-internals

Create a choke point so that non-internal module access can be done discretely from internal module access. Non-internal access through nonInternal will always check visibility in a way that is not succeptible to prototype mutation.

Due to internal nature of things, this isolation from proto mutation is not reasonably testable. An example of getting internals prior to this patch is:

  let _, s = 'startsWith',
    sp = String.prototype,
    op = Object.prototype,
    sw = sp[s],
    h = 'hasOwnProperty',
  hp = op[h];
  sp[s]=()=>false;
  op[h]=()=>true;
  _ = require('internal/child_process');
  sp[s]=sw;
  op[h]=hp;
  console.dir(_, {depth: null, colors: true});
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Merge request reports

Loading