Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8dc2e62

Browse files
committedApr 3, 2017
fix(integrity): use EINTEGRITY error code and update ssri
1 parent a2c1568 commit 8dc2e62

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed
 

Diff for: ‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ with an `EBADSIZE` error.
343343

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

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

Diff for: ‎lib/content/read.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function sizeError (expected, found) {
9494

9595
function checksumError (sri, path) {
9696
var err = new Error(`Checksum failed for ${sri} (${path})`)
97-
err.code = 'EBADCHECKSUM'
97+
err.code = 'EINTEGRITY'
9898
err.sri = sri
9999
err.path = path
100100
return err

Diff for: ‎lib/content/write.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ function sizeError (expected, found) {
159159

160160
function checksumError (expected, found) {
161161
var err = new Error('checksum failed')
162-
err.code = 'EBADCHECKSUM'
162+
err.code = 'EINTEGRITY'
163163
err.expected = expected
164164
err.found = found
165165
return err

Diff for: ‎lib/util/move-file.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function moveFile (src, dest) {
1212
// trying to move it, we should just not bother.
1313
//
1414
// In the case of cache corruption, users will receive an
15-
// EBADCHECKSUM error elsewhere, and can remove the offending
15+
// EINTEGRITY error elsewhere, and can remove the offending
1616
// content their own way.
1717
//
1818
// Note that, as the name suggests, this strictly only supports file moves.

Diff for: ‎lib/verify.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function verifyContent (filepath, sri) {
133133
fs.createReadStream(filepath),
134134
sri
135135
).catch(err => {
136-
if (err.code !== 'EBADCHECKSUM') { throw err }
136+
if (err.code !== 'EINTEGRITY') { throw err }
137137
return rimraf(filepath).then(() => {
138138
contentInfo.valid = false
139139
})

Diff for: ‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"move-concurrently": "^1.0.0",
6868
"promise-inflight": "^1.0.1",
6969
"rimraf": "^2.6.1",
70-
"ssri": "^3.0.0",
70+
"ssri": "^4.0.0",
7171
"unique-filename": "^1.1.0"
7272
},
7373
"devDependencies": {

Diff for: ‎test/content.read.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ test('read: errors if content fails checksum', function (t) {
100100
throw new Error('end was called even though stream errored')
101101
})
102102
return BB.join(
103-
finished(stream).catch({code: 'EBADCHECKSUM'}, err => err),
104-
read(CACHE, INTEGRITY).catch({code: 'EBADCHECKSUM'}, err => err),
103+
finished(stream).catch({code: 'EINTEGRITY'}, err => err),
104+
read(CACHE, INTEGRITY).catch({code: 'EINTEGRITY'}, err => err),
105105
(streamErr, bulkErr) => {
106-
t.equal(streamErr.code, 'EBADCHECKSUM', 'stream got the right error')
107-
t.equal(bulkErr.code, 'EBADCHECKSUM', 'bulk got the right error')
106+
t.equal(streamErr.code, 'EINTEGRITY', 'stream got the right error')
107+
t.equal(bulkErr.code, 'EINTEGRITY', 'bulk got the right error')
108108
}
109109
)
110110
})

Diff for: ‎test/content.write.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ test('checks input digest doesn\'t match data', t => {
5555
}), err => {
5656
t.ok(!int1, 'no digest emitted')
5757
t.ok(!!err, 'got an error')
58-
t.equal(err.code, 'EBADCHECKSUM', 'returns a useful error code')
58+
t.equal(err.code, 'EINTEGRITY', 'returns a useful error code')
5959
})
6060
pipe(fromString(CONTENT), write.stream(CACHE, {
6161
integrity: INTEGRITY

0 commit comments

Comments
 (0)