Skip to content
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.

Commit

Permalink
fix(integrity): use EINTEGRITY error code and update ssri
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Apr 3, 2017
1 parent a2c1568 commit 8dc2e62
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -343,7 +343,7 @@ with an `EBADSIZE` error.

If present, the pre-calculated digest for the inserted content. If this option
if provided and does not match the post-insertion digest, insertion will fail
with an `EBADCHECKSUM` error.
with an `EINTEGRITY` error.

`hashAlgorithm` has no effect if this option is present.

Expand Down
2 changes: 1 addition & 1 deletion lib/content/read.js
Expand Up @@ -94,7 +94,7 @@ function sizeError (expected, found) {

function checksumError (sri, path) {
var err = new Error(`Checksum failed for ${sri} (${path})`)
err.code = 'EBADCHECKSUM'
err.code = 'EINTEGRITY'
err.sri = sri
err.path = path
return err
Expand Down
2 changes: 1 addition & 1 deletion lib/content/write.js
Expand Up @@ -159,7 +159,7 @@ function sizeError (expected, found) {

function checksumError (expected, found) {
var err = new Error('checksum failed')
err.code = 'EBADCHECKSUM'
err.code = 'EINTEGRITY'
err.expected = expected
err.found = found
return err
Expand Down
2 changes: 1 addition & 1 deletion lib/util/move-file.js
Expand Up @@ -12,7 +12,7 @@ function moveFile (src, dest) {
// trying to move it, we should just not bother.
//
// In the case of cache corruption, users will receive an
// EBADCHECKSUM error elsewhere, and can remove the offending
// EINTEGRITY error elsewhere, and can remove the offending
// content their own way.
//
// Note that, as the name suggests, this strictly only supports file moves.
Expand Down
2 changes: 1 addition & 1 deletion lib/verify.js
Expand Up @@ -133,7 +133,7 @@ function verifyContent (filepath, sri) {
fs.createReadStream(filepath),
sri
).catch(err => {
if (err.code !== 'EBADCHECKSUM') { throw err }
if (err.code !== 'EINTEGRITY') { throw err }
return rimraf(filepath).then(() => {
contentInfo.valid = false
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -67,7 +67,7 @@
"move-concurrently": "^1.0.0",
"promise-inflight": "^1.0.1",
"rimraf": "^2.6.1",
"ssri": "^3.0.0",
"ssri": "^4.0.0",
"unique-filename": "^1.1.0"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions test/content.read.js
Expand Up @@ -100,11 +100,11 @@ test('read: errors if content fails checksum', function (t) {
throw new Error('end was called even though stream errored')
})
return BB.join(
finished(stream).catch({code: 'EBADCHECKSUM'}, err => err),
read(CACHE, INTEGRITY).catch({code: 'EBADCHECKSUM'}, err => err),
finished(stream).catch({code: 'EINTEGRITY'}, err => err),
read(CACHE, INTEGRITY).catch({code: 'EINTEGRITY'}, err => err),
(streamErr, bulkErr) => {
t.equal(streamErr.code, 'EBADCHECKSUM', 'stream got the right error')
t.equal(bulkErr.code, 'EBADCHECKSUM', 'bulk got the right error')
t.equal(streamErr.code, 'EINTEGRITY', 'stream got the right error')
t.equal(bulkErr.code, 'EINTEGRITY', 'bulk got the right error')
}
)
})
Expand Down
2 changes: 1 addition & 1 deletion test/content.write.js
Expand Up @@ -55,7 +55,7 @@ test('checks input digest doesn\'t match data', t => {
}), err => {
t.ok(!int1, 'no digest emitted')
t.ok(!!err, 'got an error')
t.equal(err.code, 'EBADCHECKSUM', 'returns a useful error code')
t.equal(err.code, 'EINTEGRITY', 'returns a useful error code')
})
pipe(fromString(CONTENT), write.stream(CACHE, {
integrity: INTEGRITY
Expand Down

0 comments on commit 8dc2e62

Please sign in to comment.