Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 84f2572

Browse files
committed
test: adds test vulnerable to encoding translation
1 parent 1f0b72f commit 84f2572

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

js/src/object.js

+21
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ const dagPB = require('ipld-dag-pb')
1111
const DAGNode = dagPB.DAGNode
1212
const bs58 = require('bs58')
1313
const series = require('async/series')
14+
const UnixFs = require('ipfs-unixfs')
15+
const crypto = require('crypto')
16+
const CID = require('cids')
1417

1518
module.exports = (common) => {
1619
describe('.object', function () {
@@ -451,6 +454,24 @@ module.exports = (common) => {
451454
})
452455
})
453456
})
457+
458+
it('supplies unadulterated data', () => {
459+
// has to be big enough to span several DAGNodes
460+
const data = crypto.randomBytes(1024 * 300)
461+
462+
return ipfs.files.add({
463+
path: '',
464+
content: data
465+
})
466+
.then((result) => {
467+
return ipfs.object.get(result[0].hash)
468+
})
469+
.then((node) => {
470+
const meta = UnixFs.unmarshal(node.data)
471+
472+
expect(meta.fileSize()).to.equal(data.length)
473+
})
474+
})
454475
})
455476

456477
describe('.links', () => {

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"dirty-chai": "^2.0.1",
4343
"hat": "0.0.3",
4444
"ipfs-block": "~0.7.1",
45+
"ipfs-unixfs": "~0.1.15",
4546
"ipld-dag-cbor": "~0.12.0",
4647
"ipld-dag-pb": "~0.14.4",
4748
"is-ipfs": "~0.3.2",

0 commit comments

Comments
 (0)