Skip to content

Commit

Permalink
fix(metadata): mitigation when inconsistent data is loaded
Browse files Browse the repository at this point in the history
(cherry picked from commit 5873cca)
  • Loading branch information
mroz22 authored and matejkriz committed Oct 9, 2023
1 parent 794fabd commit 6c8d061
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/suite/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ module.exports = {
],
coverageThreshold: {
global: {
statements: 63,
branches: 51,
statements: 62.9,
branches: 50.7,
functions: 61,
lines: 65,
lines: 64.2,
},
},
modulePathIgnorePatterns: [
Expand Down
13 changes: 13 additions & 0 deletions packages/suite/src/actions/suite/metadataActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,19 @@ export const fetchMetadata =
aesKey,
);

// validation of fetched data structure. in theory, user may save any data in metadata file (although it is very unlikely)
// so we should make sure that it at least matches AccountLabels types
if (entity.type === 'account') {
if (!decryptedData.addressLabels) {
console.error('fetchMetadata: addressLabels missing in metadata file');
decryptedData.addressLabels = {};
}
if (!decryptedData.outputLabels) {
console.error('fetchMetadata: outputLabels missing in metadata file');
decryptedData.outputLabels = {};
}
}

return {
fileName,
data: decryptedData,
Expand Down

0 comments on commit 6c8d061

Please sign in to comment.