feat(xo-server-audit/_uploadLastHash): check integrity sequentially (#5250)

- implementation is simpler
- stop on first error
This commit is contained in:
badrAZ 2020-09-17 09:35:42 +02:00 committed by GitHub
parent 14ab694804
commit 8a98b6b012
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 10 deletions

View File

@ -35,5 +35,6 @@
> >
> In case of conflict, the highest (lowest in previous list) `$version` wins. > In case of conflict, the highest (lowest in previous list) `$version` wins.
- xo-server-audit patch
- xo-vmdk-to-vhd patch - xo-vmdk-to-vhd patch
- xo-web minor - xo-web minor

View File

@ -335,16 +335,18 @@ class AuditXoPlugin {
} }
// check the integrity of all stored hashes // check the integrity of all stored hashes
integrityCheckSuccess = await Promise.all( try {
hashes.map((oldest, key) => for (let i = 0; i < hashes.length - 1; ++i) {
oldest !== lastHash await this._checkIntegrity({
? this._checkIntegrity({ oldest, newest: hashes[key + 1] }) oldest: hashes[i],
: true newest: hashes[i + 1],
) })
).then( }
() => true,
() => false integrityCheckSuccess = true
) } catch (_) {
integrityCheckSuccess = false
}
} }
// generate a valid fingerprint of all stored records in case of a failure integrity check // generate a valid fingerprint of all stored records in case of a failure integrity check