Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

12345678910111213141516171819202122232425262728293031323334353637
  1. const normalize = require('../')
  2. const t = require('tap')
  3. t.test('benign array', async t => {
  4. const pkg = { name: 'hello', version: 'world', bin: ['./x/y', 'y/z', './a'] }
  5. const expect = { name: 'hello', version: 'world', bin: {
  6. y: 'x/y',
  7. z: 'y/z',
  8. a: 'a',
  9. } }
  10. t.strictSame(normalize(pkg), expect)
  11. t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
  12. })
  13. t.test('conflicting array', async t => {
  14. const pkg = { name: 'hello', version: 'world', bin: ['./x/y', 'z/y', './a'] }
  15. const expect = { name: 'hello', version: 'world', bin: {
  16. y: 'z/y',
  17. a: 'a',
  18. } }
  19. t.strictSame(normalize(pkg), expect)
  20. t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
  21. })
  22. t.test('slashy array', async t => {
  23. const pkg = { name: 'hello', version: 'world', bin: [ '/etc/passwd' ] }
  24. const expect = { name: 'hello', version: 'world', bin: { passwd: 'etc/passwd' } }
  25. t.strictSame(normalize(pkg), expect)
  26. t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
  27. })
  28. t.test('dotty array', async t => {
  29. const pkg = { name: 'hello', version: 'world', bin: ['../../../../etc/passwd'] }
  30. const expect = { name: 'hello', version: 'world', bin: { passwd: 'etc/passwd' } }
  31. t.strictSame(normalize(pkg), expect)
  32. t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok')
  33. })