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

Commit a69b9f0

Browse files
committed
test: adds test vulnerable to encoding translation
1 parent 83e410a commit a69b9f0

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

js/src/object/get.js

+21
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ const bs58 = require('bs58')
77
const series = require('async/series')
88
const hat = require('hat')
99
const { getDescribe, getIt, expect } = require('../utils/mocha')
10+
const UnixFs = require('ipfs-unixfs')
11+
const crypto = require('crypto')
12+
const CID = require('cids')
1013

1114
module.exports = (createCommon, options) => {
1215
const describe = getDescribe(options)
@@ -285,5 +288,23 @@ module.exports = (createCommon, options) => {
285288
}
286289
], done)
287290
})
291+
292+
it('supplies unadulterated data', () => {
293+
// has to be big enough to span several DAGNodes
294+
const data = crypto.randomBytes(1024 * 300)
295+
296+
return ipfs.files.add({
297+
path: '',
298+
content: data
299+
})
300+
.then((result) => {
301+
return ipfs.object.get(result[0].hash)
302+
})
303+
.then((node) => {
304+
const meta = UnixFs.unmarshal(node.data)
305+
306+
expect(meta.fileSize()).to.equal(data.length)
307+
})
308+
})
288309
})
289310
}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"dirty-chai": "^2.0.1",
4242
"hat": "0.0.3",
4343
"ipfs-block": "~0.7.1",
44+
"ipfs-unixfs": "~0.1.15",
4445
"ipld-dag-cbor": "~0.12.1",
4546
"ipld-dag-pb": "~0.14.5",
4647
"is-ipfs": "~0.3.2",

0 commit comments

Comments
 (0)