security.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. 'use strict';
  2. const chai = require('chai');
  3. const sinon = require('sinon');
  4. const sinonChai = require('sinon-chai');
  5. const expect = chai.expect;
  6. chai.use(sinonChai);
  7. describe('Testing security', function () {
  8. const MultiIni = require('../src/multi-ini-class');
  9. it('Secure keys to fix prototype pollution', function () {
  10. var ini = new MultiIni();
  11. var data = ini.read('test/data/prototype_pollution.ini');
  12. expect(data).not.to.be.null;
  13. expect(data['test']).to.be.defined;
  14. expect(data['test']['value']).to.equal('key');
  15. expect(data['__proto__']['polluted']).to.be.undefined;
  16. expect({}.__proto__.polluted).to.be.undefined;
  17. expect(typeof polluted).to.equal('undefined');
  18. expect(data['__proto__']['path_polluted']).to.be.undefined;
  19. expect({}.__proto__.path_polluted).to.be.undefined;
  20. expect(typeof path_polluted).to.equal('undefined');
  21. expect(data['section_with_proto']).to.be.undefined;
  22. expect({}.__proto__.polluted).to.be.undefined;
  23. console.log(data);
  24. });
  25. });